From 84ed099050d1b9c082dd93d1901d4654d7e3c2b9 Mon Sep 17 00:00:00 2001 From: Ryan Thomas Date: Tue, 26 Feb 2019 13:10:03 -0600 Subject: [PATCH 1/2] #1176 - Updated android/Emulator.js to stop adding the -gpu host parameters when launching an emulator (non headless mode) --- detox/src/devices/android/Emulator.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/detox/src/devices/android/Emulator.js b/detox/src/devices/android/Emulator.js index 8c8856eb6f..350776cf12 100644 --- a/detox/src/devices/android/Emulator.js +++ b/detox/src/devices/android/Emulator.js @@ -29,12 +29,16 @@ class Emulator { async boot(emulatorName) { const emulatorArgs = _.compact([ '-verbose', - '-gpu', this.gpuMethod(), '-no-audio', argparse.getArgValue('headless') ? '-no-window' : '', `@${emulatorName}` ]); + const gpuMethod = this.gpuMethod(); + if(gpuMethod) { + emulatorArgs.push('-gpu', gpuMethod); + } + let childProcessOutput; const tempLog = `./${emulatorName}.log`; const stdout = fs.openSync(tempLog, 'a'); @@ -93,9 +97,9 @@ class Emulator { default: return 'auto'; } - } else { - return 'host'; } + + return undefined; } } From 3899ea2b84a93c83071d113bd411d293dca1a8b4 Mon Sep 17 00:00:00 2001 From: Ryan Thomas Date: Tue, 26 Feb 2019 15:39:50 -0600 Subject: [PATCH 2/2] #1176 - Added support for a --gpu cli parameter to explicit specify the android emulator gpu mode --- detox/local-cli/detox-test.js | 6 +++++- detox/src/devices/android/Emulator.js | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/detox/local-cli/detox-test.js b/detox/local-cli/detox-test.js index eaaeac3a9d..cc7c1ff81e 100644 --- a/detox/local-cli/detox-test.js +++ b/detox/local-cli/detox-test.js @@ -44,6 +44,8 @@ program 'Specify test file to run') .option('-H, --headless', '[Android Only] Launch Emulator in headless mode. Useful when running on CI.') + .option('--gpu [gpu mode]', + '[Android Only] Launch Emulator with the specific -gpu [gpu mode] parameter.') .option('-w, --workers ', '[iOS Only] Specifies number of workers the test runner should spawn, requires a test runner with parallel execution support (Detox CLI currently supports Jest)', 1) .option('-n, --device-name [name]', @@ -127,13 +129,14 @@ function runMocha() { const screenshots = program.takeScreenshots ? `--take-screenshots ${program.takeScreenshots}` : ''; const videos = program.recordVideos ? `--record-videos ${program.recordVideos}` : ''; const headless = program.headless ? `--headless` : ''; + const gpu = program.gpu ? `--gpu ${program.gpu}` : ''; const color = program.color ? '' : '--no-colors'; const deviceName = program.deviceName ? `--device-name "${program.deviceName}"` : ''; const debugSynchronization = program.debugSynchronization ? `--debug-synchronization ${program.debugSynchronization}` : ''; const binPath = path.join('node_modules', '.bin', 'mocha'); const command = `${binPath} ${testFolder} ${configFile} ${configuration} ${loglevel} ${color} ` + - `${cleanup} ${reuse} ${debugSynchronization} ${platformString} ${headless} ` + + `${cleanup} ${reuse} ${debugSynchronization} ${platformString} ${headless} ${gpu} ` + `${logs} ${screenshots} ${videos} ${artifactsLocation} ${deviceName} ${collectExtraArgs()}`; console.log(command); @@ -154,6 +157,7 @@ function runJest() { cleanup: program.cleanup, reuse: program.reuse, debugSynchronization: program.debugSynchronization, + gpu: program.gpu, headless: program.headless, artifactsLocation: program.artifactsLocation, recordLogs: program.recordLogs, diff --git a/detox/src/devices/android/Emulator.js b/detox/src/devices/android/Emulator.js index 350776cf12..1699dc8e48 100644 --- a/detox/src/devices/android/Emulator.js +++ b/detox/src/devices/android/Emulator.js @@ -86,6 +86,11 @@ class Emulator { } gpuMethod() { + const gpuArgument = argparse.getArgValue('gpu'); + if(gpuArgument) { + return gpuArgument; + } + if (argparse.getArgValue('headless')) { switch (os.platform()) { case 'darwin':