Skip to content

Commit

Permalink
Fix async fullReset on Android
Browse files Browse the repository at this point in the history
Update docs
  • Loading branch information
bootstraponline committed Feb 4, 2014
1 parent 44e5e14 commit 4d7d053
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 13 deletions.
4 changes: 2 additions & 2 deletions docs/server-args.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ All flags are optional, but some are required in conjunction with certain others
|`-k`, `--keep-artifacts`|false|(IOS-only) Keep Instruments trace directories||
|`-r`, `--backend-retries`|3|(iOS-only) How many times to retry launching Instruments before saying it crashed or timed out|`--backend-retries 3`|
|`--session-override`|false|Enables session override (clobbering)||
|`--full-reset`|false|(iOS) Delete the entire simulator folder. (Android) Reset app state by uninstalling app instead of clearing app data||
|`--full-reset`|false|(iOS) Delete the entire simulator folder. (Android) Reset app state by uninstalling app instead of clearing app data. On Android, this will also remove the app after the session is complete.||
|`--no-reset`|false|Don't reset app state between sessions (IOS: don't delete app plist files; Android: don't uninstall app before new session)||
|`-l`, `--pre-launch`|false|Pre-launch the application before allowing the first session (Requires --app and, for Android, --app-pkg and --app-activity)||
|`-lt`, `--launch-timeout`|90000|(iOS-only) how long in ms to wait for Instruments to launch||
Expand Down Expand Up @@ -49,7 +49,7 @@ All flags are optional, but some are required in conjunction with certain others
|`-ra`, `--robot-address`|0.0.0.0|IP Address of robot|`--robot-address 0.0.0.0`|
|`-rp`, `--robot-port`|-1|port for robot|`--robot-port 4242`|
|`--selendroid-port`|8080|Local port used for communication with Selendroid|`--selendroid-port 8080`|
|`--chromedriver-port`|9515|(Android-only) Local port used for running ChromeDriver|`--chromedriver-port 9515`|
|`--chromedriver-port`|9515|Port upon which ChromeDriver will run|`--chromedriver-port 9515`|
|`--use-keystore`|false|(Android-only) When set the keystore will be used to sign apks.||
|`--keystore-path`|/Users/user/.android/debug.keystore|(Android-only) Path to keystore||
|`--keystore-password`|android|(Android-only) Password to keystore||
Expand Down
21 changes: 14 additions & 7 deletions lib/devices/android/android.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,16 @@ Android.prototype.requestXmlCompression = function (cb) {
Android.prototype.stop = function (cb) {
this.shuttingDown = true;

var completeShutdown = function (cb) {
if (this.adb) {
this.adb.goToHome(function () {
this.shutdown(cb);
}.bind(this));
} else {
this.shutdown(cb);
}
}.bind(this);

if (this.opts.fullReset) {
logger.info("Removing app from device");
this.uninstallApp(function (err) {
Expand All @@ -327,16 +337,13 @@ Android.prototype.stop = function (cb) {
// process
logger.warn(err);
}
completeShutdown(cb);
});
}

if (this.adb) {
this.adb.goToHome(function () {
this.shutdown(cb);
}.bind(this));
} else {
this.shutdown(cb);
completeShutdown(cb);
}


};

Android.prototype.cleanup = function () {
Expand Down
16 changes: 12 additions & 4 deletions lib/devices/android/selendroid.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,14 @@ Selendroid.prototype.checkSelendroidCerts = function (cb) {
};

Selendroid.prototype.stop = function (cb) {

var completeShutdown = function (cb) {
logger.info("Stopping selendroid server");
this.deleteSession(function (err) {
cb(err ? 1 : 0);
});
}.bind(this);

if (this.opts.fullReset) {
logger.info("Removing app from device");
this.uninstallApp(function (err) {
Expand All @@ -177,13 +185,13 @@ Selendroid.prototype.stop = function (cb) {
// process
logger.warn(err);
}
completeShutdown(cb);
});
} else {
completeShutdown(cb);
}

logger.info("Stopping selendroid server");
this.deleteSession(function (err) {
cb(err ? 1 : 0);
});

};

Selendroid.prototype.keyevent = function (keycode, metastate, cb) {
Expand Down

0 comments on commit 4d7d053

Please sign in to comment.