diff --git a/lib/devices/android/selendroid.js b/lib/devices/android/selendroid.js index 32902f586..bf1921bf1 100644 --- a/lib/devices/android/selendroid.js +++ b/lib/devices/android/selendroid.js @@ -153,6 +153,7 @@ Selendroid.prototype.start = function (cb) { async.series([ this.ensureServerExists.bind(this), this.prepareDevice.bind(this), + this.checkInternetPermissionForApp.bind(this), this.packageAndLaunchActivityFromManifest.bind(this), checkModServerExists, conditionalInsertManifest, @@ -189,6 +190,23 @@ Selendroid.prototype.pushSelendroid = function (cb) { this.adb.instrument(this.args.appPackage, this.args.appActivity, instrumentWith, cb); }; +Selendroid.prototype.checkInternetPermissionForApp = function (cb) { + var apk = this.args.app; + this.adb.hasInternetPermissionFromManifest(apk, function (err, hasInternetPermission) { + if (err) return cb(err); + if (hasInternetPermission) { + return cb(); + } + else { + var errorMessg = "apk does not have INTERNET permissions. Selendroid needs internet " + + "permission to proceed, please check if you have in your " + + "AndroidManifest.xml"; + cb(new Error(errorMessg)); + } + }); +}; + Selendroid.prototype.checkSelendroidCerts = function (cb) { var alreadyReturned = false , checks = 0; diff --git a/package.json b/package.json index d34f1d954..e6a910877 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ }, "dependencies": { "adm-zip": "~0.4.4", - "appium-adb": "~1.3.1", + "appium-adb": "~1.3.2", "appium-atoms": "~0.0.5", "appium-instruments": "~1.3.0", "appium-uiauto": "~1.6.0", @@ -117,7 +117,7 @@ "socks": "~0.0.1", "underscore-cli": "~0.2.17", "unorm": "~1.3.3", - "wd": "~0.3.1", + "wd": "~0.3.4", "wd-bridge": "~0.0.1", "yiewd": "~0.5.0" } diff --git a/submodules/appium-adb b/submodules/appium-adb index 34f92d668..d795864b1 160000 --- a/submodules/appium-adb +++ b/submodules/appium-adb @@ -1 +1 @@ -Subproject commit 34f92d668161eb35158e0247523682a5c870c114 +Subproject commit d795864b161aa4ca9f2dd0959419b3625b19f3bb diff --git a/test/functional/selendroid/app-permission-spec.js b/test/functional/selendroid/app-permission-spec.js new file mode 100644 index 000000000..ccb20200c --- /dev/null +++ b/test/functional/selendroid/app-permission-spec.js @@ -0,0 +1,29 @@ +"use strict"; + +require('../../helpers/setup-chai'); + +var env = require('../../helpers/env') + , initSession = require('../../helpers/session').initSession + , _ = require('underscore') + , desired = require('./desired'); + +describe('should not launch app without internet permission', function () { + this.timeout(env.MOCHA_INIT_TIMEOUT); + var session; + var name = this.title; + it('should not launch app', function (done) { + var newDesired = _.defaults({'app': 'sample-code/apps/ContactManager/ContactManager.apk'}, desired); + afterEach(function (done) { + session + .tearDown(this.currentTest.state === 'failed') + .nodeify(done); + }); + session = initSession(newDesired, {'no-retry': true, 'expect-error': true}); + session + .setUp(name).catch(function (err) { + err.data.should.include("INTERNET"); + throw err; + }).should.be.rejectedWith(/The environment you requested was unavailable./) + .nodeify(done); + }); +});