Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,17 @@ const InstrumentsArtifactRecording = require('../InstrumentsArtifactRecording');
class AndroidInstrumentsRecording extends InstrumentsArtifactRecording {
constructor({ adb, pluginContext, client, deviceId, userConfig, temporaryRecordingPath }) {
super({ pluginContext, client, userConfig, temporaryRecordingPath });
this.adb = adb;
this.deviceId = deviceId;
this.adb = adb.bind({ deviceId });
}

async doSave(artifactPath) {
await super.doSave(artifactPath);
await this.adb.pull(this.deviceId, this.temporaryRecordingPath, artifactPath);
await this.adb.rm(this.deviceId, this.temporaryRecordingPath, true);
await this.adb.pull(this.temporaryRecordingPath, artifactPath);
await this.adb.rm(this.temporaryRecordingPath, true);
}

async doDiscard() {
await this.adb.rm(this.deviceId, this.temporaryRecordingPath, true);
await this.adb.rm(this.temporaryRecordingPath, true);
}
}

Expand Down
2 changes: 1 addition & 1 deletion detox/src/artifacts/log/android/ADBLogcatPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ADBLogcatPlugin extends LogArtifactPlugin {

async onBeforeLaunchApp(event) {
await super.onBeforeLaunchApp(event);
this._lastTimestamp = await this._adb.now(event.deviceId);
this._lastTimestamp = await this._adb.bind({ deviceId: event.deviceId }).now();
}

async onLaunchApp(event) {
Expand Down
14 changes: 7 additions & 7 deletions detox/src/artifacts/log/android/ADBLogcatRecording.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class ADBLogcatRecording extends Artifact {
pathToLogOnDevice,
}) {
super();
this.adb = adb;
this.adb = adb.bind({ deviceId });

this.deviceId = deviceId;
this.pid = pid;
Expand All @@ -28,7 +28,7 @@ class ADBLogcatRecording extends Artifact {
async doStart() {
const pid = this.pid.get();

this.processPromise = this.adb.logcat(this.deviceId, {
this.processPromise = this.adb.logcat({
file: this.pathToLogOnDevice,
time: this.since.get(),
pid: pid > 0 ? pid : 0,
Expand All @@ -42,7 +42,7 @@ class ADBLogcatRecording extends Artifact {
async doStop() {
try {
await this._waitUntilLogFileIsCreated;
this.since.set(await this.adb.now(this.deviceId));
this.since.set(await this.adb.now());
} finally {
if (this.processPromise) {
await interruptProcess(this.processPromise);
Expand All @@ -52,16 +52,16 @@ class ADBLogcatRecording extends Artifact {
}

async doSave(artifactPath) {
await this.adb.pull(this.deviceId, this.pathToLogOnDevice, artifactPath);
await this.adb.rm(this.deviceId, this.pathToLogOnDevice);
await this.adb.pull(this.pathToLogOnDevice, artifactPath);
await this.adb.rm(this.pathToLogOnDevice);
}

async doDiscard() {
await this.adb.rm(this.deviceId, this.pathToLogOnDevice);
await this.adb.rm(this.pathToLogOnDevice);
}

async _assertLogIsCreated() {
const size = await this.adb.getFileSize(this.deviceId, this.pathToLogOnDevice);
const size = await this.adb.getFileSize(this.pathToLogOnDevice);

if (size < 0) {
throw new DetoxRuntimeError({
Expand Down
12 changes: 6 additions & 6 deletions detox/src/artifacts/screenshot/ADBScreencapPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,27 @@ class ADBScreencapPlugin extends ScreenshotArtifactPlugin {
}

createTestArtifact() {
const adb = this._adb;
const deviceId = this.context.deviceId;
const adb = this._adb.bind({ deviceId });
const pathToScreenshotOnDevice = this._devicePathBuilder.buildTemporaryArtifactPath('.png');

return new Artifact({
name: 'ADBScreencapRecording',

async start() {
await adb.screencap(deviceId, pathToScreenshotOnDevice);
await adb.screencap(pathToScreenshotOnDevice);
},

async save(artifactPath) {
await adb.pull(deviceId, pathToScreenshotOnDevice, artifactPath);
await adb.rm(deviceId, pathToScreenshotOnDevice);
await adb.pull(pathToScreenshotOnDevice, artifactPath);
await adb.rm(pathToScreenshotOnDevice);
},

async discard() {
await adb.rm(deviceId, pathToScreenshotOnDevice);
await adb.rm(pathToScreenshotOnDevice);
},
});
}
}

module.exports = ADBScreencapPlugin;
module.exports = ADBScreencapPlugin;
14 changes: 7 additions & 7 deletions detox/src/artifacts/video/ADBScreenrecorderArtifact.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class ADBVideoRecording extends Artifact {
constructor(config) {
super(config);

this.adb = config.adb;
this.adb = config.adb.bind({ deviceId: config.deviceId });
this.deviceId = config.deviceId;
this.pathToVideoOnDevice = config.pathToVideoOnDevice;
this.screenRecordOptions = config.screenRecordOptions || {};
Expand All @@ -18,7 +18,7 @@ class ADBVideoRecording extends Artifact {
}

async doStart() {
this.processPromise = this.adb.screenrecord(this.deviceId, {
this.processPromise = this.adb.screenrecord({
...this.screenRecordOptions,
path: this.pathToVideoOnDevice
});
Expand All @@ -40,17 +40,17 @@ class ADBVideoRecording extends Artifact {

async doSave(artifactPath) {
await this._waitWhileVideoIsBusy;
await this.adb.pull(this.deviceId, this.pathToVideoOnDevice, artifactPath);
await this.adb.rm(this.deviceId, this.pathToVideoOnDevice);
await this.adb.pull(this.pathToVideoOnDevice, artifactPath);
await this.adb.rm(this.pathToVideoOnDevice);
}

async doDiscard() {
await this._waitWhileVideoIsBusy;
await this.adb.rm(this.deviceId, this.pathToVideoOnDevice);
await this.adb.rm(this.pathToVideoOnDevice);
}

async _assertVideoIsBeingRecorded() {
const size = await this.adb.getFileSize(this.deviceId, this.pathToVideoOnDevice);
const size = await this.adb.getFileSize(this.pathToVideoOnDevice);

if (size < 1) {
throw new DetoxRuntimeError({
Expand All @@ -60,7 +60,7 @@ class ADBVideoRecording extends Artifact {
}

async _assertVideoIsNotOpenedByProcesses() {
const size = await this.adb.getFileSize(this.deviceId, this.pathToVideoOnDevice);
const size = await this.adb.getFileSize(this.pathToVideoOnDevice);

if (size < 1) {
throw new DetoxRuntimeError({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ class GenyInstanceLifecycleService {
};

const result = await retry(options, doAdbConnect);
return new Instance(result.instance);
const instance = new Instance(result.instance);
this._adb = this._adb.bind({ deviceId: instance.adbName });
return instance;
}

async deleteInstance(instanceUUID) {
Expand Down
Loading