mirror of
https://github.com/appium/appium.git
synced 2026-10-26 18:51:48 +08:00
Merge pull request #1726 from jlipps/master
cleanup app state before a test too (rewrite of #1732)
This commit is contained in:
+36
-18
@@ -622,27 +622,45 @@ IOS.prototype.setDeviceAndLaunchSimulator = function(cb) {
|
||||
cb(new Error(msg));
|
||||
} else {
|
||||
|
||||
this.endSimulator(function(err) {
|
||||
if (err) return cb(err);
|
||||
var cleanup = function(cb) {
|
||||
if (this.reset) {
|
||||
this.cleanupAppState(cb);
|
||||
} else {
|
||||
cb();
|
||||
}
|
||||
}.bind(this);
|
||||
|
||||
var setDeviceInfo = function(cb) {
|
||||
var iosDeviceString = this.getDeviceString();
|
||||
var isiPhone = iosDeviceString.toLowerCase().indexOf("ipad") === -1;
|
||||
var iosSimArgs = ["-SimulateDevice", iosDeviceString];
|
||||
logger.debug("Launching device: " + iosDeviceString);
|
||||
this.setDeviceTypeInInfoPlist(isiPhone ? 1 : 2, function() {
|
||||
this.iosSimProcess = spawn(iosSimPath, iosSimArgs);
|
||||
var waitForSimulatorLogs = function(countdown) {
|
||||
if (countdown <= 0 || this.logs.syslog.getAllLogs().length > 0 || this.logs.crashlog.getAllLogs().length > 0) {
|
||||
logger.info(countdown > 0 ? "Simulator is now ready." : "Waited 10 seconds for simulator to start.");
|
||||
cb();
|
||||
} else {
|
||||
setTimeout(function() {
|
||||
waitForSimulatorLogs(countdown-1);
|
||||
} ,1000);
|
||||
}
|
||||
}.bind(this);
|
||||
waitForSimulatorLogs(10);
|
||||
}.bind(this));
|
||||
}.bind(this));
|
||||
this.setDeviceTypeInInfoPlist(isiPhone ? 1 : 2, cb);
|
||||
}.bind(this);
|
||||
|
||||
var startSim = function(cb) {
|
||||
var iosSimArgs = ["-SimulateDevice", this.getDeviceString()];
|
||||
this.iosSimProcess = spawn(iosSimPath, iosSimArgs);
|
||||
var waitForSimulatorLogs = function(countdown) {
|
||||
if (countdown <= 0 || this.logs.syslog.getAllLogs().length > 0 || this.logs.crashlog.getAllLogs().length > 0) {
|
||||
logger.info(countdown > 0 ? "Simulator is now ready." : "Waited 10 seconds for simulator to start.");
|
||||
cb();
|
||||
} else {
|
||||
setTimeout(function() {
|
||||
waitForSimulatorLogs(countdown-1);
|
||||
} ,1000);
|
||||
}
|
||||
}.bind(this);
|
||||
waitForSimulatorLogs(10);
|
||||
}.bind(this);
|
||||
|
||||
async.series([
|
||||
this.endSimulator.bind(this),
|
||||
cleanup,
|
||||
setDeviceInfo,
|
||||
startSim
|
||||
], function(err) {
|
||||
cb(err);
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user