Skip to content

Commit

Permalink
Fix ADB fail to set path in chromedriver
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Millin committed Feb 24, 2015
1 parent a65832c commit 2d3cd76
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 14 deletions.
11 changes: 7 additions & 4 deletions lib/devices/android/android-common.js
Original file line number Diff line number Diff line change
Expand Up @@ -1033,7 +1033,7 @@ androidCommon.getJavaVersion = function (cb) {
} else if (stderr) {
var firstLine = stderr.split("\n")[0];
if (new RegExp("java version").test(firstLine)) {
javaVersion = firstLine.split(" ")[2].replace(/"/g, '');
javaVersion = firstLine.split(" ")[2].replace(/"/g, '');
}
}
if (javaVersion === null) {
Expand All @@ -1056,10 +1056,13 @@ androidCommon.initJavaVersion = function (cb) {

androidCommon.initAdb = function (cb) {
if (this.adb === null) {
this.adb = new ADB(this.args);
this.adb.checkAdbPresent(cb);
ADB.createADB(this.args, function (e, adb) {
if (e) return cb(e);
this.adb = adb;
cb();
}.bind(this));
} else {
return cb();
cb();
}
};

Expand Down
17 changes: 10 additions & 7 deletions lib/devices/android/chrome.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ var Android = require('./android.js')
, deviceCommon = require('../common.js')
, jwpSuccess = deviceCommon.jwpSuccess
, async = require('async')
, ADB = require('./adb.js')
, UiAutomator = require('./uiautomator.js')
, Chromedriver = require('./chromedriver.js');

var NATIVE_WIN = "NATIVE_APP";
Expand Down Expand Up @@ -74,19 +72,24 @@ ChromeAndroid.prototype.configure = function (args, caps, cb) {
cb();
};

ChromeAndroid.prototype.startAutomation = function (cb) {
// this wrapper is required because uiautomator is not instantiated
// at the beginning of the async#series call
this.uiautomator.start(cb);
};

ChromeAndroid.prototype.start = function (cb, onDie) {
this.adb = new ADB(this.args);
this.uiautomator = new UiAutomator(this.adb, this.args);
this.uiautomator.setExitHandler(this.onUiautomatorExit.bind(this));
this.onDie = onDie;

async.series([
this.initAdb.bind(this),
this.initUiautomator.bind(this),
this.prepareDevice.bind(this),
this.prepareChromedriver.bind(this),
this.pushAndUnlock.bind(this),
this.forwardPort.bind(this),
this.pushAppium.bind(this),
this.uiautomator.start.bind(this.uiautomator),
this.startAutomation.bind(this),
this.getDataDir.bind(this),
this.createSession.bind(this)
], function (err, results) {
Expand All @@ -104,7 +107,7 @@ ChromeAndroid.prototype.prepareChromedriver = function (cb) {
, deviceId: this.adb.curDeviceId
, enablePerformanceLogging: this.args.enablePerformanceLogging
};
this.chromedriver = new Chromedriver(chromeArgs,
this.chromedriver = new Chromedriver(chromeArgs, this.adb,
this.onChromedriverExit.bind(this));
this.proxyTo = this.chromedriver.proxyTo.bind(this.chromedriver);
this.proxyHost = this.chromedriver.proxyHost;
Expand Down
4 changes: 2 additions & 2 deletions lib/devices/android/chromedriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var proxyTo = require('../common.js').proxyTo
, fs = require('fs')
, ADB = require('./adb.js');

var Chromedriver = function (args, onDie) {
var Chromedriver = function (args, adb, onDie) {
this.proxyHost = '127.0.0.1';
this.proxyPort = args.port || 9515;
this.deviceId = args.deviceId;
Expand All @@ -24,7 +24,7 @@ var Chromedriver = function (args, onDie) {
this.exitCb = null;
this.shuttingDown = false;
this.executable = args.executable;
this.adb = new ADB(args);
this.adb = adb;
};

Chromedriver.prototype.initChromedriverPath = function (cb) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"mv": "~2.0.0",
"namp": "0.2.25",
"ncp": "~0.5.1",
"node-idevice": "~0.1.4",
"node-idevice": "~0.1.2",
"node-simctl": "~1.0.9",
"node-uuid": "~1.4.1",
"npmlog": "~0.1.1",
Expand Down

0 comments on commit 2d3cd76

Please sign in to comment.