Implementing mobile:background command for Android and Selendroid

This commit is contained in:
imrane
2014-01-03 11:16:44 +00:00
committed by Romain Criton
parent c1a6fca60a
commit 1c6b495cd2
3 changed files with 22 additions and 4 deletions

View File

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

View File

@@ -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);
};

View File

@@ -38,6 +38,7 @@ var Selendroid = function(opts) {
, 'getCommandTimeout'
, 'reset'
, 'lock'
, 'background'
, 'keyevent'
, 'currentActivity'
, 'installApp'