Skip to content

Commit

Permalink
Merge pull request appium#834 from bootstraponline/832
Browse files Browse the repository at this point in the history
  • Loading branch information
jlipps committed Jul 1, 2013
2 parents 5f797f9 + 8f42d70 commit 0443dde
Showing 1 changed file with 16 additions and 20 deletions.
36 changes: 16 additions & 20 deletions android/adb.js
Original file line number Diff line number Diff line change
Expand Up @@ -671,8 +671,13 @@ ADB.prototype.startSelendroid = function(serverPath, onReady) {
};

ADB.prototype.pushSelendroid = function(cb) {
var act = this.appActivity,
activityString = act[0] === '.' ? act : '.' + act;
if (act.indexOf(this.appPackage) === 0) {
activityString = act.substring(this.appPackage.length);
}
var cmd = this.adbCmd + " shell am instrument -e main_activity '" +
this.appPackage + "." + this.appActivity + "' " + this.appPackage +
this.appPackage + activityString + "' " + this.appPackage +
".selendroid/io.selendroid.ServerInstrumentation";
cmd = cmd.replace(/\.+/g,'.'); // Fix pkg..activity error
logger.info("Starting instrumentation process for selendroid with cmd: " +
Expand Down Expand Up @@ -1172,23 +1177,10 @@ ADB.prototype.startApp = function(cb) {
logger.info("Starting app");
this.requireDeviceId();
this.requireApp();
var activityString = this.appActivity;
var hasNoPrefix = true;
var rootPrefixes = ['com', 'net', 'org', 'io'];
_.each(rootPrefixes, function(prefix) {
if (activityString.indexOf(prefix + ".") === 0) {
hasNoPrefix = false;
}
});

// Let's not break regular activities.
// https://github.com/appium/appium/issues/782
if (activityString[0] === ".") {
hasNoPrefix = false;
}

if (hasNoPrefix) {
activityString = "." + activityString;
var act = this.appActivity,
activityString = act[0] === '.' ? act : '.' + act;
if (act.indexOf(this.appPackage) === 0) {
activityString = act;
}
var cmd = this.adbCmd + " shell am start -n " + this.appPackage + "/" +
activityString;
Expand Down Expand Up @@ -1251,7 +1243,9 @@ ADB.prototype.waitForNotActivity = function(cb) {
, intMs = 750
, endAt = Date.now() + waitMs
, targetActivity = this.appWaitActivity || this.appActivity;

if (targetActivity.indexOf(this.appPackage) === 0) {
targetActivity = targetActivity.substring(this.appPackage.length);
}
var getFocusedApp = _.bind(function() {
this.getFocusedPackageAndActivity(_.bind(function(err, foundPackage,
foundActivity) {
Expand Down Expand Up @@ -1286,7 +1280,9 @@ ADB.prototype.waitForActivity = function(cb) {
, intMs = 750
, endAt = Date.now() + waitMs
, targetActivity = this.appWaitActivity || this.appActivity;

if (targetActivity.indexOf(this.appPackage) === 0) {
targetActivity = targetActivity.substring(this.appPackage.length);
}
var getFocusedApp = _.bind(function() {
this.getFocusedPackageAndActivity(_.bind(function(err, foundPackage,
foundActivity) {
Expand Down

0 comments on commit 0443dde

Please sign in to comment.