Skip to content

Commit

Permalink
Merge pull request appium#3322 from imurchie/isaac-selendroid-reset
Browse files Browse the repository at this point in the history
Fix selendroid full reset
  • Loading branch information
jlipps committed Aug 6, 2014
2 parents 62b6931 + eb6c322 commit 96d9537
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 14 deletions.
33 changes: 19 additions & 14 deletions lib/devices/android/selendroid.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ Selendroid.prototype.checkSelendroidCerts = function (cb) {
}.bind(this));
};

Selendroid.prototype.stop = function (cb) {
Selendroid.prototype.stop = function (ocb) {
var completeShutdown = function (cb) {
if (this.args.unicodeKeyboard && this.resetKeyboard && this.defaultIME) {
logger.debug('Resetting IME to \'' + this.defaultIME + '\'');
Expand All @@ -255,19 +255,24 @@ Selendroid.prototype.stop = function (cb) {
}
}.bind(this);

if (this.args.fullReset) {
logger.debug("Removing app from device");
this.uninstallApp(function (err) {
if (err) {
// simply warn on error here, because we don't want to stop the shutdown
// process
logger.warn(err);
}
completeShutdown(cb);
});
} else {
completeShutdown(cb);
}
completeShutdown(function (err) {
if (err) return ocb(err);

// Remove the app _after_ stopping Selendroid, or Selendroid will fail
if (this.args.fullReset) {
logger.debug("Removing app from device");
this.uninstallApp(function (err) {
if (err) {
// simply warn on error here, because we don't want to stop the shutdown
// process
logger.warn(err);
}
ocb();
});
} else {
ocb();
}
}.bind(this));
};

Selendroid.prototype.keyevent = function (keycode, metastate, cb) {
Expand Down
35 changes: 35 additions & 0 deletions test/functional/selendroid/shutdown-specs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"use strict";

var setup = require("../common/setup-base")
, _ = require('underscore')
, desired = require('./desired');

describe('selendroid -- shutdown', function () {
describe('fullReset false', function () {
var driver;
setup(this, _.defaults({
fullReset: false
}, desired)).then(function (d) { driver = d; });

it('should successfully stop', function (done) {
driver
.quit()
.should.not.be.rejected
.nodeify(done);
});
});

describe('fullReset true', function () {
var driver;
setup(this, _.defaults({
fullReset: true
}, desired)).then(function (d) { driver = d; });

it('should successfully stop', function (done) {
driver
.quit()
.should.not.be.rejected
.nodeify(done);
});
});
});

0 comments on commit 96d9537

Please sign in to comment.