mirror of
https://github.com/appium/appium.git
synced 2026-02-12 21:10:10 -06:00
Merge pull request #1520 from jlipps/master
allow alternative type of clear through fastClear: false cap
This commit is contained in:
@@ -564,6 +564,7 @@ Appium.prototype.initDevice = function() {
|
||||
, appDeviceReadyTimeout: this.args.androidDeviceReadyTimeout
|
||||
, reset: !this.args.noReset
|
||||
, fastReset: this.fastReset
|
||||
, fastClear: this.desiredCapabilities.fastClear
|
||||
, useKeystore: this.args.useKeystore
|
||||
, keystorePath: this.args.keystorePath
|
||||
, keystorePassword: this.args.keystorePassword
|
||||
|
||||
@@ -80,6 +80,54 @@ androidCommon.prepareActiveDevice = function(cb) {
|
||||
}.bind(this));
|
||||
};
|
||||
|
||||
androidCommon.resetApp = function(cb) {
|
||||
if (this.fastClear) {
|
||||
logger.info("Running fastClear");
|
||||
this.adb.stopAndClear(this.appPackage, cb);
|
||||
} else {
|
||||
logger.info("Running old fashion clear (reinstall)");
|
||||
this.remoteApkExists(function(err, remoteApk) {
|
||||
if (err) return cb(err);
|
||||
if (!remoteApk) {
|
||||
return cb(new Error("Can't run clear if remote apk doesn't exist"));
|
||||
}
|
||||
this.adb.forceStop(this.appPackage, function(err) {
|
||||
if (err) return cb(err);
|
||||
this.adb.uninstallApk(this.appPackage, function(err) {
|
||||
if (err) return cb(err);
|
||||
this.adb.installRemote(remoteApk, cb);
|
||||
}.bind(this));
|
||||
}.bind(this));
|
||||
}.bind(this));
|
||||
}
|
||||
};
|
||||
|
||||
androidCommon.getRemoteApk = function(cb) {
|
||||
var next = function() {
|
||||
cb(null, this.remoteTempPath() + this.appMd5Hash + '.apk', this.appMd5Hash);
|
||||
}.bind(this);
|
||||
|
||||
if (this.appMd5Hash) {
|
||||
next();
|
||||
} else {
|
||||
this.getAppMd5(function(err, md5Hash) {
|
||||
if (err) return cb(err);
|
||||
this.appMd5Hash = md5Hash;
|
||||
next();
|
||||
}.bind(this));
|
||||
}
|
||||
};
|
||||
|
||||
androidCommon.remoteApkExists = function(cb) {
|
||||
this.getRemoteApk(function(err, remoteApk) {
|
||||
if (err) return cb(err);
|
||||
this.adb.shell("ls " + remoteApk, function(err, stdout) {
|
||||
if (err) return cb(err);
|
||||
cb(null, stdout.trim());
|
||||
});
|
||||
}.bind(this));
|
||||
};
|
||||
|
||||
androidCommon.installApp = function(cb) {
|
||||
if (this.apkPath === null) {
|
||||
logger.info("Skipping install since we launched with a package instead " +
|
||||
@@ -89,14 +137,13 @@ androidCommon.installApp = function(cb) {
|
||||
|
||||
this.adb.isAppInstalled(this.appPackage, function(err, installed) {
|
||||
if (installed && this.opts.fastReset) {
|
||||
this.adb.stopAndClear(this.appPackage, cb);
|
||||
this.resetApp(cb);
|
||||
} else if (!installed) {
|
||||
this.adb.checkAndSignApk(this.apkPath, this.appPackage, function(err) {
|
||||
if (err) return cb(err);
|
||||
this.adb.mkdir(this.remoteTempPath(), function(err) {
|
||||
if (err) return cb(err);
|
||||
this.getAppMd5(function(err, md5Hash) {
|
||||
var remoteApk = this.remoteTempPath() + md5Hash + '.apk';
|
||||
this.getRemoteApk(function(err, remoteApk, md5Hash) {
|
||||
if (err) return cb(err);
|
||||
this.removeTempApks([md5Hash], function(err, appExists) {
|
||||
if (err) return cb(err);
|
||||
|
||||
@@ -610,7 +610,7 @@ androidController.deleteCookies = function(cb) {
|
||||
|
||||
androidController.fastReset = function(cb) {
|
||||
async.series([
|
||||
function(cb) { this.adb.stopAndClear(this.appPackage, cb); }.bind(this),
|
||||
this.resetApp.bind(this),
|
||||
this.waitForActivityToStop.bind(this),
|
||||
this.startApp.bind(this)
|
||||
], cb);
|
||||
|
||||
@@ -25,6 +25,7 @@ var Android = function(opts) {
|
||||
Android.prototype.initialize = function(opts) {
|
||||
this.compressXml = opts.compressXml;
|
||||
this.skipUninstall = opts.fastReset || !opts.reset;
|
||||
this.fastClear = opts.fastClear !== false;
|
||||
this.rest = opts.rest;
|
||||
this.webSocket = opts.webSocket;
|
||||
opts.systemPort = opts.systemPort || 4724;
|
||||
@@ -34,6 +35,7 @@ Android.prototype.initialize = function(opts) {
|
||||
this.udid = opts.udid;
|
||||
this.appPackage = opts.appPackage;
|
||||
this.appActivity = opts.appActivity;
|
||||
this.appMd5Hash = null;
|
||||
this.appWaitActivity = opts.appWaitActivity || opts.appActivity;
|
||||
this.avdName = opts.avdName || null;
|
||||
this.appDeviceReadyTimeout = opts.appDeviceReadyTimeout;
|
||||
|
||||
@@ -115,6 +115,18 @@ describeWd('basic', function(h) {
|
||||
});
|
||||
});
|
||||
|
||||
describeWd('without fastClear', function(h) {
|
||||
it('should still be able to reset', function(done) {
|
||||
h.driver.execute('mobile: reset', function(err) {
|
||||
should.not.exist(err);
|
||||
h.driver.getWindowSize(function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
}, null, null, null, {fastClear: false});
|
||||
|
||||
describeWd2('activity style: no period', function(h) {
|
||||
it('should should still find activity', function(done) {
|
||||
done();
|
||||
|
||||
Reference in New Issue
Block a user