Skip to content

Commit bd44731

Browse files
committed
No emulator.boot()
1 parent 4504853 commit bd44731

File tree

4 files changed

+20
-19
lines changed

4 files changed

+20
-19
lines changed

detox/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
"MissingDetox.js",
9292
"EmulatorTelnet.js",
9393
"EmulatorExec.js",
94-
"Emulator.js",
94+
"EmulatorLauncher.js",
9595
"DeviceDriverBase.js",
9696
"GREYConfiguration.js",
9797
"src/utils/environment.js",

detox/src/devices/drivers/android/EmulatorDriver.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ const ini = require('ini');
55
const AndroidDriver = require('./AndroidDriver');
66
const FreeEmulatorFinder = require('./emulator/FreeEmulatorFinder');
77
const AVDValidator = require('./emulator/AVDValidator');
8+
const EmulatorLauncher = require('./emulator/EmulatorLauncher');
89
const { EmulatorExec } = require('./tools/EmulatorExec');
9-
const Emulator = require('./tools/Emulator');
1010
const EmulatorTelnet = require('./tools/EmulatorTelnet');
1111
const EmulatorVersionResolver = require('./emulator/EmulatorVersionResolver');
1212
const DetoxRuntimeError = require('../../../errors/DetoxRuntimeError');
@@ -27,13 +27,15 @@ class EmulatorDriver extends AndroidDriver {
2727
constructor(config) {
2828
super(config);
2929

30-
this._emulatorExec = new EmulatorExec();
31-
this.emulator = new Emulator(this._emulatorExec);
3230
this.deviceRegistry = new DeviceRegistry({
3331
lockfilePath: environment.getDeviceLockFilePathAndroid(),
3432
});
35-
this._emuVersionResolver = new EmulatorVersionResolver(this._emulatorExec);
36-
this._avdValidator = new AVDValidator(this._emulatorExec);
33+
34+
const emulatorExec = new EmulatorExec();
35+
this._emuVersionResolver = new EmulatorVersionResolver(emulatorExec);
36+
this._emuLauncher = new EmulatorLauncher(emulatorExec);
37+
this._avdValidator = new AVDValidator(emulatorExec);
38+
3739
this.pendingBoots = {};
3840
this._name = 'Unspecified Emulator';
3941
}
@@ -73,7 +75,7 @@ class EmulatorDriver extends AndroidDriver {
7375

7476
if (coldBoot) {
7577
const port = this.pendingBoots[adbName];
76-
await this.emulator.boot(avdName, {port});
78+
await this._emuLauncher.launch(avdName, { port });
7779
delete this.pendingBoots[adbName];
7880
}
7981

@@ -133,8 +135,8 @@ class EmulatorDriver extends AndroidDriver {
133135
}
134136

135137
async _doAllocateDevice(avdName) {
136-
const FreeEmulatorFinder = new FreeEmulatorFinder(this.adb, this.deviceRegistry, avdName);
137-
const freeEmulatorAdbName = await FreeEmulatorFinder.findFreeDevice();
138+
const freeEmulatorFinder = new FreeEmulatorFinder(this.adb, this.deviceRegistry, avdName);
139+
const freeEmulatorAdbName = await freeEmulatorFinder.findFreeDevice();
138140
return freeEmulatorAdbName || this._createDevice();
139141
}
140142

detox/src/devices/drivers/android/tools/Emulator.js renamed to detox/src/devices/drivers/android/emulator/EmulatorLauncher.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
const _ = require('lodash');
22
const fs = require('fs');
33
const Tail = require('tail').Tail;
4+
const { LaunchCommand } = require('../tools/EmulatorExec');
45
const unitLogger = require('../../../../utils/logger').child({ __filename });
56
const retry = require('../../../../utils/retry');
6-
const {
7-
LaunchCommand,
8-
} = require('./EmulatorExec');
97

108
const isUnknownEmulatorError = (err) => (err.message || '').includes('failed with code null');
119

12-
class Emulator {
10+
class EmulatorLauncher {
1311
constructor(emulatorExec) {
14-
this.emulatorExec = emulatorExec;
12+
this._emulatorExec = emulatorExec;
1513
}
1614

17-
async boot(emulatorName, options = {port: undefined}) {
15+
async launch(emulatorName, options = {port: undefined}) {
1816
const launchCommand = new LaunchCommand(emulatorName, options);
1917

2018
return await retry({
@@ -57,8 +55,8 @@ class Emulator {
5755
}
5856

5957
let log = unitLogger.child({ fn: 'boot' });
60-
log.debug({ event: 'SPAWN_CMD' }, this.emulatorExec.toString(), launchCommand.toString());
61-
const childProcessPromise = this.emulatorExec.spawn(launchCommand, stdout, stderr);
58+
log.debug({ event: 'SPAWN_CMD' }, this._emulatorExec.toString(), launchCommand.toString());
59+
const childProcessPromise = this._emulatorExec.spawn(launchCommand, stdout, stderr);
6260
childProcessPromise.childProcess.unref();
6361
log = log.child({ child_pid: childProcessPromise.childProcess.pid });
6462

@@ -80,4 +78,4 @@ class Emulator {
8078
}
8179
}
8280

83-
module.exports = Emulator;
81+
module.exports = EmulatorLauncher;

detox/src/devices/drivers/android/emulator/FreeEmulatorFinder.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const log = require('../../../../utils/logger').child({ __filename });
21
const AdbDevicesHelper = require('../tools/AdbDevicesHelper');
2+
const log = require('../../../../utils/logger').child({ __filename });
33

44
const ACQUIRE_DEVICE_EV = 'ACQUIRE_DEVICE';
55

@@ -32,4 +32,5 @@ class FreeEmulatorFinder {
3232
return false;
3333
}
3434
}
35+
3536
module.exports = FreeEmulatorFinder;

0 commit comments

Comments
 (0)