Select Simulator Device & SDK

* use deviceName + version caps to launch a particular simulator device and SDK version (6.1, 7.0.3, 7.1)
* update appium-instruments submodule with corresponding change
* fail if the user tries to set preferences or language/locale and full-reset is requested since they don't work together

Fix #2032, #1642, #304
This commit is contained in:
Dan Doveralba
2014-03-13 22:38:53 -07:00
parent a8f0285336
commit 968b28bfb4
2 changed files with 37 additions and 11 deletions

View File

@@ -310,6 +310,7 @@ IOS.prototype.makeInstruments = function () {
, launchTimeout: this.args.launchTimeout
, flakeyRetries: this.args.backendRetries
, logNoColors: this.args.logNoColors
, simulatorSdkAndDevice: this.getDeviceString()
});
};
@@ -431,6 +432,11 @@ IOS.prototype.setLocale = function (cb) {
var setLoc = function (err) {
if (err) return cb(err);
var iosSimLocalePath = path.resolve(__dirname, "../../../build/ios-sim-locale");
if (this.args.fullReset) {
msg = "Cannot set locale information because a full-reset was requested";
logger.error(msg);
return cb(new Error(msg));
}
if (fs.existsSync(iosSimLocalePath)) {
helpers.getiOSSimulatorDirectories(function (err, pathList) {
if (err || typeof pathList === 'undefined' || pathList.length < 1) {
@@ -455,6 +461,7 @@ IOS.prototype.setLocale = function (cb) {
cmd = (this.args.language) ? cmd + ' -language ' + this.args.language : cmd;
cmd = (this.args.locale) ? cmd + ' -locale ' + this.args.locale : cmd;
cmd = (this.args.calendarFormat) ? cmd + ' -calendar ' + this.args.calendarFormat : cmd;
logger.info("Setting locale with command " + cmd);
exec(cmd, { maxBuffer: 524288 }, function (err) {
if (err === null) {
localeInfoWasSet = true;
@@ -495,6 +502,13 @@ IOS.prototype.setPreferences = function (cb) {
return cb();
}
if (this.args.fullReset) {
var msg = "Cannot set preferences because a full-reset was requested";
logger.info(msg);
logger.error(msg);
return cb(new Error(msg));
}
var settingsCaps = [
'locationServicesEnabled',
'locationServicesAuthorized',
@@ -548,7 +562,7 @@ IOS.prototype.setPreferences = function (cb) {
};
IOS.prototype.instantLaunchAndQuit = function (cb) {
logger.info("Sim files for this SDK do not yet exist, launching the sim " +
logger.info("Sim files for the " + this.iOSSDKVersion + " SDK do not yet exist, launching the sim " +
"to populate the applications and preference dirs");
this.setDeviceAndLaunchSimulator(function (err) {
if (err) return cb(err);
@@ -771,6 +785,9 @@ IOS.prototype.getDeviceString = function () {
iosDeviceString += is64bit ? " (64-bit)" : "";
}
}
if (this.iOSSDKVersion >= 7.1) {
iosDeviceString += " - Simulator - iOS " + this.args.version;
}
return iosDeviceString;
};
@@ -851,11 +868,11 @@ IOS.prototype.setDeviceAndLaunchSimulator = function (cb) {
var setDeviceInfo = function (cb) {
var iosDeviceString = this.getDeviceString();
var isiPhone = iosDeviceString.toLowerCase().indexOf("ipad") === -1;
logger.debug("Launching device: " + iosDeviceString);
this.setDeviceTypeInInfoPlist(isiPhone ? 1 : 2, cb);
}.bind(this);
var startSim = function (cb) {
logger.debug("Launching device: " + iosDeviceString);
var iosSimArgs = ["-SimulateDevice", this.getDeviceString()];
this.iosSimProcess = spawn(iosSimPath, iosSimArgs);
var waitForSimulatorLogs = function (countdown) {
@@ -872,14 +889,23 @@ IOS.prototype.setDeviceAndLaunchSimulator = function (cb) {
waitForSimulatorLogs(10);
}.bind(this);
async.series([
this.endSimulator.bind(this),
cleanup,
setDeviceInfo,
startSim
], function (err) {
cb(err);
});
if (this.iOSSDKVersion < 7.1) {
async.series([
this.endSimulator.bind(this),
cleanup,
setDeviceInfo,
startSim
], function (err) {
cb(err);
});
} else {
async.series([
this.endSimulator.bind(this),
cleanup,
], function (err) {
cb(err);
});
}
}
}
};