Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding new capabilities to start android app, changing adb.startApp to pass all arguments, adding functional test and updating cap.md #2856

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/en/caps.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@
|`chromedriverExecutable`| The absolute local path to webdriver executable (if Chromium embedder provides its own webdriver, it should be used instead of original chromedriver bundled with Appium) |`/abs/path/to/webdriver`|
|`specialChromedriverSessionArgs`| Custom arguments passed directly to chromedriver in chromeOptions capability. Passed as object which properties depend on a specific webdriver. |e.g., `{'androidDeviceSocket': 'opera_beta_devtools_remote',}`|
|`autoWebviewTimeout`| Amount of time to wait for Webview context to become active, in ms. Defaults to `2000`| e.g. `4`|
|`intentAction`| Intent action which will be used to start activity (default `android.intent.action.MAIN`)| e.g.`android.intent.action.MAIN`, `android.intent.action.VIEW`|
|`intentCategory`| Intent category which will be used to start activity (default `android.intent.category.LAUNCHER`)| e.g. `android.intent.category.LAUNCHER`, `android.intent.category.APP_CONTACTS`
|`intentFlags`| Flags that will be used to start activity (default `0x10200000`)| e.g. `0x10200000`
|`optionalIntentArguments`| Additional intent arguments that will be used to start activity. See [Intent arguments](http://developer.android.com/tools/help/adb.html#IntentSpec) | e.g. `--esn <EXTRA_KEY>`, `--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE>`, etc.


### iOS Only
Expand Down
10 changes: 8 additions & 2 deletions lib/devices/android/android-common.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,12 @@ androidCommon.setAndroidArgs = function () {
this.args.appActivity;
this.appProcess = this.args.appPackage;
this.args.appDeviceReadyTimeout = this.args.androidDeviceReadyTimeout;
// TODO better way to set defaults.
this.args.avdLaunchTimeout = this.args.avdLaunchTimeout || 120000;
this.args.avdReadyTimeout = this.args.avdReadyTimeout || 120000;
this.args.intentAction = this.args.intentAction || "android.intent.action.MAIN";
this.args.intentCategory = this.args.intentCategory || "android.intent.category.LAUNCHER";
this.args.intentFlags = this.args.intentFlags || "0x10200000";
};

androidCommon.background = function (secs, cb) {
Expand All @@ -99,7 +103,8 @@ androidCommon.background = function (secs, cb) {
if (err) return cb(err);

setTimeout(function () {
this.adb.startApp(this.args.appPackage, this.args.appActivity, pack, activity, true, false, function (err) {
this.adb.startApp(this.args.appPackage, this.args.appActivity, this.args.intentAction, this.args.intentCategory,
this.args.intentFlags, pack, activity, this.args.optionalIntentArguments, true, false, function (err) {
if (err) return cb(err);
cb(null, {
status: status.codes.Success.code
Expand Down Expand Up @@ -584,7 +589,8 @@ androidCommon.unlockScreen = function (cb) {
var start = Date.now();
var unlockAndCheck = function () {
logger.debug("Screen is locked, trying to unlock");
this.adb.startApp("io.appium.unlock", ".Unlock", function (err) {
this.adb.startApp("io.appium.unlock", ".Unlock","android.intent.action.MAIN","android.intent.category.LAUNCHER",
"0x10200000" , false, false, null, true, true, function (err) {
if (err) return cb(err);
this.adb.isScreenLocked(function (err, isLocked) {
if (err) return cb(err);
Expand Down
5 changes: 3 additions & 2 deletions lib/devices/android/android.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,9 @@ Android.prototype.pushAppium = function (cb) {

Android.prototype.startApp = function (cb) {
if (!this.args.androidCoverage) {
this.adb.startApp(this.args.appPackage, this.args.appActivity, this.args.appWaitPackage,
this.args.appWaitActivity, cb);
this.adb.startApp(this.args.appPackage, this.args.appActivity, this.args.intentAction,
this.args.intentCategory, this.args.intentFlags, this.args.appWaitPackage,
this.args.appWaitActivity, this.args.optionalIntentArguments, true, true, cb);
} else {
this.adb.androidCoverage(this.args.androidCoverage, this.args.appWaitPackage,
this.args.appWaitActivity, cb);
Expand Down
12 changes: 8 additions & 4 deletions lib/devices/android/selendroid.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,10 +311,14 @@ Selendroid.prototype.createSession = function (cb) {
logger.debug("Selendroid hasn't started app yet, let's do it " +
"manually with adb.startApp");
return this.adb.startApp(this.args.appPackage, this.args.appActivity,
this.args.appWaitPackage, this.args.appWaitActivity, false, function (err) {
if (err) return cb(err);
return cb(null, body.sessionId);
}.bind(this));
this.args.intentAction, this.args.intentCategory,
this.args.intentFlags, this.args.appWaitPackage,
this.args.appWaitActivity, this.args.optionalIntentArguments, false,
true,
function (err) {
if (err) return cb(err);
return cb(null, body.sessionId);
}.bind(this));
}
return cb(null, body.sessionId);
}.bind(this), 1800);
Expand Down
4 changes: 4 additions & 0 deletions lib/server/capabilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ var androidCaps = [
, 'keyAlias'
, 'keyPassword'
, 'autoWebviewTimeout'
, 'intentAction'
, 'intentCategory'
, 'intentFlags'
, 'optionalIntentArguments'
];

var iosCaps = [
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
},
"dependencies": {
"adm-zip": "~0.4.4",
"appium-adb": "~1.0.2",
"appium-adb": "~1.0.3",
"appium-atoms": "~0.0.5",
"appium-instruments": "~1.0.0",
"appium-uiauto": "~1.2.0-beta1",
Expand Down
2 changes: 1 addition & 1 deletion submodules/appium-adb
Submodule appium-adb updated 2 files
+8 −29 lib/adb.js
+1 −1 package.json
17 changes: 17 additions & 0 deletions test/functional/android/apidemos/basic-specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,23 @@ describe("apidemo - basic @skip-ci", function () {
.nodeify(done);
});
});

describe('launching activity with custom intent parameter category', function () {
var driver;
var caps = _.clone(desired);
caps.appActivity = "io.appium.android.apis.app.HelloWorld";
caps.intentCategory = "appium.android.intent.category.SAMPLE_CODE";
setup(this, caps)
.then(function (d) { driver = d; });

it('should launch activity with intent category', function (done) {
driver
.getCurrentActivity()
.should.eventually.include("HelloWorld")
.nodeify(done);
});
});

});

describe('appium android', function () {
Expand Down