Repository: wix/Detox
Pull request #2146 (2020-06-23 15:01:18)

Android driver refactor 0.1
- [x] This is a small change 
- [ ] This change has been discussed in issue #<?> and the solution has been agreed upon with maintainers.

---

**Description:**
Following work on #1192 -- need to break some of the `AndroidDriver` monolith into sub-units. This is prep-step 0.1: move existing stuff around into dedicated subfolders (i.e. a physical refactor).


Patch:
diff --git a/detox/package.json b/detox/package.json
index a5dccc0b2..74c88999a 100644
--- a/detox/package.json
+++ b/detox/package.json
@@ -1,7 +1,7 @@
 {
   "name": "detox",
   "description": "E2E tests and automation for mobile",
-  "version": "16.9.0",
+  "version": "16.9.1",
   "bin": {
     "detox": "local-cli/cli.js"
   },
diff --git a/detox/src/devices/drivers/android/AndroidDriver.js b/detox/src/devices/drivers/android/AndroidDriver.js
index 0697ebf4b..1a053709f 100644
--- a/detox/src/devices/drivers/android/AndroidDriver.js
+++ b/detox/src/devices/drivers/android/AndroidDriver.js
@@ -6,8 +6,8 @@ const logger = require('../../../utils/logger');
 const log = logger.child({ __filename });
 const invoke = require('../../../invoke');
 const InvocationManager = invoke.InvocationManager;
-const ADB = require('./tools/ADB');
-const AAPT = require('./tools/AAPT');
+const ADB = require('./exec/ADB');
+const AAPT = require('./exec/AAPT');
 const APKPath = require('./tools/APKPath');
 const TempFileXfer = require('./tools/TempFileXfer');
 const AppUninstallHelper = require('./tools/AppUninstallHelper');
diff --git a/detox/src/devices/drivers/android/EmulatorDriver.js b/detox/src/devices/drivers/android/EmulatorDriver.js
index d261231da..bae2b80fa 100644
--- a/detox/src/devices/drivers/android/EmulatorDriver.js
+++ b/detox/src/devices/drivers/android/EmulatorDriver.js
@@ -7,7 +7,7 @@ const FreeEmulatorFinder = require('./emulator/FreeEmulatorFinder');
 const AVDValidator = require('./emulator/AVDValidator');
 const EmulatorLauncher = require('./emulator/EmulatorLauncher');
 const EmulatorVersionResolver = require('./emulator/EmulatorVersionResolver');
-const { EmulatorExec } = require('./tools/EmulatorExec');
+const { EmulatorExec } = require('./exec/EmulatorExec');
 const EmulatorTelnet = require('./tools/EmulatorTelnet');
 const AppInstallHelper = require('./tools/AppInstallHelper');
 const DetoxRuntimeError = require('../../../errors/DetoxRuntimeError');
diff --git a/detox/src/devices/drivers/android/emulator/AVDsResolver.js b/detox/src/devices/drivers/android/emulator/AVDsResolver.js
index 910ad9c08..df735f866 100644
--- a/detox/src/devices/drivers/android/emulator/AVDsResolver.js
+++ b/detox/src/devices/drivers/android/emulator/AVDsResolver.js
@@ -1,4 +1,4 @@
-const { ListAVDsCommand } = require('../tools/EmulatorExec');
+const { ListAVDsCommand } = require('../exec/EmulatorExec');
 
 class AVDsResolver {
   constructor(emulatorExec) {
diff --git a/detox/src/devices/drivers/android/emulator/EmulatorLauncher.js b/detox/src/devices/drivers/android/emulator/EmulatorLauncher.js
index c3c8ba310..8147cd4c9 100644
--- a/detox/src/devices/drivers/android/emulator/EmulatorLauncher.js
+++ b/detox/src/devices/drivers/android/emulator/EmulatorLauncher.js
@@ -1,7 +1,7 @@
 const _ = require('lodash');
 const fs = require('fs');
 const Tail = require('tail').Tail;
-const { LaunchCommand } = require('../tools/EmulatorExec');
+const { LaunchCommand } = require('../exec/EmulatorExec');
 const unitLogger = require('../../../../utils/logger').child({ __filename });
 const retry = require('../../../../utils/retry');
 
diff --git a/detox/src/devices/drivers/android/emulator/EmulatorVersionResolver.js b/detox/src/devices/drivers/android/emulator/EmulatorVersionResolver.js
index 8d1c87eb6..d12301838 100644
--- a/detox/src/devices/drivers/android/emulator/EmulatorVersionResolver.js
+++ b/detox/src/devices/drivers/android/emulator/EmulatorVersionResolver.js
@@ -1,4 +1,4 @@
-const {QueryVersionCommand} = require('../tools/EmulatorExec');
+const {QueryVersionCommand} = require('../exec/EmulatorExec');
 const log = require('../../../../utils/logger').child({ __filename });
 
 const EMU_BIN_VERSION_DETECT_EV = 'EMU_BIN_VERSION_DETECT';
diff --git a/detox/src/devices/drivers/android/tools/AAPT.js b/detox/src/devices/drivers/android/exec/AAPT.js
similarity index 100%
rename from detox/src/devices/drivers/android/tools/AAPT.js
rename to detox/src/devices/drivers/android/exec/AAPT.js
diff --git a/detox/src/devices/drivers/android/tools/AAPT.test.js b/detox/src/devices/drivers/android/exec/AAPT.test.js
similarity index 100%
rename from detox/src/devices/drivers/android/tools/AAPT.test.js
rename to detox/src/devices/drivers/android/exec/AAPT.test.js
diff --git a/detox/src/devices/drivers/android/tools/ADB.js b/detox/src/devices/drivers/android/exec/ADB.js
similarity index 99%
rename from detox/src/devices/drivers/android/tools/ADB.js
rename to detox/src/devices/drivers/android/exec/ADB.js
index 7a7536292..ca98165ef 100644
--- a/detox/src/devices/drivers/android/tools/ADB.js
+++ b/detox/src/devices/drivers/android/exec/ADB.js
@@ -2,7 +2,7 @@ const _ = require('lodash');
 const {execWithRetriesAndLogs, spawnAndLog} = require('../../../../utils/exec');
 const {escape} = require('../../../../utils/pipeCommands');
 const DetoxRuntimeError = require('../../../../errors/DetoxRuntimeError');
-const EmulatorTelnet = require('./EmulatorTelnet');
+const EmulatorTelnet = require('../tools/EmulatorTelnet');
 const {getAdbPath} = require('../../../../utils/environment');
 const {encodeBase64} = require('../../../../utils/encoding');
 
diff --git a/examples/demo-native-android/package.json b/examples/demo-native-android/package.json
index 52da7878d..23487f9f5 100644
--- a/examples/demo-native-android/package.json
+++ b/examples/demo-native-android/package.json
@@ -1,6 +1,6 @@
 {
   "name": "detox-demo-native-android",
-  "version": "16.9.0",
+  "version": "16.9.1",
   "private": true,
   "scripts": {
     "packager": "react-native start",
@@ -8,7 +8,7 @@
     "e2e": "mocha e2e --opts ./e2e/mocha.opts"
   },
   "devDependencies": {
-    "detox": "^16.9.0",
+    "detox": "^16.9.1",
     "mocha": "^6.1.3"
   },
   "detox": {}
diff --git a/examples/demo-native-ios/package.json b/examples/demo-native-ios/package.json
index 374d69161..221e99320 100644
--- a/examples/demo-native-ios/package.json
+++ b/examples/demo-native-ios/package.json
@@ -1,9 +1,9 @@
 {
   "name": "detox-demo-native-ios",
-  "version": "16.9.0",
+  "version": "16.9.1",
   "private": true,
   "devDependencies": {
-    "detox": "^16.9.0",
+    "detox": "^16.9.1",
     "mocha": "^6.1.3"
   },
   "detox": {
diff --git a/examples/demo-plugin/package.json b/examples/demo-plugin/package.json
index 6745b6ae0..a094b5633 100644
--- a/examples/demo-plugin/package.json
+++ b/examples/demo-plugin/package.json
@@ -1,12 +1,12 @@
 {
   "name": "demo-plugin",
-  "version": "16.9.0",
+  "version": "16.9.1",
   "private": true,
   "scripts": {
     "test:plugin": "detox test --configuration plugin -l verbose"
   },
   "devDependencies": {
-    "detox": "^16.9.0",
+    "detox": "^16.9.1",
     "jest": "26.x.x"
   },
   "detox": {
diff --git a/examples/demo-react-native-detox-instruments/package.json b/examples/demo-react-native-detox-instruments/package.json
index 64bc442e6..95120ced1 100644
--- a/examples/demo-react-native-detox-instruments/package.json
+++ b/examples/demo-react-native-detox-instruments/package.json
@@ -1,10 +1,10 @@
 {
   "name": "demo-react-native-detox-instruments",
-  "version": "16.9.0",
+  "version": "16.9.1",
   "private": true,
   "scripts": {},
   "devDependencies": {
-    "detox": "^16.9.0",
+    "detox": "^16.9.1",
     "mocha": "6.x.x"
   },
   "detox": {
diff --git a/examples/demo-react-native-jest/package.json b/examples/demo-react-native-jest/package.json
index c110ff23c..c9e270bb3 100644
--- a/examples/demo-react-native-jest/package.json
+++ b/examples/demo-react-native-jest/package.json
@@ -1,6 +1,6 @@
 {
   "name": "demo-react-native-jest",
-  "version": "16.9.0",
+  "version": "16.9.1",
   "private": true,
   "scripts": {
     "test:ios-release": "detox test --configuration ios.sim.release -l verbose",
@@ -9,7 +9,7 @@
     "test:android-release-ci": "detox test --configuration android.emu.release -l verbose --workers 2 --headless --record-logs all --take-screenshots all"
   },
   "devDependencies": {
-    "detox": "^16.9.0",
+    "detox": "^16.9.1",
     "jest": "26.x.x",
     "jest-circus": "26.x.x",
     "sanitize-filename": "^1.6.1"
diff --git a/examples/demo-react-native/package.json b/examples/demo-react-native/package.json
index dd53ecb4d..55543df3d 100644
--- a/examples/demo-react-native/package.json
+++ b/examples/demo-react-native/package.json
@@ -1,6 +1,6 @@
 {
   "name": "example",
-  "version": "16.9.0",
+  "version": "16.9.1",
   "private": true,
   "scripts": {
     "start": "react-native start",
@@ -21,7 +21,7 @@
     "react-native": "0.62.x"
   },
   "devDependencies": {
-    "detox": "^16.9.0",
+    "detox": "^16.9.1",
     "mocha": "^6.1.3"
   }
 }
diff --git a/lerna.json b/lerna.json
index 6cb2f5df7..505eaaaa6 100644
--- a/lerna.json
+++ b/lerna.json
@@ -13,7 +13,7 @@
     "generation",
     "."
   ],
-  "version": "16.9.0",
+  "version": "16.9.1",
   "npmClient": "npm",
   "command": {
     "publish": {
diff --git a/package.json b/package.json
index 515beabbe..906f7e964 100644
--- a/package.json
+++ b/package.json
@@ -18,5 +18,5 @@
     "semver": "5.x.x",
     "shell-utils": "1.x.x"
   },
-  "version": "16.9.0"
+  "version": "16.9.1"
 }


Test patch:
diff --git a/detox/src/devices/drivers/android/AndroidDriver.test.js b/detox/src/devices/drivers/android/AndroidDriver.test.js
index 5eb7c2892..01c4d2ace 100644
--- a/detox/src/devices/drivers/android/AndroidDriver.test.js
+++ b/detox/src/devices/drivers/android/AndroidDriver.test.js
@@ -100,7 +100,7 @@ describe('Android driver', () => {
 
   let adb;
   beforeEach(() => {
-    const ADB = jest.genMockFromModule('./tools/ADB');
+    const ADB = jest.genMockFromModule('./exec/ADB');
     adb = new ADB();
     adb.adbBin = 'ADB binary mock';
     adb.spawnInstrumentation.mockReturnValue({
@@ -112,7 +112,7 @@ describe('Android driver', () => {
         }
       }
     });
-    jest.mock('./tools/ADB', () => MockADBClass);
+    jest.mock('./exec/ADB', () => MockADBClass);
   });
 
   let fileXfer;
diff --git a/detox/src/devices/drivers/android/emulator/AVDsResolver.test.js b/detox/src/devices/drivers/android/emulator/AVDsResolver.test.js
index 45747d672..73e1b53e7 100644
--- a/detox/src/devices/drivers/android/emulator/AVDsResolver.test.js
+++ b/detox/src/devices/drivers/android/emulator/AVDsResolver.test.js
@@ -3,8 +3,8 @@ describe('AVDs resolver', () => {
   let emulatorExec;
   let uut;
   beforeEach(() => {
-    MockListAVDsCommand = jest.genMockFromModule('../tools/EmulatorExec').ListAVDsCommand;
-    jest.mock('../tools/EmulatorExec', () => ({
+    MockListAVDsCommand = jest.genMockFromModule('../exec/EmulatorExec').ListAVDsCommand;
+    jest.mock('../exec/EmulatorExec', () => ({
       ListAVDsCommand: MockListAVDsCommand,
     }));
 
diff --git a/detox/src/devices/drivers/android/emulator/EmulatorVersionResolver.test.js b/detox/src/devices/drivers/android/emulator/EmulatorVersionResolver.test.js
index d95eb0d87..4f94b4769 100644
--- a/detox/src/devices/drivers/android/emulator/EmulatorVersionResolver.test.js
+++ b/detox/src/devices/drivers/android/emulator/EmulatorVersionResolver.test.js
@@ -22,8 +22,8 @@ describe('Emulator binary version', () => {
   let log;
   let uut;
   beforeEach(() => {
-    MockQueryVersionCommand = jest.genMockFromModule('../tools/EmulatorExec').QueryVersionCommand;
-    jest.mock('../tools/EmulatorExec', () => ({
+    MockQueryVersionCommand = jest.genMockFromModule('../exec/EmulatorExec').QueryVersionCommand;
+    jest.mock('../exec/EmulatorExec', () => ({
       QueryVersionCommand: MockQueryVersionCommand,
     }));
 
diff --git a/detox/src/devices/drivers/android/tools/ADB.test.js b/detox/src/devices/drivers/android/exec/ADB.test.js
similarity index 99%
rename from detox/src/devices/drivers/android/tools/ADB.test.js
rename to detox/src/devices/drivers/android/exec/ADB.test.js
index 5cdd821a3..c8fc5fa6c 100644
--- a/detox/src/devices/drivers/android/tools/ADB.test.js
+++ b/detox/src/devices/drivers/android/exec/ADB.test.js
@@ -28,7 +28,7 @@ describe('ADB', () => {
         this.avdName = mockEmulatorTelnet.avdName;
       }
     }
-    jest.mock('./EmulatorTelnet', () => MockEmulatorTelnet);
+    jest.mock('../tools/EmulatorTelnet', () => MockEmulatorTelnet);
 
     jest.mock('../../../../utils/exec', () => ({
       execWithRetriesAndLogs: jest.fn().mockReturnValue({ stdout: '' }),
diff --git a/detox/src/devices/drivers/android/tools/BinaryExec.js b/detox/src/devices/drivers/android/exec/BinaryExec.js
similarity index 100%
rename from detox/src/devices/drivers/android/tools/BinaryExec.js
rename to detox/src/devices/drivers/android/exec/BinaryExec.js
diff --git a/detox/src/devices/drivers/android/tools/BinaryExec.test.js b/detox/src/devices/drivers/android/exec/BinaryExec.test.js
similarity index 100%
rename from detox/src/devices/drivers/android/tools/BinaryExec.test.js
rename to detox/src/devices/drivers/android/exec/BinaryExec.test.js
diff --git a/detox/src/devices/drivers/android/tools/EmulatorExec.js b/detox/src/devices/drivers/android/exec/EmulatorExec.js
similarity index 100%
rename from detox/src/devices/drivers/android/tools/EmulatorExec.js
rename to detox/src/devices/drivers/android/exec/EmulatorExec.js
diff --git a/detox/src/devices/drivers/android/tools/AppInstallHelper.test.js b/detox/src/devices/drivers/android/tools/AppInstallHelper.test.js
index 32993b7db..9f70c43e3 100644
--- a/detox/src/devices/drivers/android/tools/AppInstallHelper.test.js
+++ b/detox/src/devices/drivers/android/tools/AppInstallHelper.test.js
@@ -6,7 +6,7 @@ describe('Android app installation helper', () => {
   let adb;
 
   beforeEach(() => {
-    const ADBMock = jest.genMockFromModule('./ADB');
+    const ADBMock = jest.genMockFromModule('../exec/ADB');
     adb = new ADBMock();
   });
 
diff --git a/detox/src/devices/drivers/android/tools/AppUninstallHelper.test.js b/detox/src/devices/drivers/android/tools/AppUninstallHelper.test.js
index 3ff8be1ac..274e46c8f 100644
--- a/detox/src/devices/drivers/android/tools/AppUninstallHelper.test.js
+++ b/detox/src/devices/drivers/android/tools/AppUninstallHelper.test.js
@@ -12,11 +12,11 @@ describe('Android app uninstall helper', () => {
   }
 
   beforeEach(() => {
-    const ADBMock = jest.genMockFromModule('./ADB');
+    const ADBMock = jest.genMockFromModule('../exec/ADB');
     adb = new ADBMock();
     adb.isPackageInstalled.mockResolvedValue(true);
 
-    jest.mock('./ADB', () => MockAdbClass);
+    jest.mock('../exec/ADB', () => MockAdbClass);
   });
 
   let uut;
diff --git a/detox/src/devices/drivers/android/tools/FileXfer.test.js b/detox/src/devices/drivers/android/tools/FileXfer.test.js
index 97fa952de..287dec3ff 100644
--- a/detox/src/devices/drivers/android/tools/FileXfer.test.js
+++ b/detox/src/devices/drivers/android/tools/FileXfer.test.js
@@ -6,7 +6,7 @@ describe('File-transfer util', () => {
   let uut;
 
   beforeEach(() => {
-    const ADBMock = jest.genMockFromModule('./ADB');
+    const ADBMock = jest.genMockFromModule('../exec/ADB');
     adb = new ADBMock();
 
     const FileXfer = require('./FileXfer');
diff --git a/detox/src/devices/drivers/android/tools/TempFileXfer.test.js b/detox/src/devices/drivers/android/tools/TempFileXfer.test.js
index 3ec9097bf..0fa3fd709 100644
--- a/detox/src/devices/drivers/android/tools/TempFileXfer.test.js
+++ b/detox/src/devices/drivers/android/tools/TempFileXfer.test.js
@@ -2,7 +2,7 @@ describe('Temp file transfer', () => {
   let adb;
   let uut;
   beforeEach(() => {
-    const ADB = jest.genMockFromModule('./ADB');
+    const ADB = jest.genMockFromModule('../exec/ADB');
     adb = new ADB();
 
     const TempFileXfer = require('./TempFileXfer');
diff --git a/detox/test/package.json b/detox/test/package.json
index 31c5f45a7..382ba13d6 100644
--- a/detox/test/package.json
+++ b/detox/test/package.json
@@ -1,6 +1,6 @@
 {
   "name": "detox-test",
-  "version": "16.9.0",
+  "version": "16.9.1",
   "private": true,
   "engines": {
     "node": ">=8.3.0"
@@ -34,7 +34,7 @@
   },
   "devDependencies": {
     "@babel/core": "^7.4.5",
-    "detox": "^16.9.0",
+    "detox": "^16.9.1",
     "express": "^4.15.3",
     "jest": "26.x.x",
     "jest-circus": "26.x.x",