mirror of
https://github.com/appium/appium.git
synced 2026-02-08 10:38:58 -06:00
Implementing mobile:background command for Android and Selendroid
This commit is contained in:
@@ -14,6 +14,27 @@ var logTypesSupported = {
|
||||
|
||||
var androidCommon = {};
|
||||
|
||||
androidCommon.background = function(secs, cb) {
|
||||
console.log("background " + this.appPackage + " " + this.appActivity);
|
||||
this.adb.keyevent("3", function() {
|
||||
cb(null, {
|
||||
status: status.codes.Success.code
|
||||
, value: null
|
||||
});
|
||||
});
|
||||
setTimeout(function(){
|
||||
var appName = this.appActivity.replace(this.appPackage,this.appPackage + "/");
|
||||
this.adb.shell("am start -n "+ appName, function(err, stdout) {
|
||||
if (err) return cb(err);
|
||||
if (stdout.indexOf("No such file") !== -1) {
|
||||
return cb(new Error("remote apk did not exist"));
|
||||
}
|
||||
cb(null, stdout.trim());
|
||||
});
|
||||
}.bind(this),secs *1000) ;
|
||||
|
||||
};
|
||||
|
||||
androidCommon.prepareDevice = function(onReady) {
|
||||
logger.info("Preparing device for session");
|
||||
async.series([
|
||||
|
||||
@@ -352,10 +352,6 @@ androidController.lock = function(secs, cb) {
|
||||
cb(new NotYetImplementedError(), null);
|
||||
};
|
||||
|
||||
androidController.background = function(secs, cb) {
|
||||
cb(new NotYetImplementedError(), null);
|
||||
};
|
||||
|
||||
androidController.getOrientation = function(cb) {
|
||||
this.proxy(["orientation", {}], cb);
|
||||
};
|
||||
|
||||
@@ -38,6 +38,7 @@ var Selendroid = function(opts) {
|
||||
, 'getCommandTimeout'
|
||||
, 'reset'
|
||||
, 'lock'
|
||||
, 'background'
|
||||
, 'keyevent'
|
||||
, 'currentActivity'
|
||||
, 'installApp'
|
||||
|
||||
Reference in New Issue
Block a user