Skip to content

Commit

Permalink
Add clearDeviceLogsOnStart capability
Browse files Browse the repository at this point in the history
  • Loading branch information
imurchie committed Dec 8, 2017
1 parent dd7c22c commit f95634e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
13 changes: 10 additions & 3 deletions lib/android-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ helpers.getDeviceInfoFromCaps = async function (opts = {}) {
let adb = await ADB.createADB({
javaVersion: opts.javaVersion,
adbPort: opts.adbPort,
remoteAdbHost: opts.remoteAdbHost
remoteAdbHost: opts.remoteAdbHost,
clearDeviceLogsOnStart: opts.clearDeviceLogsOnStart,
});
let udid = opts.udid;
let emPort = null;
Expand Down Expand Up @@ -179,8 +180,14 @@ helpers.getDeviceInfoFromCaps = async function (opts = {}) {
};

// returns a new adb instance with deviceId set
helpers.createADB = async function (javaVersion, udid, emPort, adbPort, suppressKillServer, remoteAdbHost) {
let adb = await ADB.createADB({javaVersion, adbPort, suppressKillServer, remoteAdbHost});
helpers.createADB = async function (javaVersion, udid, emPort, adbPort, suppressKillServer, remoteAdbHost, clearDeviceLogsOnStart) {
let adb = await ADB.createADB({
javaVersion,
adbPort,
suppressKillServer,
remoteAdbHost,
clearDeviceLogsOnStart,
});

adb.setDeviceId(udid);
if (emPort) {
Expand Down
3 changes: 3 additions & 0 deletions lib/desired-caps.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ let commonCapConstraints = {
skipUnlock: {
isBoolean: true
},
clearDeviceLogsOnStart: {
isBoolean: true
},
};

let uiautomatorCapConstraints = {
Expand Down
3 changes: 2 additions & 1 deletion lib/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ class AndroidDriver extends BaseDriver {
this.opts.emPort,
this.opts.adbPort,
this.opts.suppressKillServer,
this.opts.remoteAdbHost);
this.opts.remoteAdbHost,
this.opts.clearDeviceLogsOnStart);

if (this.helpers.isPackageOrBundle(this.opts.app)) {
// user provided package instead of app for 'app' capability, massage options
Expand Down
11 changes: 8 additions & 3 deletions test/unit/android-helper-specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,14 @@ describe('Android Helpers', () => {
ADB.createADB.restore();
});
it('should create adb and set device id and emulator port', async () => {
await helpers.createADB("1.7", "111222", "111", "222", true, "remote_host");
ADB.createADB.calledWithExactly({javaVersion: "1.7", adbPort: "222",
suppressKillServer: true, remoteAdbHost: "remote_host"}).should.be.true;
await helpers.createADB("1.7", "111222", "111", "222", true, "remote_host", true);
ADB.createADB.calledWithExactly({
javaVersion: "1.7",
adbPort: "222",
suppressKillServer: true,
remoteAdbHost: "remote_host",
clearDeviceLogsOnStart: true,
}).should.be.true;
curDeviceId.should.equal("111222");
emulatorPort.should.equal("111");
});
Expand Down

0 comments on commit f95634e

Please sign in to comment.