Merge pull request #2875 from moizjv/fix-2026

Adding new capabilities to startApp in android adb, updating adb.startApp in appium, adding a test and updating package.json,caps.md and appium-adb submodule.
This commit is contained in:
Jonathan Lipps
2014-06-18 14:59:14 -07:00
8 changed files with 80 additions and 14 deletions

View File

@@ -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

View File

@@ -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) {
@@ -99,13 +103,25 @@ 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) {
var onStart = function (err) {
if (err) return cb(err);
cb(null, {
status: status.codes.Success.code
, value: null
cb(null,{
status: status.codes.Success.code,
value: null
});
});
};
this.adb.startApp({
pkg: this.args.appPackage,
activity: this.args.appActivity,
action: this.args.intentAction,
category: this.args.intentCategory,
flags: this.args.intentFlags,
waitPkg: pack,
waitActivity: activity,
optionalIntentArguments: this.args.optionalIntentArguments,
retry: true,
stopApp: false
}, onStart);
}.bind(this), secs * 1000);
}.bind(this));
}.bind(this));
@@ -584,7 +600,7 @@ 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) {
var onStart = function (err) {
if (err) return cb(err);
this.adb.isScreenLocked(function (err, isLocked) {
if (err) return cb(err);
@@ -598,7 +614,14 @@ androidCommon.unlockScreen = function (cb) {
setTimeout(unlockAndCheck, 1000);
}
}.bind(this));
}.bind(this));
}.bind(this);
this.adb.startApp({
pkg: "io.appium.unlock",
activity: ".Unlock",
action: "android.intent.action.MAIN",
category: "android.intent.category.LAUNCHER",
flags: "0x10200000"
}, onStart);
}.bind(this);
unlockAndCheck();
} else {

View File

@@ -343,8 +343,16 @@ 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({
pkg: this.args.appPackage,
activity: this.args.appActivity,
action: this.args.intentAction,
category: this.args.intentCategory,
flags: this.args.intentFlags,
waitPkg: this.args.appWaitPackage,
waitActivity: this.args.appWaitActivity,
optionalIntentArguments: this.args.optionalIntentArguments
}, cb);
} else {
this.adb.androidCoverage(this.args.androidCoverage, this.args.appWaitPackage,
this.args.appWaitActivity, cb);

View File

@@ -310,11 +310,22 @@ Selendroid.prototype.createSession = function (cb) {
if (err) {
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) {
var onStart = function (err) {
if (err) return cb(err);
return cb(null, body.sessionId);
}.bind(this));
}.bind(this);
return this.adb.startApp({
pkg: this.args.appPackage,
activity: this.args.appActivity,
action: this.args.intentAction,
category: this.args.intentCategory,
flags: this.args.intentFlags,
waitPkg: this.args.appWaitPackage,
waitActivity: this.args.appWaitActivity,
optionalIntentArguments: this.args.optionalIntentArguments,
retry: false
}, onStart);
}
return cb(null, body.sessionId);
}.bind(this), 1800);

View File

@@ -55,6 +55,10 @@ var androidCaps = [
, 'keyAlias'
, 'keyPassword'
, 'autoWebviewTimeout'
, 'intentAction'
, 'intentCategory'
, 'intentFlags'
, 'optionalIntentArguments'
];
var iosCaps = [

View File

@@ -41,7 +41,7 @@
},
"dependencies": {
"adm-zip": "~0.4.4",
"appium-adb": "1.0.2",
"appium-adb": "1.1.1",
"appium-atoms": "~0.0.5",
"appium-instruments": "1.1.0-beta2",
"appium-uiauto": "1.2.0-beta4",

View File

@@ -224,6 +224,22 @@ 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 () {