mirror of
https://github.com/appium/appium.git
synced 2026-02-09 11:18:51 -06:00
allow enabling/disabling locationservices via caps
This commit is contained in:
@@ -33,5 +33,6 @@ Appium server capabilities
|
||||
|`language`| Language to set for the iOS Simulator|e.g. `fr`|
|
||||
|`launchTimeout`| Amount of time in ms to wait for instruments before assuming it hung and failing the session|e.g. `20000`|
|
||||
|`locale`| Locale to set for the iOS Simulator|e.g. `fr_CA`|
|
||||
|`locationServicesEnabled`| Force location services to be either on or off|`true` or `false`|
|
||||
|`autoAcceptAlerts`| Accept iOS privacy access permission alerts (e.g., location, contacts, photos). Default is false.|
|
||||
|`nativeInstrumentsLib`| Use native intruments lib (ie disable instruments-without-delay).|
|
||||
|
||||
@@ -23,6 +23,7 @@ var path = require('path')
|
||||
, async = require('async')
|
||||
, iOSController = require('./ios-controller.js')
|
||||
, iOSHybrid = require('./ios-hybrid.js')
|
||||
, settings = require('./settings.js')
|
||||
, UnknownError = errors.UnknownError;
|
||||
|
||||
// XML Plist library helper
|
||||
@@ -194,6 +195,7 @@ IOS.prototype.start = function(cb, onDie) {
|
||||
this.detectUdid.bind(this),
|
||||
this.parseLocalizableStrings.bind(this),
|
||||
this.setLocale.bind(this),
|
||||
this.setPreferences.bind(this),
|
||||
this.startLogCapture.bind(this),
|
||||
this.setDeviceAndLaunchSimulator.bind(this),
|
||||
this.installToRealDevice.bind(this),
|
||||
@@ -405,6 +407,22 @@ IOS.prototype.setLocale = function(cb) {
|
||||
}
|
||||
};
|
||||
|
||||
IOS.prototype.setPreferences = function(cb) {
|
||||
logger.info("Setting iOS and app preferences");
|
||||
var err = null;
|
||||
if (typeof this.capabilities.locationServicesEnabled !== "undefined") {
|
||||
var locServ = this.capabilities.locationServicesEnabled ? 1 : 0;
|
||||
logger.info("Setting location services to " + locServ);
|
||||
try {
|
||||
settings.updateSettings(this.iOSSDKVersion, 'locationServices',
|
||||
{LocationServicesEnabled: locServ});
|
||||
} catch (e) {
|
||||
err = e;
|
||||
}
|
||||
}
|
||||
cb(err);
|
||||
};
|
||||
|
||||
IOS.prototype.detectTraceTemplate = function(cb) {
|
||||
var msg;
|
||||
if (!this.automationTraceTemplatePath) {
|
||||
|
||||
@@ -49,12 +49,10 @@ var prefs = {
|
||||
|
||||
var getPlistPath = function(plist, sdk) {
|
||||
var file = plists[plist];
|
||||
console.log(file);
|
||||
var base = getPrefsDir(sdk);
|
||||
if (plist === 'mobileSafari' && parseFloat(sdk) >= 7) {
|
||||
base = getSafari7Dir(sdk);
|
||||
}
|
||||
console.log(base);
|
||||
return path.resolve(base, file);
|
||||
};
|
||||
|
||||
@@ -118,7 +116,7 @@ var checkValidSettings = function(forPlist, prefSet) {
|
||||
};
|
||||
|
||||
settings.writeSettings = function(sdk, forPlist, prefSet, bypassCheck) {
|
||||
logger.info("Writing settings for " + forPlist);
|
||||
logger.info("Writing settings for " + forPlist + ":");
|
||||
logger.info(JSON.stringify(prefSet));
|
||||
if (!bypassCheck) {
|
||||
checkValidSettings(forPlist, prefSet);
|
||||
|
||||
@@ -33,3 +33,26 @@ describeWd('settings app', function(h) {
|
||||
}).nodeify(done);
|
||||
});
|
||||
});
|
||||
|
||||
var checkLocServ = function(h, expected, cb) {
|
||||
h.driver
|
||||
.execute("mobile: findAndAct", [{strategy: "tag name", selector: "tableCell", index: 2}])
|
||||
.sleep(1000)
|
||||
.execute("mobile: findAndAct", [{strategy: "tag name", selector: "tableCell", index: 0}])
|
||||
.elementByTagName('switch')
|
||||
.getValue().then(function(checked) {
|
||||
checked.should.eql(expected);
|
||||
}).nodeify(cb);
|
||||
};
|
||||
|
||||
describeWd('settings app with location services', function(h) {
|
||||
it('should respond to positive locationServicesEnabled cap', function(done) {
|
||||
checkLocServ(h, 1, done);
|
||||
});
|
||||
}, null, null, {locationServicesEnabled: true});
|
||||
|
||||
describeWd('settings app without location services', function(h) {
|
||||
it('should respond to negative locationServicesEnabled cap', function(done) {
|
||||
checkLocServ(h, 0, done);
|
||||
});
|
||||
}, null, null, {locationServicesEnabled: false});
|
||||
|
||||
Reference in New Issue
Block a user