From 797a3dd228bf96f87390cb4b45e26ee6f088fcd4 Mon Sep 17 00:00:00 2001 From: Luis Naranjo Date: Thu, 19 Jul 2018 18:39:47 -0700 Subject: [PATCH 01/35] pipe language through to xcrun launch --- detox/src/devices/AppleSimUtils.js | 10 ++++++---- detox/src/devices/Device.js | 2 +- detox/src/devices/SimulatorDriver.js | 4 ++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/detox/src/devices/AppleSimUtils.js b/detox/src/devices/AppleSimUtils.js index 1fda4bb137..32a911b291 100644 --- a/detox/src/devices/AppleSimUtils.js +++ b/detox/src/devices/AppleSimUtils.js @@ -114,12 +114,12 @@ class AppleSimUtils { } } - async launch(udid, bundleId, launchArgs) { + async launch(udid, bundleId, launchArgs, language) { const frameworkPath = await environment.getFrameworkPath(); const logsInfo = new LogsInfo(udid); const args = this._joinLaunchArgs(launchArgs); - const result = await this._launchMagically(frameworkPath, logsInfo, udid, bundleId, args); + const result = await this._launchMagically(frameworkPath, logsInfo, udid, bundleId, args, language); return this._parseLaunchId(result); } @@ -243,17 +243,19 @@ class AppleSimUtils { return _.map(launchArgs, (v, k) => `${k} ${v}`).join(' ').trim(); } - async _launchMagically(frameworkPath, logsInfo, udid, bundleId, args) { + async _launchMagically(frameworkPath, logsInfo, udid, bundleId, args, language) { const statusLogs = { trying: `Launching ${bundleId}...`, successful: `${bundleId} launched. The stdout and stderr logs were recreated, you can watch them with:\n` + ` tail -F ${logsInfo.absJoined}` }; + const languageFlag = !!language ? `-AppleLanguages "(${language})" ` : ''; + const launchBin = `/bin/cat /dev/null >${logsInfo.absStdout} 2>${logsInfo.absStderr} && ` + `SIMCTL_CHILD_DYLD_INSERT_LIBRARIES="${frameworkPath}/Detox" ` + `/usr/bin/xcrun simctl launch --stdout=${logsInfo.simStdout} --stderr=${logsInfo.simStderr} ` + - `${udid} ${bundleId} --args ${args}`; + `${udid} ${bundleId} ${languageFlag}--args ${args}`; return await exec.execWithRetriesAndLogs(launchBin, undefined, statusLogs, 1); } diff --git a/detox/src/devices/Device.js b/detox/src/devices/Device.js index 83cfbbaa4a..3366a52171 100644 --- a/detox/src/devices/Device.js +++ b/detox/src/devices/Device.js @@ -111,7 +111,7 @@ class Device { } } - const processId = await this.deviceDriver.launch(this._deviceId, _bundleId, this._prepareLaunchArgs(baseLaunchArgs)); + const processId = await this.deviceDriver.launch(this._deviceId, _bundleId, this._prepareLaunchArgs(baseLaunchArgs), params.language); this._processes[_bundleId] = processId; await this.deviceDriver.waitUntilReady(); diff --git a/detox/src/devices/SimulatorDriver.js b/detox/src/devices/SimulatorDriver.js index d4af028b9f..058ea41fd3 100644 --- a/detox/src/devices/SimulatorDriver.js +++ b/detox/src/devices/SimulatorDriver.js @@ -82,8 +82,8 @@ class SimulatorDriver extends IosDriver { await this._applesimutils.uninstall(deviceId, bundleId); } - async launch(deviceId, bundleId, launchArgs) { - return await this._applesimutils.launch(deviceId, bundleId, launchArgs); + async launch(deviceId, bundleId, launchArgs, language) { + return await this._applesimutils.launch(deviceId, bundleId, launchArgs, language); } async terminate(deviceId, bundleId) { From bdff879126e386e431ec756d7cc07a581b2160a5 Mon Sep 17 00:00:00 2001 From: Luis Naranjo Date: Fri, 20 Jul 2018 10:40:27 -0700 Subject: [PATCH 02/35] Revert "pipe language through to xcrun launch" This reverts commit 797a3dd228bf96f87390cb4b45e26ee6f088fcd4. --- detox/src/devices/AppleSimUtils.js | 10 ++++------ detox/src/devices/Device.js | 2 +- detox/src/devices/SimulatorDriver.js | 4 ++-- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/detox/src/devices/AppleSimUtils.js b/detox/src/devices/AppleSimUtils.js index 32a911b291..1fda4bb137 100644 --- a/detox/src/devices/AppleSimUtils.js +++ b/detox/src/devices/AppleSimUtils.js @@ -114,12 +114,12 @@ class AppleSimUtils { } } - async launch(udid, bundleId, launchArgs, language) { + async launch(udid, bundleId, launchArgs) { const frameworkPath = await environment.getFrameworkPath(); const logsInfo = new LogsInfo(udid); const args = this._joinLaunchArgs(launchArgs); - const result = await this._launchMagically(frameworkPath, logsInfo, udid, bundleId, args, language); + const result = await this._launchMagically(frameworkPath, logsInfo, udid, bundleId, args); return this._parseLaunchId(result); } @@ -243,19 +243,17 @@ class AppleSimUtils { return _.map(launchArgs, (v, k) => `${k} ${v}`).join(' ').trim(); } - async _launchMagically(frameworkPath, logsInfo, udid, bundleId, args, language) { + async _launchMagically(frameworkPath, logsInfo, udid, bundleId, args) { const statusLogs = { trying: `Launching ${bundleId}...`, successful: `${bundleId} launched. The stdout and stderr logs were recreated, you can watch them with:\n` + ` tail -F ${logsInfo.absJoined}` }; - const languageFlag = !!language ? `-AppleLanguages "(${language})" ` : ''; - const launchBin = `/bin/cat /dev/null >${logsInfo.absStdout} 2>${logsInfo.absStderr} && ` + `SIMCTL_CHILD_DYLD_INSERT_LIBRARIES="${frameworkPath}/Detox" ` + `/usr/bin/xcrun simctl launch --stdout=${logsInfo.simStdout} --stderr=${logsInfo.simStderr} ` + - `${udid} ${bundleId} ${languageFlag}--args ${args}`; + `${udid} ${bundleId} --args ${args}`; return await exec.execWithRetriesAndLogs(launchBin, undefined, statusLogs, 1); } diff --git a/detox/src/devices/Device.js b/detox/src/devices/Device.js index 3366a52171..83cfbbaa4a 100644 --- a/detox/src/devices/Device.js +++ b/detox/src/devices/Device.js @@ -111,7 +111,7 @@ class Device { } } - const processId = await this.deviceDriver.launch(this._deviceId, _bundleId, this._prepareLaunchArgs(baseLaunchArgs), params.language); + const processId = await this.deviceDriver.launch(this._deviceId, _bundleId, this._prepareLaunchArgs(baseLaunchArgs)); this._processes[_bundleId] = processId; await this.deviceDriver.waitUntilReady(); diff --git a/detox/src/devices/SimulatorDriver.js b/detox/src/devices/SimulatorDriver.js index 058ea41fd3..d4af028b9f 100644 --- a/detox/src/devices/SimulatorDriver.js +++ b/detox/src/devices/SimulatorDriver.js @@ -82,8 +82,8 @@ class SimulatorDriver extends IosDriver { await this._applesimutils.uninstall(deviceId, bundleId); } - async launch(deviceId, bundleId, launchArgs, language) { - return await this._applesimutils.launch(deviceId, bundleId, launchArgs, language); + async launch(deviceId, bundleId, launchArgs) { + return await this._applesimutils.launch(deviceId, bundleId, launchArgs); } async terminate(deviceId, bundleId) { From d5dae80fe0f01e65937d99d830445bd8125c2f2f Mon Sep 17 00:00:00 2001 From: Luis Naranjo Date: Fri, 20 Jul 2018 10:43:40 -0700 Subject: [PATCH 03/35] pipe the thing through for real this time --- detox/src/devices/AppleSimUtils.js | 12 ++++++++---- detox/src/devices/Device.js | 3 ++- detox/src/devices/SimulatorDriver.js | 4 ++-- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/detox/src/devices/AppleSimUtils.js b/detox/src/devices/AppleSimUtils.js index 1fda4bb137..2438931c8e 100644 --- a/detox/src/devices/AppleSimUtils.js +++ b/detox/src/devices/AppleSimUtils.js @@ -114,12 +114,12 @@ class AppleSimUtils { } } - async launch(udid, bundleId, launchArgs) { + async launch(udid, bundleId, launchArgs, language) { const frameworkPath = await environment.getFrameworkPath(); const logsInfo = new LogsInfo(udid); const args = this._joinLaunchArgs(launchArgs); - const result = await this._launchMagically(frameworkPath, logsInfo, udid, bundleId, args); + const result = await this._launchMagically(frameworkPath, logsInfo, udid, bundleId, args, language); return this._parseLaunchId(result); } @@ -243,17 +243,21 @@ class AppleSimUtils { return _.map(launchArgs, (v, k) => `${k} ${v}`).join(' ').trim(); } - async _launchMagically(frameworkPath, logsInfo, udid, bundleId, args) { + async _launchMagically(frameworkPath, logsInfo, udid, bundleId, args, language) { const statusLogs = { trying: `Launching ${bundleId}...`, successful: `${bundleId} launched. The stdout and stderr logs were recreated, you can watch them with:\n` + ` tail -F ${logsInfo.absJoined}` }; + const languageArgs = !!language ? `-AppleLanguages "(${language})" ` : ''; + const launchBin = `/bin/cat /dev/null >${logsInfo.absStdout} 2>${logsInfo.absStderr} && ` + `SIMCTL_CHILD_DYLD_INSERT_LIBRARIES="${frameworkPath}/Detox" ` + `/usr/bin/xcrun simctl launch --stdout=${logsInfo.simStdout} --stderr=${logsInfo.simStderr} ` + - `${udid} ${bundleId} --args ${args}`; + `${udid} ${bundleId} ${languageArgs}--args ${args}`; + + console.log(`Launching app w/ ${launchBin}`); return await exec.execWithRetriesAndLogs(launchBin, undefined, statusLogs, 1); } diff --git a/detox/src/devices/Device.js b/detox/src/devices/Device.js index 83cfbbaa4a..c3db2e3f66 100644 --- a/detox/src/devices/Device.js +++ b/detox/src/devices/Device.js @@ -66,6 +66,7 @@ class Device { params[launchKey] = payloadFilePath; } + async launchApp(params = {newInstance: false}, bundleId) { const payloadParams = ['url', 'userNotification', 'userActivity']; const hasPayload = this._assertHasSingleParam(payloadParams, params); @@ -111,7 +112,7 @@ class Device { } } - const processId = await this.deviceDriver.launch(this._deviceId, _bundleId, this._prepareLaunchArgs(baseLaunchArgs)); + const processId = await this.deviceDriver.launch(this._deviceId, _bundleId, this._prepareLaunchArgs(baseLaunchArgs), params.language); this._processes[_bundleId] = processId; await this.deviceDriver.waitUntilReady(); diff --git a/detox/src/devices/SimulatorDriver.js b/detox/src/devices/SimulatorDriver.js index d4af028b9f..058ea41fd3 100644 --- a/detox/src/devices/SimulatorDriver.js +++ b/detox/src/devices/SimulatorDriver.js @@ -82,8 +82,8 @@ class SimulatorDriver extends IosDriver { await this._applesimutils.uninstall(deviceId, bundleId); } - async launch(deviceId, bundleId, launchArgs) { - return await this._applesimutils.launch(deviceId, bundleId, launchArgs); + async launch(deviceId, bundleId, launchArgs, language) { + return await this._applesimutils.launch(deviceId, bundleId, launchArgs, language); } async terminate(deviceId, bundleId) { From 30afc5f201e135deaf81821559ea98abfd7bb0dc Mon Sep 17 00:00:00 2001 From: Luis Naranjo Date: Thu, 2 Aug 2018 16:50:20 -0700 Subject: [PATCH 04/35] pass the other arg --- detox/src/devices/AppleSimUtils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/detox/src/devices/AppleSimUtils.js b/detox/src/devices/AppleSimUtils.js index 2438931c8e..e19e5a620c 100644 --- a/detox/src/devices/AppleSimUtils.js +++ b/detox/src/devices/AppleSimUtils.js @@ -250,7 +250,7 @@ class AppleSimUtils { ` tail -F ${logsInfo.absJoined}` }; - const languageArgs = !!language ? `-AppleLanguages "(${language})" ` : ''; + const languageArgs = !!language ? `-AppleLanguages "(${language})" -AppleLocale ${language} ` : ''; const launchBin = `/bin/cat /dev/null >${logsInfo.absStdout} 2>${logsInfo.absStderr} && ` + `SIMCTL_CHILD_DYLD_INSERT_LIBRARIES="${frameworkPath}/Detox" ` + From 4dd1215f52270a8d89bfcb22bc560a1907c5b75b Mon Sep 17 00:00:00 2001 From: Luis Naranjo Date: Thu, 2 Aug 2018 16:59:27 -0700 Subject: [PATCH 05/35] remove console.logs --- detox/src/devices/AppleSimUtils.js | 4 +--- detox/src/devices/Device.js | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/detox/src/devices/AppleSimUtils.js b/detox/src/devices/AppleSimUtils.js index e19e5a620c..9f864b4fc2 100644 --- a/detox/src/devices/AppleSimUtils.js +++ b/detox/src/devices/AppleSimUtils.js @@ -255,9 +255,7 @@ class AppleSimUtils { const launchBin = `/bin/cat /dev/null >${logsInfo.absStdout} 2>${logsInfo.absStderr} && ` + `SIMCTL_CHILD_DYLD_INSERT_LIBRARIES="${frameworkPath}/Detox" ` + `/usr/bin/xcrun simctl launch --stdout=${logsInfo.simStdout} --stderr=${logsInfo.simStderr} ` + - `${udid} ${bundleId} ${languageArgs}--args ${args}`; - - console.log(`Launching app w/ ${launchBin}`); + `${udid} ${bundleId} ${languageArgs}--args ${args}`;; return await exec.execWithRetriesAndLogs(launchBin, undefined, statusLogs, 1); } diff --git a/detox/src/devices/Device.js b/detox/src/devices/Device.js index c6d67dcbdf..d413f28ab9 100644 --- a/detox/src/devices/Device.js +++ b/detox/src/devices/Device.js @@ -113,7 +113,7 @@ class Device { bundleId: _bundleId, }); - const processId = await this.deviceDriver.launch(this._deviceId, _bundleId, this._prepareLaunchArgs(baseLaunchArgs)); + const processId = await this.deviceDriver.launch(this._deviceId, _bundleId, this._prepareLaunchArgs(baseLaunchArgs), params.language); this._processes[_bundleId] = processId; await this.deviceDriver.waitUntilReady(); From 9e00b94eba1c036aad944ec58d291c9734d1ec17 Mon Sep 17 00:00:00 2001 From: Luis Naranjo Date: Thu, 2 Aug 2018 17:01:15 -0700 Subject: [PATCH 06/35] pass language prop to android --- detox/src/devices/AndroidDriver.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/detox/src/devices/AndroidDriver.js b/detox/src/devices/AndroidDriver.js index 8f09af3970..1532627bae 100644 --- a/detox/src/devices/AndroidDriver.js +++ b/detox/src/devices/AndroidDriver.js @@ -86,7 +86,7 @@ class AndroidDriver extends DeviceDriverBase { } } - async launch(deviceId, bundleId, launchArgs) { + async launch(deviceId, bundleId, launchArgs, language) { const args = []; _.forEach(launchArgs, (value, key) => { args.push(`${key} ${value}`); From 9fb206fad2c8e6a90632e2c90eae06afd3910908 Mon Sep 17 00:00:00 2001 From: Luis Naranjo Date: Thu, 2 Aug 2018 17:02:26 -0700 Subject: [PATCH 07/35] remove a newline --- detox/src/devices/Device.js | 1 - 1 file changed, 1 deletion(-) diff --git a/detox/src/devices/Device.js b/detox/src/devices/Device.js index d413f28ab9..d34cf51807 100644 --- a/detox/src/devices/Device.js +++ b/detox/src/devices/Device.js @@ -67,7 +67,6 @@ class Device { params[launchKey] = payloadFilePath; } - async launchApp(params = {newInstance: false}, bundleId) { const payloadParams = ['url', 'userNotification', 'userActivity']; const hasPayload = this._assertHasSingleParam(payloadParams, params); From 92e7a420a63e77e091187467b57ed1fa51cd2179 Mon Sep 17 00:00:00 2001 From: Luis Naranjo Date: Thu, 2 Aug 2018 21:33:19 -0700 Subject: [PATCH 08/35] fix unit tests --- detox/src/devices/Device.test.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/detox/src/devices/Device.test.js b/detox/src/devices/Device.test.js index 2a485bc6e9..8e6e49d1bb 100644 --- a/detox/src/devices/Device.test.js +++ b/detox/src/devices/Device.test.js @@ -87,7 +87,7 @@ describe('Device', () => { expect(device.deviceDriver.launch).toHaveBeenCalledWith(device._deviceId, device._bundleId, - {"-detoxServer": "ws://localhost:8099", "-detoxSessionId": "test"}); + {"-detoxServer": "ws://localhost:8099", "-detoxSessionId": "test"}, undefined); }); it('launchApp() should emit \'launchApp\' event for async listeners and wait for them', async () => { @@ -163,7 +163,7 @@ describe('Device', () => { expect(device.deviceDriver.terminate).toHaveBeenCalled(); expect(device.deviceDriver.launch).toHaveBeenCalledWith(device._deviceId, device._bundleId, - {"-detoxServer": "ws://localhost:8099", "-detoxSessionId": "test"}); + {"-detoxServer": "ws://localhost:8099", "-detoxSessionId": "test"}, undefined); }); it(`relaunchApp({newInstance: false}) should not terminate the app before launch`, async () => { @@ -200,7 +200,7 @@ describe('Device', () => { expect(device.deviceDriver.installApp).toHaveBeenCalled(); expect(device.deviceDriver.launch).toHaveBeenCalledWith(device._deviceId, device._bundleId, - {"-detoxServer": "ws://localhost:8099", "-detoxSessionId": "test"}); + {"-detoxServer": "ws://localhost:8099", "-detoxSessionId": "test"}, undefined); }); it(`relaunchApp() without delete when reuse is enabled should not uninstall and install`, async () => { @@ -214,7 +214,7 @@ describe('Device', () => { expect(device.deviceDriver.installApp).not.toHaveBeenCalled(); expect(device.deviceDriver.launch).toHaveBeenCalledWith(device._deviceId, device._bundleId, - {"-detoxServer": "ws://localhost:8099", "-detoxSessionId": "test"}); + {"-detoxServer": "ws://localhost:8099", "-detoxSessionId": "test"}, undefined); }); it(`relaunchApp() with url should send the url as a param in launchParams`, async () => { @@ -223,7 +223,7 @@ describe('Device', () => { expect(device.deviceDriver.launch).toHaveBeenCalledWith(device._deviceId, device._bundleId, - {"-detoxServer": "ws://localhost:8099", "-detoxSessionId": "test", "-detoxURLOverride": "scheme://some.url"}); + {"-detoxServer": "ws://localhost:8099", "-detoxSessionId": "test", "-detoxURLOverride": "scheme://some.url"}, undefined); }); it(`relaunchApp() with url should send the url as a param in launchParams`, async () => { @@ -235,7 +235,7 @@ describe('Device', () => { { "-detoxServer": "ws://localhost:8099", "-detoxSessionId": "test", "-detoxURLOverride": "scheme://some.url", "-detoxSourceAppOverride": "sourceAppBundleId" - }); + }, undefined); }); it(`relaunchApp() with userNofitication should send the userNotification as a param in launchParams`, async () => { @@ -247,7 +247,7 @@ describe('Device', () => { expect(device.deviceDriver.launch).toHaveBeenCalledWith(device._deviceId, device._bundleId, - {"-detoxServer": "ws://localhost:8099", "-detoxSessionId": "test", "-detoxUserNotificationDataURL": "url"}); + {"-detoxServer": "ws://localhost:8099", "-detoxSessionId": "test", "-detoxUserNotificationDataURL": "url"}, undefined); }); it(`relaunchApp() with url and userNofitication should throw`, async () => { @@ -275,7 +275,7 @@ describe('Device', () => { expect(device.deviceDriver.launch).toHaveBeenCalledWith(device._deviceId, device._bundleId, - {"-detoxServer": "ws://localhost:8099", "-detoxSessionId": "test", "-arg1": "1", "-arg2": 2}); + {"-detoxServer": "ws://localhost:8099", "-detoxSessionId": "test", "-arg1": "1", "-arg2": 2}, undefined); }); it(`sendToHome() should pass to device driver`, async () => { From b160757eaddeebb42d453f90e5e33cc4a18eab27 Mon Sep 17 00:00:00 2001 From: Luis Naranjo Date: Thu, 2 Aug 2018 21:37:03 -0700 Subject: [PATCH 09/35] add a unit test --- detox/src/devices/Device.test.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/detox/src/devices/Device.test.js b/detox/src/devices/Device.test.js index 8e6e49d1bb..a0338568e3 100644 --- a/detox/src/devices/Device.test.js +++ b/detox/src/devices/Device.test.js @@ -90,6 +90,18 @@ describe('Device', () => { {"-detoxServer": "ws://localhost:8099", "-detoxSessionId": "test"}, undefined); }); + it('launchApp({language}) should launch app with a specific language', async () => { + device = validDevice(); + + const language = 'es-MX'; + + await device.launchApp({language}); + + expect(device.deviceDriver.launch).toHaveBeenCalledWith(device._deviceId, + device._bundleId, + {"-detoxServer": "ws://localhost:8099", "-detoxSessionId": "test"}, language); + }); + it('launchApp() should emit \'launchApp\' event for async listeners and wait for them', async () => { device = validDevice(); device.deviceDriver.launch.mockReturnValue(1); From 697e6bb4533af6151fea65ae9ccf0908bb40f9f4 Mon Sep 17 00:00:00 2001 From: Luis Naranjo Date: Sat, 8 Sep 2018 22:59:05 -0700 Subject: [PATCH 10/35] re-apply changes and fix unit tests --- detox/src/devices/Device.js | 2 +- detox/src/devices/Device.test.js | 4 ++-- detox/src/devices/drivers/SimulatorDriver.js | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/detox/src/devices/Device.js b/detox/src/devices/Device.js index 825afff155..ea31ddc47f 100644 --- a/detox/src/devices/Device.js +++ b/detox/src/devices/Device.js @@ -83,7 +83,7 @@ class Device { } } - const processId = await this.deviceDriver.launchApp(this._deviceId, _bundleId, this._prepareLaunchArgs(baseLaunchArgs)); + const processId = await this.deviceDriver.launchApp(this._deviceId, _bundleId, this._prepareLaunchArgs(baseLaunchArgs), params.language); this._processes[_bundleId] = processId; await this.deviceDriver.waitUntilReady(); diff --git a/detox/src/devices/Device.test.js b/detox/src/devices/Device.test.js index 4b3b79679d..3d7333fc7c 100644 --- a/detox/src/devices/Device.test.js +++ b/detox/src/devices/Device.test.js @@ -106,7 +106,7 @@ describe('Device', () => { await device.launchApp({language}); - expect(device.deviceDriver.launch).toHaveBeenCalledWith(device._deviceId, + expect(device.deviceDriver.launchApp).toHaveBeenCalledWith(device._deviceId, device._bundleId, {"-detoxServer": "ws://localhost:8099", "-detoxSessionId": "test"}, language); }); @@ -200,7 +200,7 @@ describe('Device', () => { expect(device.deviceDriver.launchApp).toHaveBeenCalledWith(device._deviceId, device._bundleId, - {"-detoxServer": "ws://localhost:8099", "-detoxSessionId": "test", "-detoxDisableTouchIndicators": true}); + {"-detoxServer": "ws://localhost:8099", "-detoxSessionId": "test", "-detoxDisableTouchIndicators": true}, undefined); }); it(`relaunchApp() with userNofitication should send the userNotification as a param in launchParams`, async () => { diff --git a/detox/src/devices/drivers/SimulatorDriver.js b/detox/src/devices/drivers/SimulatorDriver.js index 7960655222..bf54d37512 100644 --- a/detox/src/devices/drivers/SimulatorDriver.js +++ b/detox/src/devices/drivers/SimulatorDriver.js @@ -84,9 +84,9 @@ class SimulatorDriver extends IosDriver { await this._applesimutils.uninstall(deviceId, bundleId); } - async launchApp(deviceId, bundleId, launchArgs) { + async launchApp(deviceId, bundleId, launchArgs, language) { await this.emitter.emit('beforeLaunchApp', {bundleId, deviceId, launchArgs}); - const pid = await this._applesimutils.launch(deviceId, bundleId, launchArgs); + const pid = await this._applesimutils.launch(deviceId, bundleId, launchArgs, language); await this.emitter.emit('launchApp', {bundleId, deviceId, launchArgs, pid}); return pid; From 19f73daab29afd2bb461f35e3716483f76ccf98c Mon Sep 17 00:00:00 2001 From: Luis Naranjo Date: Sat, 8 Sep 2018 23:55:47 -0700 Subject: [PATCH 11/35] add a locale option --- detox/src/devices/Device.js | 2 +- detox/src/devices/drivers/SimulatorDriver.js | 4 ++-- detox/src/devices/ios/AppleSimUtils.js | 20 +++++++++++++------- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/detox/src/devices/Device.js b/detox/src/devices/Device.js index ea31ddc47f..fb44341103 100644 --- a/detox/src/devices/Device.js +++ b/detox/src/devices/Device.js @@ -83,7 +83,7 @@ class Device { } } - const processId = await this.deviceDriver.launchApp(this._deviceId, _bundleId, this._prepareLaunchArgs(baseLaunchArgs), params.language); + const processId = await this.deviceDriver.launchApp(this._deviceId, _bundleId, this._prepareLaunchArgs(baseLaunchArgs), params.languageAndLocale); this._processes[_bundleId] = processId; await this.deviceDriver.waitUntilReady(); diff --git a/detox/src/devices/drivers/SimulatorDriver.js b/detox/src/devices/drivers/SimulatorDriver.js index bf54d37512..dbb7d7862c 100644 --- a/detox/src/devices/drivers/SimulatorDriver.js +++ b/detox/src/devices/drivers/SimulatorDriver.js @@ -84,9 +84,9 @@ class SimulatorDriver extends IosDriver { await this._applesimutils.uninstall(deviceId, bundleId); } - async launchApp(deviceId, bundleId, launchArgs, language) { + async launchApp(deviceId, bundleId, launchArgs, languageAndLocale) { await this.emitter.emit('beforeLaunchApp', {bundleId, deviceId, launchArgs}); - const pid = await this._applesimutils.launch(deviceId, bundleId, launchArgs, language); + const pid = await this._applesimutils.launch(deviceId, bundleId, launchArgs, languageAndLocale); await this.emitter.emit('launchApp', {bundleId, deviceId, launchArgs, pid}); return pid; diff --git a/detox/src/devices/ios/AppleSimUtils.js b/detox/src/devices/ios/AppleSimUtils.js index f21a061951..7d20ea391a 100644 --- a/detox/src/devices/ios/AppleSimUtils.js +++ b/detox/src/devices/ios/AppleSimUtils.js @@ -121,12 +121,12 @@ class AppleSimUtils { } } - async launch(udid, bundleId, launchArgs, language) { + async launch(udid, bundleId, launchArgs, languageAndLocale) { const frameworkPath = await environment.getFrameworkPath(); const logsInfo = new LogsInfo(udid); const args = this._joinLaunchArgs(launchArgs); - const result = await this._launchMagically(frameworkPath, logsInfo, udid, bundleId, args, language); + const result = await this._launchMagically(frameworkPath, logsInfo, udid, bundleId, args, languageAndLocale); return this._parseLaunchId(result); } @@ -250,19 +250,25 @@ class AppleSimUtils { return _.map(launchArgs, (v, k) => `${k} ${v}`).join(' ').trim(); } - async _launchMagically(frameworkPath, logsInfo, udid, bundleId, args, language) { + async _launchMagically(frameworkPath, logsInfo, udid, bundleId, args, languageAndLocale) { const statusLogs = { trying: `Launching ${bundleId}...`, successful: `${bundleId} launched. The stdout and stderr logs were recreated, you can watch them with:\n` + ` tail -F ${logsInfo.absJoined}` }; - const languageArgs = !!language ? `-AppleLanguages "(${language})" -AppleLocale ${language} ` : ''; - - const launchBin = `/bin/cat /dev/null >${logsInfo.absStdout} 2>${logsInfo.absStderr} && ` + + let launchBin = `/bin/cat /dev/null >${logsInfo.absStdout} 2>${logsInfo.absStderr} && ` + `SIMCTL_CHILD_DYLD_INSERT_LIBRARIES="${frameworkPath}/Detox" ` + `/usr/bin/xcrun simctl launch --stdout=${logsInfo.simStdout} --stderr=${logsInfo.simStderr} ` + - `${udid} ${bundleId} ${languageArgs}--args ${args}`;; + `${udid} ${bundleId} --args ${args}`;; + + if (!!languageAndLocale && !!languageAndLocale.language) { + launchBin += ` -AppleLanguages "(${languageAndLocale.language})"`; + } + + if (!!languageAndLocale && !!languageAndLocale.locale) { + launchBin += ` -AppleLocale ${languageAndLocale.locale}`; + } return await exec.execWithRetriesAndLogs(launchBin, undefined, statusLogs, 1); } From 12a7a608022631b2bf8c35cdff9e74a238f4a8e0 Mon Sep 17 00:00:00 2001 From: Luis Naranjo Date: Sat, 8 Sep 2018 23:58:58 -0700 Subject: [PATCH 12/35] update unit test --- detox/src/devices/Device.test.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/detox/src/devices/Device.test.js b/detox/src/devices/Device.test.js index 3d7333fc7c..aeb116a4e1 100644 --- a/detox/src/devices/Device.test.js +++ b/detox/src/devices/Device.test.js @@ -99,16 +99,19 @@ describe('Device', () => { {"-detoxServer": "ws://localhost:8099", "-detoxSessionId": "test"}, undefined); }); - it('launchApp({language}) should launch app with a specific language', async () => { + it('launchApp({languageAndLocale}) should launch app with a specific language/locale', async () => { device = validDevice(); - const language = 'es-MX'; + const languageAndLocale = { + language: 'es-MX', + locale: 'es-MX' + }; - await device.launchApp({language}); + await device.launchApp({languageAndLocale}); expect(device.deviceDriver.launchApp).toHaveBeenCalledWith(device._deviceId, device._bundleId, - {"-detoxServer": "ws://localhost:8099", "-detoxSessionId": "test"}, language); + {"-detoxServer": "ws://localhost:8099", "-detoxSessionId": "test"}, languageAndLocale); }); it(`relaunchApp()`, async () => { From 8b6f74ffb43ead23624851c50431d2aa569244e2 Mon Sep 17 00:00:00 2001 From: Luis Naranjo Date: Sun, 9 Sep 2018 10:04:44 -0700 Subject: [PATCH 13/35] 100% test coverage --- detox/src/devices/ios/AppleSimUtils.test.js | 10 ++++++++++ .../ios/__snapshots__/AppleSimUtils.test.js.snap | 15 +++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/detox/src/devices/ios/AppleSimUtils.test.js b/detox/src/devices/ios/AppleSimUtils.test.js index d5cb389782..6f436125a3 100644 --- a/detox/src/devices/ios/AppleSimUtils.test.js +++ b/detox/src/devices/ios/AppleSimUtils.test.js @@ -317,6 +317,15 @@ describe('AppleSimUtils', () => { expect(exec.execWithRetriesAndLogs.mock.calls).toMatchSnapshot(); }); + it('appends language and locale flags', async () => { + const languageAndLocale = { + language: "es-MS", + locale: "en-US" + }; + await uut.launch('udid', 'theBundleId', undefined, languageAndLocale); + expect(exec.execWithRetriesAndLogs.mock.calls).toMatchSnapshot(); + }); + it('concats args', async () => { await uut.launch('udid', 'theBundleId', { 'foo': 'bar', 'bob': 'yourUncle' }); expect(exec.execWithRetriesAndLogs.mock.calls).toMatchSnapshot(); @@ -344,6 +353,7 @@ describe('AppleSimUtils', () => { const result = await uut.launch('udid', 'theBundleId'); expect(result).toEqual(12345); }); + }); describe('sendToHome', () => { diff --git a/detox/src/devices/ios/__snapshots__/AppleSimUtils.test.js.snap b/detox/src/devices/ios/__snapshots__/AppleSimUtils.test.js.snap index c39f0660ce..d7e49c3841 100644 --- a/detox/src/devices/ios/__snapshots__/AppleSimUtils.test.js.snap +++ b/detox/src/devices/ios/__snapshots__/AppleSimUtils.test.js.snap @@ -132,6 +132,21 @@ Array [ ] `; +exports[`AppleSimUtils launch appends language and locale flags 1`] = ` +Array [ + Array [ + "/bin/cat /dev/null >/Users/detox/Library/Developer/CoreSimulator/Devices/udid/data/tmp/detox.last_launch_app_log.out 2>/Users/detox/Library/Developer/CoreSimulator/Devices/udid/data/tmp/detox.last_launch_app_log.err && SIMCTL_CHILD_DYLD_INSERT_LIBRARIES=\\"undefined/Detox\\" /usr/bin/xcrun simctl launch --stdout=/tmp/detox.last_launch_app_log.out --stderr=/tmp/detox.last_launch_app_log.err udid theBundleId --args -AppleLanguages \\"(es-MS)\\" -AppleLocale en-US", + undefined, + Object { + "successful": "theBundleId launched. The stdout and stderr logs were recreated, you can watch them with: + tail -F /Users/detox/Library/Developer/CoreSimulator/Devices/udid/data/tmp/detox.last_launch_app_log.{out,err}", + "trying": "Launching theBundleId...", + }, + 1, + ], +] +`; + exports[`AppleSimUtils launch asks environment for frameworkPath 1`] = ` Array [ Array [ From 9de21e5f453302efeeffabf4edefffd50de0ad9a Mon Sep 17 00:00:00 2001 From: Luis Naranjo Date: Sun, 9 Sep 2018 11:16:28 -0700 Subject: [PATCH 14/35] temp rename unneeded test files --- detox/test/e2e/{01.sanity.test.js => 01.sanity.js} | 0 detox/test/e2e/{02.matchers.test.js => 02.matchers.js} | 0 detox/test/e2e/{03.actions.test.js => 03.actions.js} | 0 detox/test/e2e/{04.assertions.test.js => 04.assertions.js} | 0 detox/test/e2e/{05.waitfor.test.js => 05.waitfor.js} | 0 .../{06.device-orientation.test.js => 06.device-orientation.js} | 0 detox/test/e2e/{07.stress-tests.test.js => 07.stress-tests.js} | 0 detox/test/e2e/{08.stress-root.test.js => 08.stress-root.js} | 0 .../e2e/{09.stress-timeouts.test.js => 09.stress-timeouts.js} | 0 .../{10.async-and-callbacks.test.js => 10.async-and-callbacks.js} | 0 .../{11.user-notifications.test.js => 11.user-notifications.js} | 0 detox/test/e2e/{12.animations.test.js => 12.animations.js} | 0 detox/test/e2e/{13.permissions.test.js => 13.permissions.js} | 0 detox/test/e2e/{14.network.test.js => 14.network.js} | 0 detox/test/e2e/{15.urls.test.js => 15.urls.js} | 0 detox/test/e2e/{16.location.test.js => 16.location.js} | 0 detox/test/e2e/{17.datePicker.test.js => 17.datePicker.js} | 0 .../e2e/{18.user-activities.test.js => 18.user-activities.js} | 0 .../test/e2e/{19.crash-handling.test.js => 19.crash-handling.js} | 0 19 files changed, 0 insertions(+), 0 deletions(-) rename detox/test/e2e/{01.sanity.test.js => 01.sanity.js} (100%) rename detox/test/e2e/{02.matchers.test.js => 02.matchers.js} (100%) rename detox/test/e2e/{03.actions.test.js => 03.actions.js} (100%) rename detox/test/e2e/{04.assertions.test.js => 04.assertions.js} (100%) rename detox/test/e2e/{05.waitfor.test.js => 05.waitfor.js} (100%) rename detox/test/e2e/{06.device-orientation.test.js => 06.device-orientation.js} (100%) rename detox/test/e2e/{07.stress-tests.test.js => 07.stress-tests.js} (100%) rename detox/test/e2e/{08.stress-root.test.js => 08.stress-root.js} (100%) rename detox/test/e2e/{09.stress-timeouts.test.js => 09.stress-timeouts.js} (100%) rename detox/test/e2e/{10.async-and-callbacks.test.js => 10.async-and-callbacks.js} (100%) rename detox/test/e2e/{11.user-notifications.test.js => 11.user-notifications.js} (100%) rename detox/test/e2e/{12.animations.test.js => 12.animations.js} (100%) rename detox/test/e2e/{13.permissions.test.js => 13.permissions.js} (100%) rename detox/test/e2e/{14.network.test.js => 14.network.js} (100%) rename detox/test/e2e/{15.urls.test.js => 15.urls.js} (100%) rename detox/test/e2e/{16.location.test.js => 16.location.js} (100%) rename detox/test/e2e/{17.datePicker.test.js => 17.datePicker.js} (100%) rename detox/test/e2e/{18.user-activities.test.js => 18.user-activities.js} (100%) rename detox/test/e2e/{19.crash-handling.test.js => 19.crash-handling.js} (100%) diff --git a/detox/test/e2e/01.sanity.test.js b/detox/test/e2e/01.sanity.js similarity index 100% rename from detox/test/e2e/01.sanity.test.js rename to detox/test/e2e/01.sanity.js diff --git a/detox/test/e2e/02.matchers.test.js b/detox/test/e2e/02.matchers.js similarity index 100% rename from detox/test/e2e/02.matchers.test.js rename to detox/test/e2e/02.matchers.js diff --git a/detox/test/e2e/03.actions.test.js b/detox/test/e2e/03.actions.js similarity index 100% rename from detox/test/e2e/03.actions.test.js rename to detox/test/e2e/03.actions.js diff --git a/detox/test/e2e/04.assertions.test.js b/detox/test/e2e/04.assertions.js similarity index 100% rename from detox/test/e2e/04.assertions.test.js rename to detox/test/e2e/04.assertions.js diff --git a/detox/test/e2e/05.waitfor.test.js b/detox/test/e2e/05.waitfor.js similarity index 100% rename from detox/test/e2e/05.waitfor.test.js rename to detox/test/e2e/05.waitfor.js diff --git a/detox/test/e2e/06.device-orientation.test.js b/detox/test/e2e/06.device-orientation.js similarity index 100% rename from detox/test/e2e/06.device-orientation.test.js rename to detox/test/e2e/06.device-orientation.js diff --git a/detox/test/e2e/07.stress-tests.test.js b/detox/test/e2e/07.stress-tests.js similarity index 100% rename from detox/test/e2e/07.stress-tests.test.js rename to detox/test/e2e/07.stress-tests.js diff --git a/detox/test/e2e/08.stress-root.test.js b/detox/test/e2e/08.stress-root.js similarity index 100% rename from detox/test/e2e/08.stress-root.test.js rename to detox/test/e2e/08.stress-root.js diff --git a/detox/test/e2e/09.stress-timeouts.test.js b/detox/test/e2e/09.stress-timeouts.js similarity index 100% rename from detox/test/e2e/09.stress-timeouts.test.js rename to detox/test/e2e/09.stress-timeouts.js diff --git a/detox/test/e2e/10.async-and-callbacks.test.js b/detox/test/e2e/10.async-and-callbacks.js similarity index 100% rename from detox/test/e2e/10.async-and-callbacks.test.js rename to detox/test/e2e/10.async-and-callbacks.js diff --git a/detox/test/e2e/11.user-notifications.test.js b/detox/test/e2e/11.user-notifications.js similarity index 100% rename from detox/test/e2e/11.user-notifications.test.js rename to detox/test/e2e/11.user-notifications.js diff --git a/detox/test/e2e/12.animations.test.js b/detox/test/e2e/12.animations.js similarity index 100% rename from detox/test/e2e/12.animations.test.js rename to detox/test/e2e/12.animations.js diff --git a/detox/test/e2e/13.permissions.test.js b/detox/test/e2e/13.permissions.js similarity index 100% rename from detox/test/e2e/13.permissions.test.js rename to detox/test/e2e/13.permissions.js diff --git a/detox/test/e2e/14.network.test.js b/detox/test/e2e/14.network.js similarity index 100% rename from detox/test/e2e/14.network.test.js rename to detox/test/e2e/14.network.js diff --git a/detox/test/e2e/15.urls.test.js b/detox/test/e2e/15.urls.js similarity index 100% rename from detox/test/e2e/15.urls.test.js rename to detox/test/e2e/15.urls.js diff --git a/detox/test/e2e/16.location.test.js b/detox/test/e2e/16.location.js similarity index 100% rename from detox/test/e2e/16.location.test.js rename to detox/test/e2e/16.location.js diff --git a/detox/test/e2e/17.datePicker.test.js b/detox/test/e2e/17.datePicker.js similarity index 100% rename from detox/test/e2e/17.datePicker.test.js rename to detox/test/e2e/17.datePicker.js diff --git a/detox/test/e2e/18.user-activities.test.js b/detox/test/e2e/18.user-activities.js similarity index 100% rename from detox/test/e2e/18.user-activities.test.js rename to detox/test/e2e/18.user-activities.js diff --git a/detox/test/e2e/19.crash-handling.test.js b/detox/test/e2e/19.crash-handling.js similarity index 100% rename from detox/test/e2e/19.crash-handling.test.js rename to detox/test/e2e/19.crash-handling.js From c11308d9d9ca6db4e0d4f44b94067ced7502cb0f Mon Sep 17 00:00:00 2001 From: Luis Naranjo Date: Sun, 9 Sep 2018 11:20:45 -0700 Subject: [PATCH 15/35] temp use iphone 6 --- detox/test/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/detox/test/package.json b/detox/test/package.json index dfe4e4afeb..eefae07642 100644 --- a/detox/test/package.json +++ b/detox/test/package.json @@ -37,13 +37,13 @@ "binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/example.app", "build": "set -o pipefail && xcodebuild -project ios/example.xcodeproj -scheme example_ci -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build | xcpretty", "type": "ios.simulator", - "name": "iPhone X" + "name": "iPhone 6" }, "ios.sim.release": { "binaryPath": "ios/build/Build/Products/Release-iphonesimulator/example.app", "build": "set -o pipefail && export CODE_SIGNING_REQUIRED=NO && export RCT_NO_LAUNCH_PACKAGER=true && xcodebuild -project ios/example.xcodeproj -scheme example_ci -configuration Release -sdk iphonesimulator -derivedDataPath ios/build | xcpretty", "type": "ios.simulator", - "name": "iPhone X" + "name": "iPhone 6" }, "ios.none": { "binaryPath": "ios", From 9ee6c55d424a437a339311f30a65bfdbea3ff059 Mon Sep 17 00:00:00 2001 From: Luis Naranjo Date: Sun, 9 Sep 2018 11:31:07 -0700 Subject: [PATCH 16/35] install and link react-native-device-info --- detox/test/android/app/build.gradle | 1 + .../java/com/example/MainApplication.java | 2 + detox/test/android/settings.gradle | 2 + .../ios/example.xcodeproj/project.pbxproj | 119 +++++++++++++++++- detox/test/package.json | 3 +- 5 files changed, 125 insertions(+), 2 deletions(-) diff --git a/detox/test/android/app/build.gradle b/detox/test/android/app/build.gradle index 6130f7ebb8..38b897ee9d 100644 --- a/detox/test/android/app/build.gradle +++ b/detox/test/android/app/build.gradle @@ -60,6 +60,7 @@ android { } dependencies { + implementation project(':react-native-device-info') implementation "com.android.support:appcompat-v7:27.1.1" fromSourceImplementation(project(path: ":ReactAndroid")) diff --git a/detox/test/android/app/src/main/java/com/example/MainApplication.java b/detox/test/android/app/src/main/java/com/example/MainApplication.java index b6da2f9831..76758a6689 100644 --- a/detox/test/android/app/src/main/java/com/example/MainApplication.java +++ b/detox/test/android/app/src/main/java/com/example/MainApplication.java @@ -3,6 +3,7 @@ import android.app.Application; import com.facebook.react.ReactApplication; +import com.learnium.RNDeviceInfo.RNDeviceInfo; import com.facebook.react.ReactNativeHost; import com.facebook.react.ReactPackage; import com.facebook.react.shell.MainReactPackage; @@ -26,6 +27,7 @@ public boolean getUseDeveloperSupport() { protected List getPackages() { return Arrays.asList( new MainReactPackage(), + new RNDeviceInfo(), new NativeModulePackage() ); } diff --git a/detox/test/android/settings.gradle b/detox/test/android/settings.gradle index 55be9788c1..14eec18283 100644 --- a/detox/test/android/settings.gradle +++ b/detox/test/android/settings.gradle @@ -1,4 +1,6 @@ rootProject.name = 'DetoxTest' +include ':react-native-device-info' +project(':react-native-device-info').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-device-info/android') include ':app' diff --git a/detox/test/ios/example.xcodeproj/project.pbxproj b/detox/test/ios/example.xcodeproj/project.pbxproj index e4559136cf..8e11be8476 100644 --- a/detox/test/ios/example.xcodeproj/project.pbxproj +++ b/detox/test/ios/example.xcodeproj/project.pbxproj @@ -42,6 +42,7 @@ 39A34C791E30F3A000BEBB59 /* Detox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 39B044621DAED76400431EC5 /* Detox.framework */; }; 39B044651DAED76E00431EC5 /* Detox.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 39B044621DAED76400431EC5 /* Detox.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 832341B51AAA6A8300B99B32 /* libRCTText.a */; }; + CA3050EB41644470AAC97E89 /* libRNDeviceInfo.a in Frameworks */ = {isa = PBXBuildFile; fileRef = B8A28B62FB3541C19C71EE97 /* libRNDeviceInfo.a */; }; CC17D3321D60A24300267B0C /* NativeModule.m in Sources */ = {isa = PBXBuildFile; fileRef = CC17D3311D60A24300267B0C /* NativeModule.m */; }; E088C8F41F01585500CC48E9 /* CalendarManager.m in Sources */ = {isa = PBXBuildFile; fileRef = E088C8F31F01585500CC48E9 /* CalendarManager.m */; }; E088C8F51F025DE900CC48E9 /* CalendarManager.m in Sources */ = {isa = PBXBuildFile; fileRef = E088C8F31F01585500CC48E9 /* CalendarManager.m */; }; @@ -104,6 +105,34 @@ remoteGlobalIDString = 83CBBA2E1A601D0E00E9B192; remoteInfo = React; }; + 20AC4A5921459E1B0036F3CF /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = EBF21BDC1FC498900052F4D5; + remoteInfo = jsinspector; + }; + 20AC4A5B21459E1B0036F3CF /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = EBF21BFA1FC4989A0052F4D5; + remoteInfo = "jsinspector-tvOS"; + }; + 20AC4A6121459E1B0036F3CF /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = C09C646FD03A4D6BB6116478 /* RNDeviceInfo.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = DA5891D81BA9A9FC002B4DB2; + remoteInfo = RNDeviceInfo; + }; + 20AC4A6321459E1B0036F3CF /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = C09C646FD03A4D6BB6116478 /* RNDeviceInfo.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = E72EC1401F7ABB5A0001BC90; + remoteInfo = "RNDeviceInfo-tvOS"; + }; 396B38381EC9DAB600A226F2 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 396B38301EC9DAB600A226F2 /* RCTAnimation.xcodeproj */; @@ -365,6 +394,8 @@ 39FC9D24202899F90033C11A /* src */ = {isa = PBXFileReference; lastKnownFileType = folder; name = src; path = ../src; sourceTree = ""; }; 78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTLinking.xcodeproj; path = "../node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj"; sourceTree = ""; }; 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTText.xcodeproj; path = "../node_modules/react-native/Libraries/Text/RCTText.xcodeproj"; sourceTree = ""; }; + B8A28B62FB3541C19C71EE97 /* libRNDeviceInfo.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRNDeviceInfo.a; sourceTree = ""; }; + C09C646FD03A4D6BB6116478 /* RNDeviceInfo.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = RNDeviceInfo.xcodeproj; path = "../node_modules/react-native-device-info/ios/RNDeviceInfo.xcodeproj"; sourceTree = ""; }; CC17D3301D60A24300267B0C /* NativeModule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NativeModule.h; path = example/NativeModule.h; sourceTree = ""; }; CC17D3311D60A24300267B0C /* NativeModule.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = NativeModule.m; path = example/NativeModule.m; sourceTree = ""; }; E088C8F21F01585500CC48E9 /* CalendarManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CalendarManager.h; path = example/CalendarManager.h; sourceTree = ""; }; @@ -389,6 +420,7 @@ 00C302EA1ABCBA2D00DB3ED1 /* libRCTVibration.a in Frameworks */, 139FDEF61B0652A700C62182 /* libRCTWebSocket.a in Frameworks */, 39A077AA1E5450FF00A53A07 /* libRCTPushNotification.a in Frameworks */, + CA3050EB41644470AAC97E89 /* libRNDeviceInfo.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -505,6 +537,8 @@ 39A34C5D1E30ED3600BEBB59 /* libcxxreact.a */, 39A34C5F1E30ED3600BEBB59 /* libjschelpers.a */, 39A34C611E30ED3600BEBB59 /* libjschelpers.a */, + 20AC4A5A21459E1B0036F3CF /* libjsinspector.a */, + 20AC4A5C21459E1B0036F3CF /* libjsinspector-tvOS.a */, 4644B8651F897583003223D4 /* libthird-party.a */, 4644B8671F897583003223D4 /* libthird-party.a */, 4644B8691F897583003223D4 /* libdouble-conversion.a */, @@ -515,6 +549,23 @@ name = Products; sourceTree = ""; }; + 20AC4A3221459E1A0036F3CF /* Recovered References */ = { + isa = PBXGroup; + children = ( + B8A28B62FB3541C19C71EE97 /* libRNDeviceInfo.a */, + ); + name = "Recovered References"; + sourceTree = ""; + }; + 20AC4A5D21459E1B0036F3CF /* Products */ = { + isa = PBXGroup; + children = ( + 20AC4A6221459E1B0036F3CF /* libRNDeviceInfo.a */, + 20AC4A6421459E1B0036F3CF /* libRNDeviceInfo-tvOS.a */, + ); + name = Products; + sourceTree = ""; + }; 396B38311EC9DAB600A226F2 /* Products */ = { isa = PBXGroup; children = ( @@ -575,6 +626,7 @@ 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */, 00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */, 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */, + C09C646FD03A4D6BB6116478 /* RNDeviceInfo.xcodeproj */, ); name = Libraries; sourceTree = ""; @@ -596,6 +648,7 @@ CCFA7DE41D11D22600E15EDF /* Frameworks */, 832341AE1AAA6A7D00B99B32 /* Libraries */, 83CBBA001A601CBA00E9B192 /* Products */, + 20AC4A3221459E1A0036F3CF /* Recovered References */, ); indentWidth = 4; sourceTree = ""; @@ -666,7 +719,7 @@ 83CBB9F71A601CBA00E9B192 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0900; + LastUpgradeCheck = 900; ORGANIZATIONNAME = Facebook; }; buildConfigurationList = 83CBB9FA1A601CBA00E9B192 /* Build configuration list for PBXProject "example" */; @@ -733,6 +786,10 @@ ProductGroup = 146834001AC3E56700842450 /* Products */; ProjectRef = 146833FF1AC3E56700842450 /* React.xcodeproj */; }, + { + ProductGroup = 20AC4A5D21459E1B0036F3CF /* Products */; + ProjectRef = C09C646FD03A4D6BB6116478 /* RNDeviceInfo.xcodeproj */; + }, ); projectRoot = ""; targets = ( @@ -799,6 +856,34 @@ remoteRef = 146834031AC3E56700842450 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; + 20AC4A5A21459E1B0036F3CF /* libjsinspector.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = libjsinspector.a; + remoteRef = 20AC4A5921459E1B0036F3CF /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 20AC4A5C21459E1B0036F3CF /* libjsinspector-tvOS.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = "libjsinspector-tvOS.a"; + remoteRef = 20AC4A5B21459E1B0036F3CF /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 20AC4A6221459E1B0036F3CF /* libRNDeviceInfo.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = libRNDeviceInfo.a; + remoteRef = 20AC4A6121459E1B0036F3CF /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 20AC4A6421459E1B0036F3CF /* libRNDeviceInfo-tvOS.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = "libRNDeviceInfo-tvOS.a"; + remoteRef = 20AC4A6321459E1B0036F3CF /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; 396B38391EC9DAB600A226F2 /* libRCTAnimation.a */ = { isa = PBXReferenceProxy; fileType = archive.ar; @@ -1108,9 +1193,17 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; DEAD_CODE_STRIPPING = NO; DEVELOPMENT_TEAM = ""; + HEADER_SEARCH_PATHS = ( + "$(inherited)", + "$(SRCROOT)/../node_modules/react-native-device-info/ios/RNDeviceInfo", + ); INFOPLIST_FILE = example/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "\"$(SRCROOT)/example\"", + ); OTHER_LDFLAGS = ( "-ObjC", "-lc++", @@ -1125,9 +1218,17 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; DEVELOPMENT_TEAM = ""; + HEADER_SEARCH_PATHS = ( + "$(inherited)", + "$(SRCROOT)/../node_modules/react-native-device-info/ios/RNDeviceInfo", + ); INFOPLIST_FILE = example/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "\"$(SRCROOT)/example\"", + ); OTHER_LDFLAGS = ( "-ObjC", "-lc++", @@ -1143,9 +1244,17 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; DEAD_CODE_STRIPPING = NO; DEVELOPMENT_TEAM = ""; + HEADER_SEARCH_PATHS = ( + "$(inherited)", + "$(SRCROOT)/../node_modules/react-native-device-info/ios/RNDeviceInfo", + ); INFOPLIST_FILE = "$(SRCROOT)/example/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "\"$(SRCROOT)/example\"", + ); OTHER_LDFLAGS = ( "-ObjC", "-lc++", @@ -1160,9 +1269,17 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; DEVELOPMENT_TEAM = ""; + HEADER_SEARCH_PATHS = ( + "$(inherited)", + "$(SRCROOT)/../node_modules/react-native-device-info/ios/RNDeviceInfo", + ); INFOPLIST_FILE = "$(SRCROOT)/example/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "\"$(SRCROOT)/example\"", + ); OTHER_LDFLAGS = ( "-ObjC", "-lc++", diff --git a/detox/test/package.json b/detox/test/package.json index eefae07642..3752ef6369 100644 --- a/detox/test/package.json +++ b/detox/test/package.json @@ -16,7 +16,8 @@ }, "dependencies": { "react": "16.4.1", - "react-native": "0.56.0" + "react-native": "0.56.0", + "react-native-device-info": "^0.22.5" }, "devDependencies": { "detox": "^9.0.0", From fe31f849808a32bf09b8e87c9c9fbc794564e04b Mon Sep 17 00:00:00 2001 From: Luis Naranjo Date: Sun, 9 Sep 2018 11:34:30 -0700 Subject: [PATCH 17/35] add boilerplate for a language screen --- detox/test/src/Screens/LanguageScreen.js | 56 ++++++++++++++++++++++++ detox/test/src/Screens/index.js | 6 ++- detox/test/src/app.js | 1 + 3 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 detox/test/src/Screens/LanguageScreen.js diff --git a/detox/test/src/Screens/LanguageScreen.js b/detox/test/src/Screens/LanguageScreen.js new file mode 100644 index 0000000000..b472a0731b --- /dev/null +++ b/detox/test/src/Screens/LanguageScreen.js @@ -0,0 +1,56 @@ +import React, { Component } from 'react'; +import { + Text, + View, + TouchableOpacity +} from 'react-native'; + +export default class LanguageScreen extends Component { + + constructor(props) { + super(props); + this.state = { + greeting: undefined, + }; + console.log('LanguageScreen react component constructed (console.log test)'); + } + + renderTestButton(label, onPress) { + return ( + + {label} + + ) + } + + render() { + if (this.state.greeting) return this.renderAfterButton(); + return ( + + + Welcome + + {this.renderTestButton('Say Hello', this.onButtonPress.bind(this, 'Hello'))} + {this.renderTestButton('Say World', this.onButtonPress.bind(this, 'World'))} + + ); + } + + renderAfterButton() { + return ( + + + {this.state.greeting}!!! + + + ); + } + + onButtonPress(greeting) { + console.log('SanityScreen onButtonPress "' + greeting + '" (console.log test)'); + this.setState({ + greeting: greeting + }); + } + +} diff --git a/detox/test/src/Screens/index.js b/detox/test/src/Screens/index.js index 8548420b1c..01906d2300 100644 --- a/detox/test/src/Screens/index.js +++ b/detox/test/src/Screens/index.js @@ -12,7 +12,8 @@ import NetworkScreen from './NetworkScreen'; import AnimationsScreen from './AnimationsScreen'; import LocationScreen from './LocationScreen'; import ShakeScreen from './ShakeScreen'; -import DatePickerScreen from './DatePickerScreen' +import DatePickerScreen from './DatePickerScreen'; +import LanguageScreen from './LanguageScreen'; export { SanityScreen, @@ -29,5 +30,6 @@ export { AnimationsScreen, LocationScreen, ShakeScreen, - DatePickerScreen + DatePickerScreen, + LanguageScreen }; diff --git a/detox/test/src/app.js b/detox/test/src/app.js index cdb9201845..2e43897d19 100644 --- a/detox/test/src/app.js +++ b/detox/test/src/app.js @@ -78,6 +78,7 @@ class example extends Component { Choose a test + {this.renderScreenButton('Language', Screens.LanguageScreen)} {this.renderScreenButton('Sanity', Screens.SanityScreen)} {this.renderScreenButton('Matchers', Screens.MatchersScreen)} {this.renderScreenButton('Actions', Screens.ActionsScreen)} From 9cfd7637fbb89ca94be151585283962987c6d28e Mon Sep 17 00:00:00 2001 From: Luis Naranjo Date: Sun, 9 Sep 2018 11:37:56 -0700 Subject: [PATCH 18/35] render current country and locale in test app --- detox/test/src/Screens/LanguageScreen.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/detox/test/src/Screens/LanguageScreen.js b/detox/test/src/Screens/LanguageScreen.js index b472a0731b..f80fa3137d 100644 --- a/detox/test/src/Screens/LanguageScreen.js +++ b/detox/test/src/Screens/LanguageScreen.js @@ -4,6 +4,7 @@ import { View, TouchableOpacity } from 'react-native'; +import DeviceInfo from 'react-native-device-info'; export default class LanguageScreen extends Component { @@ -28,7 +29,10 @@ export default class LanguageScreen extends Component { return ( - Welcome + Current language: {DeviceInfo.getDeviceLocale()} + + + Current country: {DeviceInfo.getDeviceCountry()} {this.renderTestButton('Say Hello', this.onButtonPress.bind(this, 'Hello'))} {this.renderTestButton('Say World', this.onButtonPress.bind(this, 'World'))} From 1de2f1ef8440e7d19b676032e2b5859d770feb8c Mon Sep 17 00:00:00 2001 From: Luis Naranjo Date: Sun, 9 Sep 2018 11:43:59 -0700 Subject: [PATCH 19/35] add e2e test --- detox/test/e2e/06.device.test.js | 125 +++++++++++++++++-------------- 1 file changed, 68 insertions(+), 57 deletions(-) diff --git a/detox/test/e2e/06.device.test.js b/detox/test/e2e/06.device.test.js index ed460c7f87..6fcf760b99 100644 --- a/detox/test/e2e/06.device.test.js +++ b/detox/test/e2e/06.device.test.js @@ -1,70 +1,81 @@ describe('Device', () => { - it('reloadReactNative - should tap successfully', async () => { - await device.reloadReactNative(); - await element(by.text('Sanity')).tap(); - await element(by.text('Say Hello')).tap(); - await expect(element(by.text('Hello!!!'))).toBeVisible(); - }); + // it('reloadReactNative - should tap successfully', async () => { + // await device.reloadReactNative(); + // await element(by.text('Sanity')).tap(); + // await element(by.text('Say Hello')).tap(); + // await expect(element(by.text('Hello!!!'))).toBeVisible(); + // }); - it('relaunchApp - should tap successfully', async () => { - await device.relaunchApp(); - await element(by.text('Sanity')).tap(); - await element(by.text('Say Hello')).tap(); - await expect(element(by.text('Hello!!!'))).toBeVisible(); - }); + // it('relaunchApp - should tap successfully', async () => { + // await device.relaunchApp(); + // await element(by.text('Sanity')).tap(); + // await element(by.text('Say Hello')).tap(); + // await expect(element(by.text('Hello!!!'))).toBeVisible(); + // }); - it('relaunchApp({delete: true}) - should tap successfully', async () => { - await device.relaunchApp({delete: true}); - await element(by.text('Sanity')).tap(); - await element(by.text('Say Hello')).tap(); - await expect(element(by.text('Hello!!!'))).toBeVisible(); - }); + // it('relaunchApp({delete: true}) - should tap successfully', async () => { + // await device.relaunchApp({delete: true}); + // await element(by.text('Sanity')).tap(); + // await element(by.text('Say Hello')).tap(); + // await expect(element(by.text('Hello!!!'))).toBeVisible(); + // }); - it('uninstall() + install() + relaunch() - should tap successfully', async () => { - await device.uninstallApp(); - await device.installApp(); - await device.relaunchApp(); - await element(by.text('Sanity')).tap(); - await element(by.text('Say Hello')).tap(); - await expect(element(by.text('Hello!!!'))).toBeVisible(); - }); + // it('uninstall() + install() + relaunch() - should tap successfully', async () => { + // await device.uninstallApp(); + // await device.installApp(); + // await device.relaunchApp(); + // await element(by.text('Sanity')).tap(); + // await element(by.text('Say Hello')).tap(); + // await expect(element(by.text('Hello!!!'))).toBeVisible(); + // }); - it('launchApp({newInstance: true}) + sendToHome() + launchApp() - should bring up previous instance', async () => { - await device.launchApp({newInstance: true}); - await element(by.text('Sanity')).tap(); - await element(by.text('Say Hello')).tap(); - await device.sendToHome(); - await device.launchApp(); + // it('launchApp({newInstance: true}) + sendToHome() + launchApp() - should bring up previous instance', async () => { + // await device.launchApp({newInstance: true}); + // await element(by.text('Sanity')).tap(); + // await element(by.text('Say Hello')).tap(); + // await device.sendToHome(); + // await device.launchApp(); - await expect(element(by.text('Hello!!!'))).toBeVisible(); - }); + // await expect(element(by.text('Hello!!!'))).toBeVisible(); + // }); - it('resetContentAndSettings() + install() + relaunch() - should tap successfully', async () => { - await device.resetContentAndSettings(); - await device.installApp(); - await device.launchApp({ newInstance: true }); - await element(by.text('Sanity')).tap(); - await element(by.text('Say Hello')).tap(); - await expect(element(by.text('Hello!!!'))).toBeVisible(); - }); + it('launchApp in a different language', async () => { + let languageAndLocale = { + language: "es-MX", + locale: "es-MX" + }; - it(':ios: shake() should shake screen', async () => { - await device.reloadReactNative(); - await element(by.text('Shake')).tap(); - await device.shake(); - await expect(element(by.text('Shaken, not stirred'))).toBeVisible(); + await device.launchApp({newInstance: true}); + await element(by.text('Language')).tap(); + await expect(element(by.text('Current language: es-MX'))).toBeVisible(); }); - describe(':android: device back button', () => { - beforeEach(async() => { - await device.reloadReactNative(); - await element(by.text('Actions')).tap(); - }); + // it('resetContentAndSettings() + install() + relaunch() - should tap successfully', async () => { + // await device.resetContentAndSettings(); + // await device.installApp(); + // await device.launchApp({ newInstance: true }); + // await element(by.text('Sanity')).tap(); + // await element(by.text('Say Hello')).tap(); + // await expect(element(by.text('Hello!!!'))).toBeVisible(); + // }); - it(':android: should show popup back pressed when back button is pressed', async () => { - await device.pressBack(); - await expect(element(by.text('Back pressed !'))).toBeVisible(); - }); - }); + // it(':ios: shake() should shake screen', async () => { + // await device.reloadReactNative(); + // await element(by.text('Shake')).tap(); + // await device.shake(); + // await expect(element(by.text('Shaken, not stirred'))).toBeVisible(); + // }); + + // describe(':android: device back button', () => { + // beforeEach(async() => { + // await device.reloadReactNative(); + // await element(by.text('Actions')).tap(); + // }); + + // it(':android: should show popup back pressed when back button is pressed', async () => { + // await device.pressBack(); + // await expect(element(by.text('Back pressed !'))).toBeVisible(); + // }); + // }); }); From 8c648b53e95b9726217a5a59d1c45ee154a0ee80 Mon Sep 17 00:00:00 2001 From: Luis Naranjo Date: Sun, 9 Sep 2018 12:43:50 -0700 Subject: [PATCH 20/35] add language UI to language screen --- detox/test/src/Screens/LanguageScreen.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/detox/test/src/Screens/LanguageScreen.js b/detox/test/src/Screens/LanguageScreen.js index f80fa3137d..6a8a4925b7 100644 --- a/detox/test/src/Screens/LanguageScreen.js +++ b/detox/test/src/Screens/LanguageScreen.js @@ -4,7 +4,8 @@ import { View, TouchableOpacity } from 'react-native'; -import DeviceInfo from 'react-native-device-info'; +import { NativeModules } from 'react-native' +import _ from "lodash"; export default class LanguageScreen extends Component { @@ -29,10 +30,10 @@ export default class LanguageScreen extends Component { return ( - Current language: {DeviceInfo.getDeviceLocale()} + Current locale: {NativeModules.SettingsManager.settings.AppleLocale} - Current country: {DeviceInfo.getDeviceCountry()} + Current language: {_.take(NativeModules.SettingsManager.settings.AppleLanguages, 1)} {this.renderTestButton('Say Hello', this.onButtonPress.bind(this, 'Hello'))} {this.renderTestButton('Say World', this.onButtonPress.bind(this, 'World'))} From ab62a220e68871574e415d0baed719b27e0c2362 Mon Sep 17 00:00:00 2001 From: Luis Naranjo Date: Sun, 9 Sep 2018 12:45:52 -0700 Subject: [PATCH 21/35] update e2e --- detox/test/e2e/06.device.test.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/detox/test/e2e/06.device.test.js b/detox/test/e2e/06.device.test.js index 6fcf760b99..461fc250e8 100644 --- a/detox/test/e2e/06.device.test.js +++ b/detox/test/e2e/06.device.test.js @@ -47,7 +47,8 @@ describe('Device', () => { await device.launchApp({newInstance: true}); await element(by.text('Language')).tap(); - await expect(element(by.text('Current language: es-MX'))).toBeVisible(); + await expect(element(by.text('Say Hello'))).toBeVisible(); + // await expect(element(by.text('Current language: es-MX'))).toBeVisible(); }); // it('resetContentAndSettings() + install() + relaunch() - should tap successfully', async () => { From 55e256de08759908de79d279feca05db157b3dac Mon Sep 17 00:00:00 2001 From: Luis Naranjo Date: Sun, 9 Sep 2018 12:46:26 -0700 Subject: [PATCH 22/35] Revert "install and link react-native-device-info" This reverts commit 9ee6c55d424a437a339311f30a65bfdbea3ff059. --- detox/test/android/app/build.gradle | 1 - .../java/com/example/MainApplication.java | 2 - detox/test/android/settings.gradle | 2 - .../ios/example.xcodeproj/project.pbxproj | 119 +----------------- detox/test/package.json | 3 +- 5 files changed, 2 insertions(+), 125 deletions(-) diff --git a/detox/test/android/app/build.gradle b/detox/test/android/app/build.gradle index 38b897ee9d..6130f7ebb8 100644 --- a/detox/test/android/app/build.gradle +++ b/detox/test/android/app/build.gradle @@ -60,7 +60,6 @@ android { } dependencies { - implementation project(':react-native-device-info') implementation "com.android.support:appcompat-v7:27.1.1" fromSourceImplementation(project(path: ":ReactAndroid")) diff --git a/detox/test/android/app/src/main/java/com/example/MainApplication.java b/detox/test/android/app/src/main/java/com/example/MainApplication.java index 76758a6689..b6da2f9831 100644 --- a/detox/test/android/app/src/main/java/com/example/MainApplication.java +++ b/detox/test/android/app/src/main/java/com/example/MainApplication.java @@ -3,7 +3,6 @@ import android.app.Application; import com.facebook.react.ReactApplication; -import com.learnium.RNDeviceInfo.RNDeviceInfo; import com.facebook.react.ReactNativeHost; import com.facebook.react.ReactPackage; import com.facebook.react.shell.MainReactPackage; @@ -27,7 +26,6 @@ public boolean getUseDeveloperSupport() { protected List getPackages() { return Arrays.asList( new MainReactPackage(), - new RNDeviceInfo(), new NativeModulePackage() ); } diff --git a/detox/test/android/settings.gradle b/detox/test/android/settings.gradle index 14eec18283..55be9788c1 100644 --- a/detox/test/android/settings.gradle +++ b/detox/test/android/settings.gradle @@ -1,6 +1,4 @@ rootProject.name = 'DetoxTest' -include ':react-native-device-info' -project(':react-native-device-info').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-device-info/android') include ':app' diff --git a/detox/test/ios/example.xcodeproj/project.pbxproj b/detox/test/ios/example.xcodeproj/project.pbxproj index 8e11be8476..e4559136cf 100644 --- a/detox/test/ios/example.xcodeproj/project.pbxproj +++ b/detox/test/ios/example.xcodeproj/project.pbxproj @@ -42,7 +42,6 @@ 39A34C791E30F3A000BEBB59 /* Detox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 39B044621DAED76400431EC5 /* Detox.framework */; }; 39B044651DAED76E00431EC5 /* Detox.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 39B044621DAED76400431EC5 /* Detox.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 832341B51AAA6A8300B99B32 /* libRCTText.a */; }; - CA3050EB41644470AAC97E89 /* libRNDeviceInfo.a in Frameworks */ = {isa = PBXBuildFile; fileRef = B8A28B62FB3541C19C71EE97 /* libRNDeviceInfo.a */; }; CC17D3321D60A24300267B0C /* NativeModule.m in Sources */ = {isa = PBXBuildFile; fileRef = CC17D3311D60A24300267B0C /* NativeModule.m */; }; E088C8F41F01585500CC48E9 /* CalendarManager.m in Sources */ = {isa = PBXBuildFile; fileRef = E088C8F31F01585500CC48E9 /* CalendarManager.m */; }; E088C8F51F025DE900CC48E9 /* CalendarManager.m in Sources */ = {isa = PBXBuildFile; fileRef = E088C8F31F01585500CC48E9 /* CalendarManager.m */; }; @@ -105,34 +104,6 @@ remoteGlobalIDString = 83CBBA2E1A601D0E00E9B192; remoteInfo = React; }; - 20AC4A5921459E1B0036F3CF /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = EBF21BDC1FC498900052F4D5; - remoteInfo = jsinspector; - }; - 20AC4A5B21459E1B0036F3CF /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = EBF21BFA1FC4989A0052F4D5; - remoteInfo = "jsinspector-tvOS"; - }; - 20AC4A6121459E1B0036F3CF /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = C09C646FD03A4D6BB6116478 /* RNDeviceInfo.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = DA5891D81BA9A9FC002B4DB2; - remoteInfo = RNDeviceInfo; - }; - 20AC4A6321459E1B0036F3CF /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = C09C646FD03A4D6BB6116478 /* RNDeviceInfo.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = E72EC1401F7ABB5A0001BC90; - remoteInfo = "RNDeviceInfo-tvOS"; - }; 396B38381EC9DAB600A226F2 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 396B38301EC9DAB600A226F2 /* RCTAnimation.xcodeproj */; @@ -394,8 +365,6 @@ 39FC9D24202899F90033C11A /* src */ = {isa = PBXFileReference; lastKnownFileType = folder; name = src; path = ../src; sourceTree = ""; }; 78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTLinking.xcodeproj; path = "../node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj"; sourceTree = ""; }; 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTText.xcodeproj; path = "../node_modules/react-native/Libraries/Text/RCTText.xcodeproj"; sourceTree = ""; }; - B8A28B62FB3541C19C71EE97 /* libRNDeviceInfo.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRNDeviceInfo.a; sourceTree = ""; }; - C09C646FD03A4D6BB6116478 /* RNDeviceInfo.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = RNDeviceInfo.xcodeproj; path = "../node_modules/react-native-device-info/ios/RNDeviceInfo.xcodeproj"; sourceTree = ""; }; CC17D3301D60A24300267B0C /* NativeModule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NativeModule.h; path = example/NativeModule.h; sourceTree = ""; }; CC17D3311D60A24300267B0C /* NativeModule.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = NativeModule.m; path = example/NativeModule.m; sourceTree = ""; }; E088C8F21F01585500CC48E9 /* CalendarManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CalendarManager.h; path = example/CalendarManager.h; sourceTree = ""; }; @@ -420,7 +389,6 @@ 00C302EA1ABCBA2D00DB3ED1 /* libRCTVibration.a in Frameworks */, 139FDEF61B0652A700C62182 /* libRCTWebSocket.a in Frameworks */, 39A077AA1E5450FF00A53A07 /* libRCTPushNotification.a in Frameworks */, - CA3050EB41644470AAC97E89 /* libRNDeviceInfo.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -537,8 +505,6 @@ 39A34C5D1E30ED3600BEBB59 /* libcxxreact.a */, 39A34C5F1E30ED3600BEBB59 /* libjschelpers.a */, 39A34C611E30ED3600BEBB59 /* libjschelpers.a */, - 20AC4A5A21459E1B0036F3CF /* libjsinspector.a */, - 20AC4A5C21459E1B0036F3CF /* libjsinspector-tvOS.a */, 4644B8651F897583003223D4 /* libthird-party.a */, 4644B8671F897583003223D4 /* libthird-party.a */, 4644B8691F897583003223D4 /* libdouble-conversion.a */, @@ -549,23 +515,6 @@ name = Products; sourceTree = ""; }; - 20AC4A3221459E1A0036F3CF /* Recovered References */ = { - isa = PBXGroup; - children = ( - B8A28B62FB3541C19C71EE97 /* libRNDeviceInfo.a */, - ); - name = "Recovered References"; - sourceTree = ""; - }; - 20AC4A5D21459E1B0036F3CF /* Products */ = { - isa = PBXGroup; - children = ( - 20AC4A6221459E1B0036F3CF /* libRNDeviceInfo.a */, - 20AC4A6421459E1B0036F3CF /* libRNDeviceInfo-tvOS.a */, - ); - name = Products; - sourceTree = ""; - }; 396B38311EC9DAB600A226F2 /* Products */ = { isa = PBXGroup; children = ( @@ -626,7 +575,6 @@ 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */, 00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */, 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */, - C09C646FD03A4D6BB6116478 /* RNDeviceInfo.xcodeproj */, ); name = Libraries; sourceTree = ""; @@ -648,7 +596,6 @@ CCFA7DE41D11D22600E15EDF /* Frameworks */, 832341AE1AAA6A7D00B99B32 /* Libraries */, 83CBBA001A601CBA00E9B192 /* Products */, - 20AC4A3221459E1A0036F3CF /* Recovered References */, ); indentWidth = 4; sourceTree = ""; @@ -719,7 +666,7 @@ 83CBB9F71A601CBA00E9B192 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 900; + LastUpgradeCheck = 0900; ORGANIZATIONNAME = Facebook; }; buildConfigurationList = 83CBB9FA1A601CBA00E9B192 /* Build configuration list for PBXProject "example" */; @@ -786,10 +733,6 @@ ProductGroup = 146834001AC3E56700842450 /* Products */; ProjectRef = 146833FF1AC3E56700842450 /* React.xcodeproj */; }, - { - ProductGroup = 20AC4A5D21459E1B0036F3CF /* Products */; - ProjectRef = C09C646FD03A4D6BB6116478 /* RNDeviceInfo.xcodeproj */; - }, ); projectRoot = ""; targets = ( @@ -856,34 +799,6 @@ remoteRef = 146834031AC3E56700842450 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; - 20AC4A5A21459E1B0036F3CF /* libjsinspector.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libjsinspector.a; - remoteRef = 20AC4A5921459E1B0036F3CF /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 20AC4A5C21459E1B0036F3CF /* libjsinspector-tvOS.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = "libjsinspector-tvOS.a"; - remoteRef = 20AC4A5B21459E1B0036F3CF /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 20AC4A6221459E1B0036F3CF /* libRNDeviceInfo.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libRNDeviceInfo.a; - remoteRef = 20AC4A6121459E1B0036F3CF /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 20AC4A6421459E1B0036F3CF /* libRNDeviceInfo-tvOS.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = "libRNDeviceInfo-tvOS.a"; - remoteRef = 20AC4A6321459E1B0036F3CF /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; 396B38391EC9DAB600A226F2 /* libRCTAnimation.a */ = { isa = PBXReferenceProxy; fileType = archive.ar; @@ -1193,17 +1108,9 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; DEAD_CODE_STRIPPING = NO; DEVELOPMENT_TEAM = ""; - HEADER_SEARCH_PATHS = ( - "$(inherited)", - "$(SRCROOT)/../node_modules/react-native-device-info/ios/RNDeviceInfo", - ); INFOPLIST_FILE = example/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - "\"$(SRCROOT)/example\"", - ); OTHER_LDFLAGS = ( "-ObjC", "-lc++", @@ -1218,17 +1125,9 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; DEVELOPMENT_TEAM = ""; - HEADER_SEARCH_PATHS = ( - "$(inherited)", - "$(SRCROOT)/../node_modules/react-native-device-info/ios/RNDeviceInfo", - ); INFOPLIST_FILE = example/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - "\"$(SRCROOT)/example\"", - ); OTHER_LDFLAGS = ( "-ObjC", "-lc++", @@ -1244,17 +1143,9 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; DEAD_CODE_STRIPPING = NO; DEVELOPMENT_TEAM = ""; - HEADER_SEARCH_PATHS = ( - "$(inherited)", - "$(SRCROOT)/../node_modules/react-native-device-info/ios/RNDeviceInfo", - ); INFOPLIST_FILE = "$(SRCROOT)/example/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - "\"$(SRCROOT)/example\"", - ); OTHER_LDFLAGS = ( "-ObjC", "-lc++", @@ -1269,17 +1160,9 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; DEVELOPMENT_TEAM = ""; - HEADER_SEARCH_PATHS = ( - "$(inherited)", - "$(SRCROOT)/../node_modules/react-native-device-info/ios/RNDeviceInfo", - ); INFOPLIST_FILE = "$(SRCROOT)/example/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - "\"$(SRCROOT)/example\"", - ); OTHER_LDFLAGS = ( "-ObjC", "-lc++", diff --git a/detox/test/package.json b/detox/test/package.json index 3752ef6369..eefae07642 100644 --- a/detox/test/package.json +++ b/detox/test/package.json @@ -16,8 +16,7 @@ }, "dependencies": { "react": "16.4.1", - "react-native": "0.56.0", - "react-native-device-info": "^0.22.5" + "react-native": "0.56.0" }, "devDependencies": { "detox": "^9.0.0", From 667475c50c163e936d9aa13c20a801d7748b7dbc Mon Sep 17 00:00:00 2001 From: Luis Naranjo Date: Sun, 9 Sep 2018 12:59:34 -0700 Subject: [PATCH 23/35] e2e test is passing --- detox/test/e2e/06.device.test.js | 16 ++++++-- detox/test/src/Screens/LanguageScreen.js | 49 ++++-------------------- 2 files changed, 20 insertions(+), 45 deletions(-) diff --git a/detox/test/e2e/06.device.test.js b/detox/test/e2e/06.device.test.js index 461fc250e8..c74404c644 100644 --- a/detox/test/e2e/06.device.test.js +++ b/detox/test/e2e/06.device.test.js @@ -45,10 +45,20 @@ describe('Device', () => { locale: "es-MX" }; - await device.launchApp({newInstance: true}); + await device.launchApp({newInstance: true, languageAndLocale}); await element(by.text('Language')).tap(); - await expect(element(by.text('Say Hello'))).toBeVisible(); - // await expect(element(by.text('Current language: es-MX'))).toBeVisible(); + await expect(element(by.text(`Current locale: ${languageAndLocale.locale}`))).toBeVisible(); + await expect(element(by.text(`Current language: ${languageAndLocale.language}`))).toBeVisible(); + + languageAndLocale = { + language: "en-US", + locale: "en-US" + }; + + await device.launchApp({newInstance: true, languageAndLocale}); + await element(by.text('Language')).tap(); + await expect(element(by.text(`Current locale: ${languageAndLocale.locale}`))).toBeVisible(); + await expect(element(by.text(`Current language: ${languageAndLocale.language}`))).toBeVisible(); }); // it('resetContentAndSettings() + install() + relaunch() - should tap successfully', async () => { diff --git a/detox/test/src/Screens/LanguageScreen.js b/detox/test/src/Screens/LanguageScreen.js index 6a8a4925b7..36806bf059 100644 --- a/detox/test/src/Screens/LanguageScreen.js +++ b/detox/test/src/Screens/LanguageScreen.js @@ -1,61 +1,26 @@ import React, { Component } from 'react'; -import { - Text, - View, - TouchableOpacity -} from 'react-native'; -import { NativeModules } from 'react-native' -import _ from "lodash"; +import { Text, View } from 'react-native'; +import { NativeModules } from 'react-native'; +import _ from 'lodash'; export default class LanguageScreen extends Component { - constructor(props) { super(props); this.state = { - greeting: undefined, + greeting: undefined }; console.log('LanguageScreen react component constructed (console.log test)'); } - renderTestButton(label, onPress) { - return ( - - {label} - - ) - } - render() { if (this.state.greeting) return this.renderAfterButton(); return ( - - - Current locale: {NativeModules.SettingsManager.settings.AppleLocale} - - + + Current locale: {NativeModules.SettingsManager.settings.AppleLocale} + Current language: {_.take(NativeModules.SettingsManager.settings.AppleLanguages, 1)} - {this.renderTestButton('Say Hello', this.onButtonPress.bind(this, 'Hello'))} - {this.renderTestButton('Say World', this.onButtonPress.bind(this, 'World'))} - - ); - } - - renderAfterButton() { - return ( - - - {this.state.greeting}!!! - ); } - - onButtonPress(greeting) { - console.log('SanityScreen onButtonPress "' + greeting + '" (console.log test)'); - this.setState({ - greeting: greeting - }); - } - } From 3f6bb3023e602c21b6670c9928bbb2ef7102fcb4 Mon Sep 17 00:00:00 2001 From: Luis Naranjo Date: Sun, 9 Sep 2018 13:01:57 -0700 Subject: [PATCH 24/35] clean up language screen --- detox/test/src/Screens/LanguageScreen.js | 9 --------- 1 file changed, 9 deletions(-) diff --git a/detox/test/src/Screens/LanguageScreen.js b/detox/test/src/Screens/LanguageScreen.js index 36806bf059..d8cba4e7c9 100644 --- a/detox/test/src/Screens/LanguageScreen.js +++ b/detox/test/src/Screens/LanguageScreen.js @@ -4,16 +4,7 @@ import { NativeModules } from 'react-native'; import _ from 'lodash'; export default class LanguageScreen extends Component { - constructor(props) { - super(props); - this.state = { - greeting: undefined - }; - console.log('LanguageScreen react component constructed (console.log test)'); - } - render() { - if (this.state.greeting) return this.renderAfterButton(); return ( Current locale: {NativeModules.SettingsManager.settings.AppleLocale} From 971fb09ca5e6e86623848c87dc99aa6a11a95392 Mon Sep 17 00:00:00 2001 From: Luis Naranjo Date: Sun, 9 Sep 2018 13:38:16 -0700 Subject: [PATCH 25/35] temp switch emulator --- detox/test/e2e/06.device.test.js | 52 ++++++++++++++++---------------- detox/test/package.json | 2 +- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/detox/test/e2e/06.device.test.js b/detox/test/e2e/06.device.test.js index c74404c644..0468011eb3 100644 --- a/detox/test/e2e/06.device.test.js +++ b/detox/test/e2e/06.device.test.js @@ -29,37 +29,37 @@ describe('Device', () => { // await expect(element(by.text('Hello!!!'))).toBeVisible(); // }); - // it('launchApp({newInstance: true}) + sendToHome() + launchApp() - should bring up previous instance', async () => { - // await device.launchApp({newInstance: true}); - // await element(by.text('Sanity')).tap(); - // await element(by.text('Say Hello')).tap(); - // await device.sendToHome(); - // await device.launchApp(); + it('launchApp({newInstance: true}) + sendToHome() + launchApp() - should bring up previous instance', async () => { + await device.launchApp({newInstance: true}); + await element(by.text('Sanity')).tap(); + await element(by.text('Say Hello')).tap(); + await device.sendToHome(); + await device.launchApp(); - // await expect(element(by.text('Hello!!!'))).toBeVisible(); - // }); + await expect(element(by.text('Hello!!!'))).toBeVisible(); + }); - it('launchApp in a different language', async () => { - let languageAndLocale = { - language: "es-MX", - locale: "es-MX" - }; + // it('launchApp in a different language', async () => { + // let languageAndLocale = { + // language: "es-MX", + // locale: "es-MX" + // }; - await device.launchApp({newInstance: true, languageAndLocale}); - await element(by.text('Language')).tap(); - await expect(element(by.text(`Current locale: ${languageAndLocale.locale}`))).toBeVisible(); - await expect(element(by.text(`Current language: ${languageAndLocale.language}`))).toBeVisible(); + // await device.launchApp({newInstance: true, languageAndLocale}); + // await element(by.text('Language')).tap(); + // await expect(element(by.text(`Current locale: ${languageAndLocale.locale}`))).toBeVisible(); + // await expect(element(by.text(`Current language: ${languageAndLocale.language}`))).toBeVisible(); - languageAndLocale = { - language: "en-US", - locale: "en-US" - }; + // languageAndLocale = { + // language: "en-US", + // locale: "en-US" + // }; - await device.launchApp({newInstance: true, languageAndLocale}); - await element(by.text('Language')).tap(); - await expect(element(by.text(`Current locale: ${languageAndLocale.locale}`))).toBeVisible(); - await expect(element(by.text(`Current language: ${languageAndLocale.language}`))).toBeVisible(); - }); + // await device.launchApp({newInstance: true, languageAndLocale}); + // await element(by.text('Language')).tap(); + // await expect(element(by.text(`Current locale: ${languageAndLocale.locale}`))).toBeVisible(); + // await expect(element(by.text(`Current language: ${languageAndLocale.language}`))).toBeVisible(); + // }); // it('resetContentAndSettings() + install() + relaunch() - should tap successfully', async () => { // await device.resetContentAndSettings(); diff --git a/detox/test/package.json b/detox/test/package.json index eefae07642..4c12976347 100644 --- a/detox/test/package.json +++ b/detox/test/package.json @@ -64,7 +64,7 @@ "binaryPath": "android/app/build/outputs/apk/fromBin/release/app-fromBin-release.apk", "build": "cd android && ./gradlew assembleFromBinRelease assembleFromBinReleaseAndroidTest -DtestBuildType=release && cd ..", "type": "android.emulator", - "name": "Nexus_5X_API_26" + "name": "Pixel_2_XL_API_27" }, "android.emu.debug.fromSource": { "binaryPath": "android/app/build/outputs/apk/fromSource/debug/app-fromSource-debug.apk", From 6b1b4462588eecdf5cc813cb2285fd1e2c3f7b5d Mon Sep 17 00:00:00 2001 From: Luis Naranjo Date: Sun, 9 Sep 2018 14:00:00 -0700 Subject: [PATCH 26/35] add language support to test app for android --- detox/test/package.json | 6 +++--- detox/test/src/Screens/LanguageScreen.js | 16 +++++++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/detox/test/package.json b/detox/test/package.json index 4c12976347..0fc8f378aa 100644 --- a/detox/test/package.json +++ b/detox/test/package.json @@ -8,9 +8,9 @@ "detox-server": "detox run-server", "e2e:ios": "detox test --configuration ios.sim.release --debug-synchronization --take-screenshots all --record-logs all", "e2e:ios-multi": "npm run e2e:ios -- -w 2", - "e2e:android": "detox test --configuration android.emu.release --take-screenshots all --record-logs all", + "e2e:android": "detox test --configuration android.emu.debug --take-screenshots all --record-logs all", "build:ios": "detox build --configuration ios.sim.release", - "build:android": "detox build --configuration android.emu.release", + "build:android": "detox build --configuration android.emu.debug", "verify-artifacts:ios": "jest ./scripts/verify_artifacts_are_not_missing.ios.test.js --testEnvironment node", "verify-artifacts:android": "jest ./scripts/verify_artifacts_are_not_missing.android.test.js --testEnvironment node" }, @@ -58,7 +58,7 @@ "binaryPath": "android/app/build/outputs/apk/fromBin/debug/app-fromBin-debug.apk", "build": "cd android && ./gradlew assembleFromBinDebug assembleFromBinDebugAndroidTest -DtestBuildType=debug && cd ..", "type": "android.emulator", - "name": "Nexus_5X_API_26" + "name": "Pixel_2_XL_API_27" }, "android.emu.release": { "binaryPath": "android/app/build/outputs/apk/fromBin/release/app-fromBin-release.apk", diff --git a/detox/test/src/Screens/LanguageScreen.js b/detox/test/src/Screens/LanguageScreen.js index d8cba4e7c9..3d052aa0ca 100644 --- a/detox/test/src/Screens/LanguageScreen.js +++ b/detox/test/src/Screens/LanguageScreen.js @@ -1,15 +1,25 @@ import React, { Component } from 'react'; -import { Text, View } from 'react-native'; +import { Text, View, Platform } from 'react-native'; import { NativeModules } from 'react-native'; import _ from 'lodash'; export default class LanguageScreen extends Component { render() { + const locale = Platform.select({ + ios: () => NativeModules.SettingsManager.settings.AppleLocale, + android: () => NativeModules.I18nManager.localeIdentifier + })(); + + const language = Platform.select({ + ios: () => _.take(NativeModules.SettingsManager.settings.AppleLanguages, 1), + android: () => 'N/A' + })(); + return ( - Current locale: {NativeModules.SettingsManager.settings.AppleLocale} + Current locale: {locale} - Current language: {_.take(NativeModules.SettingsManager.settings.AppleLanguages, 1)} + Current language: {language} ); From 50b4d3ed58a44931936d14d98f33dc67731aa1d3 Mon Sep 17 00:00:00 2001 From: Luis Naranjo Date: Sun, 9 Sep 2018 15:20:10 -0700 Subject: [PATCH 27/35] Revert "add language support to test app for android" This reverts commit 6b1b4462588eecdf5cc813cb2285fd1e2c3f7b5d. --- detox/test/package.json | 6 +++--- detox/test/src/Screens/LanguageScreen.js | 16 +++------------- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/detox/test/package.json b/detox/test/package.json index 0fc8f378aa..4c12976347 100644 --- a/detox/test/package.json +++ b/detox/test/package.json @@ -8,9 +8,9 @@ "detox-server": "detox run-server", "e2e:ios": "detox test --configuration ios.sim.release --debug-synchronization --take-screenshots all --record-logs all", "e2e:ios-multi": "npm run e2e:ios -- -w 2", - "e2e:android": "detox test --configuration android.emu.debug --take-screenshots all --record-logs all", + "e2e:android": "detox test --configuration android.emu.release --take-screenshots all --record-logs all", "build:ios": "detox build --configuration ios.sim.release", - "build:android": "detox build --configuration android.emu.debug", + "build:android": "detox build --configuration android.emu.release", "verify-artifacts:ios": "jest ./scripts/verify_artifacts_are_not_missing.ios.test.js --testEnvironment node", "verify-artifacts:android": "jest ./scripts/verify_artifacts_are_not_missing.android.test.js --testEnvironment node" }, @@ -58,7 +58,7 @@ "binaryPath": "android/app/build/outputs/apk/fromBin/debug/app-fromBin-debug.apk", "build": "cd android && ./gradlew assembleFromBinDebug assembleFromBinDebugAndroidTest -DtestBuildType=debug && cd ..", "type": "android.emulator", - "name": "Pixel_2_XL_API_27" + "name": "Nexus_5X_API_26" }, "android.emu.release": { "binaryPath": "android/app/build/outputs/apk/fromBin/release/app-fromBin-release.apk", diff --git a/detox/test/src/Screens/LanguageScreen.js b/detox/test/src/Screens/LanguageScreen.js index 3d052aa0ca..d8cba4e7c9 100644 --- a/detox/test/src/Screens/LanguageScreen.js +++ b/detox/test/src/Screens/LanguageScreen.js @@ -1,25 +1,15 @@ import React, { Component } from 'react'; -import { Text, View, Platform } from 'react-native'; +import { Text, View } from 'react-native'; import { NativeModules } from 'react-native'; import _ from 'lodash'; export default class LanguageScreen extends Component { render() { - const locale = Platform.select({ - ios: () => NativeModules.SettingsManager.settings.AppleLocale, - android: () => NativeModules.I18nManager.localeIdentifier - })(); - - const language = Platform.select({ - ios: () => _.take(NativeModules.SettingsManager.settings.AppleLanguages, 1), - android: () => 'N/A' - })(); - return ( - Current locale: {locale} + Current locale: {NativeModules.SettingsManager.settings.AppleLocale} - Current language: {language} + Current language: {_.take(NativeModules.SettingsManager.settings.AppleLanguages, 1)} ); From d5d4955f90e24b5a791b2a5202450312110d97b8 Mon Sep 17 00:00:00 2001 From: Luis Naranjo Date: Sun, 9 Sep 2018 15:26:09 -0700 Subject: [PATCH 28/35] add android support to language screen --- detox/test/src/Screens/LanguageScreen.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/detox/test/src/Screens/LanguageScreen.js b/detox/test/src/Screens/LanguageScreen.js index d8cba4e7c9..88e6256d2c 100644 --- a/detox/test/src/Screens/LanguageScreen.js +++ b/detox/test/src/Screens/LanguageScreen.js @@ -1,15 +1,25 @@ import React, { Component } from 'react'; -import { Text, View } from 'react-native'; -import { NativeModules } from 'react-native'; +import { Text, View, NativeModules, Platform } from 'react-native'; import _ from 'lodash'; export default class LanguageScreen extends Component { render() { + + const locale = Platform.select({ + ios: () => NativeModules.SettingsManager.settings.AppleLocale, + android: () => NativeModules.I18nManager.localeIdentifier + })(); + + const language = Platform.select({ + ios: () => _.take(NativeModules.SettingsManager.settings.AppleLanguages, 1), + android: () => 'Unavailable' + })(); + return ( - Current locale: {NativeModules.SettingsManager.settings.AppleLocale} + Current locale: {locale} - Current language: {_.take(NativeModules.SettingsManager.settings.AppleLanguages, 1)} + Current language: {language} ); From df7967fc6818bad3c73c0b4b88c6c8559c559bff Mon Sep 17 00:00:00 2001 From: Luis Naranjo Date: Sun, 9 Sep 2018 15:32:13 -0700 Subject: [PATCH 29/35] update android API --- detox/src/devices/drivers/AndroidDriver.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/detox/src/devices/drivers/AndroidDriver.js b/detox/src/devices/drivers/AndroidDriver.js index 9a7fd05318..dffd720161 100644 --- a/detox/src/devices/drivers/AndroidDriver.js +++ b/detox/src/devices/drivers/AndroidDriver.js @@ -86,7 +86,7 @@ class AndroidDriver extends DeviceDriverBase { } } - async launchApp(deviceId, bundleId, launchArgs) { + async launchApp(deviceId, bundleId, launchArgs, languageAndLocale) { await this.emitter.emit('beforeLaunchApp', { deviceId, bundleId, launchArgs }); if (!this.instrumentationProcess) { From 3768a3478b74e57adfb6c43274921dfbd50cb838 Mon Sep 17 00:00:00 2001 From: Luis Naranjo Date: Sun, 9 Sep 2018 15:33:34 -0700 Subject: [PATCH 30/35] Revert "temp switch emulator" This reverts commit 971fb09ca5e6e86623848c87dc99aa6a11a95392. --- detox/test/e2e/06.device.test.js | 52 ++++++++++++++++---------------- detox/test/package.json | 2 +- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/detox/test/e2e/06.device.test.js b/detox/test/e2e/06.device.test.js index 0468011eb3..c74404c644 100644 --- a/detox/test/e2e/06.device.test.js +++ b/detox/test/e2e/06.device.test.js @@ -29,37 +29,37 @@ describe('Device', () => { // await expect(element(by.text('Hello!!!'))).toBeVisible(); // }); - it('launchApp({newInstance: true}) + sendToHome() + launchApp() - should bring up previous instance', async () => { - await device.launchApp({newInstance: true}); - await element(by.text('Sanity')).tap(); - await element(by.text('Say Hello')).tap(); - await device.sendToHome(); - await device.launchApp(); + // it('launchApp({newInstance: true}) + sendToHome() + launchApp() - should bring up previous instance', async () => { + // await device.launchApp({newInstance: true}); + // await element(by.text('Sanity')).tap(); + // await element(by.text('Say Hello')).tap(); + // await device.sendToHome(); + // await device.launchApp(); - await expect(element(by.text('Hello!!!'))).toBeVisible(); - }); + // await expect(element(by.text('Hello!!!'))).toBeVisible(); + // }); - // it('launchApp in a different language', async () => { - // let languageAndLocale = { - // language: "es-MX", - // locale: "es-MX" - // }; + it('launchApp in a different language', async () => { + let languageAndLocale = { + language: "es-MX", + locale: "es-MX" + }; - // await device.launchApp({newInstance: true, languageAndLocale}); - // await element(by.text('Language')).tap(); - // await expect(element(by.text(`Current locale: ${languageAndLocale.locale}`))).toBeVisible(); - // await expect(element(by.text(`Current language: ${languageAndLocale.language}`))).toBeVisible(); + await device.launchApp({newInstance: true, languageAndLocale}); + await element(by.text('Language')).tap(); + await expect(element(by.text(`Current locale: ${languageAndLocale.locale}`))).toBeVisible(); + await expect(element(by.text(`Current language: ${languageAndLocale.language}`))).toBeVisible(); - // languageAndLocale = { - // language: "en-US", - // locale: "en-US" - // }; + languageAndLocale = { + language: "en-US", + locale: "en-US" + }; - // await device.launchApp({newInstance: true, languageAndLocale}); - // await element(by.text('Language')).tap(); - // await expect(element(by.text(`Current locale: ${languageAndLocale.locale}`))).toBeVisible(); - // await expect(element(by.text(`Current language: ${languageAndLocale.language}`))).toBeVisible(); - // }); + await device.launchApp({newInstance: true, languageAndLocale}); + await element(by.text('Language')).tap(); + await expect(element(by.text(`Current locale: ${languageAndLocale.locale}`))).toBeVisible(); + await expect(element(by.text(`Current language: ${languageAndLocale.language}`))).toBeVisible(); + }); // it('resetContentAndSettings() + install() + relaunch() - should tap successfully', async () => { // await device.resetContentAndSettings(); diff --git a/detox/test/package.json b/detox/test/package.json index 4c12976347..eefae07642 100644 --- a/detox/test/package.json +++ b/detox/test/package.json @@ -64,7 +64,7 @@ "binaryPath": "android/app/build/outputs/apk/fromBin/release/app-fromBin-release.apk", "build": "cd android && ./gradlew assembleFromBinRelease assembleFromBinReleaseAndroidTest -DtestBuildType=release && cd ..", "type": "android.emulator", - "name": "Pixel_2_XL_API_27" + "name": "Nexus_5X_API_26" }, "android.emu.debug.fromSource": { "binaryPath": "android/app/build/outputs/apk/fromSource/debug/app-fromSource-debug.apk", From 85a2ccdfc9528f86bc1456b04930b0d4d92f44b8 Mon Sep 17 00:00:00 2001 From: Luis Naranjo Date: Sun, 9 Sep 2018 15:34:04 -0700 Subject: [PATCH 31/35] Revert "temp use iphone 6" This reverts commit c11308d9d9ca6db4e0d4f44b94067ced7502cb0f. --- detox/test/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/detox/test/package.json b/detox/test/package.json index eefae07642..dfe4e4afeb 100644 --- a/detox/test/package.json +++ b/detox/test/package.json @@ -37,13 +37,13 @@ "binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/example.app", "build": "set -o pipefail && xcodebuild -project ios/example.xcodeproj -scheme example_ci -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build | xcpretty", "type": "ios.simulator", - "name": "iPhone 6" + "name": "iPhone X" }, "ios.sim.release": { "binaryPath": "ios/build/Build/Products/Release-iphonesimulator/example.app", "build": "set -o pipefail && export CODE_SIGNING_REQUIRED=NO && export RCT_NO_LAUNCH_PACKAGER=true && xcodebuild -project ios/example.xcodeproj -scheme example_ci -configuration Release -sdk iphonesimulator -derivedDataPath ios/build | xcpretty", "type": "ios.simulator", - "name": "iPhone 6" + "name": "iPhone X" }, "ios.none": { "binaryPath": "ios", From 168e42e9300db68d506b6c5bfdc88ee4442e1ff1 Mon Sep 17 00:00:00 2001 From: Luis Naranjo Date: Sun, 9 Sep 2018 15:34:12 -0700 Subject: [PATCH 32/35] Revert "temp rename unneeded test files" This reverts commit 9de21e5f453302efeeffabf4edefffd50de0ad9a. --- detox/test/e2e/{01.sanity.js => 01.sanity.test.js} | 0 detox/test/e2e/{02.matchers.js => 02.matchers.test.js} | 0 detox/test/e2e/{03.actions.js => 03.actions.test.js} | 0 detox/test/e2e/{04.assertions.js => 04.assertions.test.js} | 0 detox/test/e2e/{05.waitfor.js => 05.waitfor.test.js} | 0 .../{06.device-orientation.js => 06.device-orientation.test.js} | 0 detox/test/e2e/{07.stress-tests.js => 07.stress-tests.test.js} | 0 detox/test/e2e/{08.stress-root.js => 08.stress-root.test.js} | 0 .../e2e/{09.stress-timeouts.js => 09.stress-timeouts.test.js} | 0 .../{10.async-and-callbacks.js => 10.async-and-callbacks.test.js} | 0 .../{11.user-notifications.js => 11.user-notifications.test.js} | 0 detox/test/e2e/{12.animations.js => 12.animations.test.js} | 0 detox/test/e2e/{13.permissions.js => 13.permissions.test.js} | 0 detox/test/e2e/{14.network.js => 14.network.test.js} | 0 detox/test/e2e/{15.urls.js => 15.urls.test.js} | 0 detox/test/e2e/{16.location.js => 16.location.test.js} | 0 detox/test/e2e/{17.datePicker.js => 17.datePicker.test.js} | 0 .../e2e/{18.user-activities.js => 18.user-activities.test.js} | 0 .../test/e2e/{19.crash-handling.js => 19.crash-handling.test.js} | 0 19 files changed, 0 insertions(+), 0 deletions(-) rename detox/test/e2e/{01.sanity.js => 01.sanity.test.js} (100%) rename detox/test/e2e/{02.matchers.js => 02.matchers.test.js} (100%) rename detox/test/e2e/{03.actions.js => 03.actions.test.js} (100%) rename detox/test/e2e/{04.assertions.js => 04.assertions.test.js} (100%) rename detox/test/e2e/{05.waitfor.js => 05.waitfor.test.js} (100%) rename detox/test/e2e/{06.device-orientation.js => 06.device-orientation.test.js} (100%) rename detox/test/e2e/{07.stress-tests.js => 07.stress-tests.test.js} (100%) rename detox/test/e2e/{08.stress-root.js => 08.stress-root.test.js} (100%) rename detox/test/e2e/{09.stress-timeouts.js => 09.stress-timeouts.test.js} (100%) rename detox/test/e2e/{10.async-and-callbacks.js => 10.async-and-callbacks.test.js} (100%) rename detox/test/e2e/{11.user-notifications.js => 11.user-notifications.test.js} (100%) rename detox/test/e2e/{12.animations.js => 12.animations.test.js} (100%) rename detox/test/e2e/{13.permissions.js => 13.permissions.test.js} (100%) rename detox/test/e2e/{14.network.js => 14.network.test.js} (100%) rename detox/test/e2e/{15.urls.js => 15.urls.test.js} (100%) rename detox/test/e2e/{16.location.js => 16.location.test.js} (100%) rename detox/test/e2e/{17.datePicker.js => 17.datePicker.test.js} (100%) rename detox/test/e2e/{18.user-activities.js => 18.user-activities.test.js} (100%) rename detox/test/e2e/{19.crash-handling.js => 19.crash-handling.test.js} (100%) diff --git a/detox/test/e2e/01.sanity.js b/detox/test/e2e/01.sanity.test.js similarity index 100% rename from detox/test/e2e/01.sanity.js rename to detox/test/e2e/01.sanity.test.js diff --git a/detox/test/e2e/02.matchers.js b/detox/test/e2e/02.matchers.test.js similarity index 100% rename from detox/test/e2e/02.matchers.js rename to detox/test/e2e/02.matchers.test.js diff --git a/detox/test/e2e/03.actions.js b/detox/test/e2e/03.actions.test.js similarity index 100% rename from detox/test/e2e/03.actions.js rename to detox/test/e2e/03.actions.test.js diff --git a/detox/test/e2e/04.assertions.js b/detox/test/e2e/04.assertions.test.js similarity index 100% rename from detox/test/e2e/04.assertions.js rename to detox/test/e2e/04.assertions.test.js diff --git a/detox/test/e2e/05.waitfor.js b/detox/test/e2e/05.waitfor.test.js similarity index 100% rename from detox/test/e2e/05.waitfor.js rename to detox/test/e2e/05.waitfor.test.js diff --git a/detox/test/e2e/06.device-orientation.js b/detox/test/e2e/06.device-orientation.test.js similarity index 100% rename from detox/test/e2e/06.device-orientation.js rename to detox/test/e2e/06.device-orientation.test.js diff --git a/detox/test/e2e/07.stress-tests.js b/detox/test/e2e/07.stress-tests.test.js similarity index 100% rename from detox/test/e2e/07.stress-tests.js rename to detox/test/e2e/07.stress-tests.test.js diff --git a/detox/test/e2e/08.stress-root.js b/detox/test/e2e/08.stress-root.test.js similarity index 100% rename from detox/test/e2e/08.stress-root.js rename to detox/test/e2e/08.stress-root.test.js diff --git a/detox/test/e2e/09.stress-timeouts.js b/detox/test/e2e/09.stress-timeouts.test.js similarity index 100% rename from detox/test/e2e/09.stress-timeouts.js rename to detox/test/e2e/09.stress-timeouts.test.js diff --git a/detox/test/e2e/10.async-and-callbacks.js b/detox/test/e2e/10.async-and-callbacks.test.js similarity index 100% rename from detox/test/e2e/10.async-and-callbacks.js rename to detox/test/e2e/10.async-and-callbacks.test.js diff --git a/detox/test/e2e/11.user-notifications.js b/detox/test/e2e/11.user-notifications.test.js similarity index 100% rename from detox/test/e2e/11.user-notifications.js rename to detox/test/e2e/11.user-notifications.test.js diff --git a/detox/test/e2e/12.animations.js b/detox/test/e2e/12.animations.test.js similarity index 100% rename from detox/test/e2e/12.animations.js rename to detox/test/e2e/12.animations.test.js diff --git a/detox/test/e2e/13.permissions.js b/detox/test/e2e/13.permissions.test.js similarity index 100% rename from detox/test/e2e/13.permissions.js rename to detox/test/e2e/13.permissions.test.js diff --git a/detox/test/e2e/14.network.js b/detox/test/e2e/14.network.test.js similarity index 100% rename from detox/test/e2e/14.network.js rename to detox/test/e2e/14.network.test.js diff --git a/detox/test/e2e/15.urls.js b/detox/test/e2e/15.urls.test.js similarity index 100% rename from detox/test/e2e/15.urls.js rename to detox/test/e2e/15.urls.test.js diff --git a/detox/test/e2e/16.location.js b/detox/test/e2e/16.location.test.js similarity index 100% rename from detox/test/e2e/16.location.js rename to detox/test/e2e/16.location.test.js diff --git a/detox/test/e2e/17.datePicker.js b/detox/test/e2e/17.datePicker.test.js similarity index 100% rename from detox/test/e2e/17.datePicker.js rename to detox/test/e2e/17.datePicker.test.js diff --git a/detox/test/e2e/18.user-activities.js b/detox/test/e2e/18.user-activities.test.js similarity index 100% rename from detox/test/e2e/18.user-activities.js rename to detox/test/e2e/18.user-activities.test.js diff --git a/detox/test/e2e/19.crash-handling.js b/detox/test/e2e/19.crash-handling.test.js similarity index 100% rename from detox/test/e2e/19.crash-handling.js rename to detox/test/e2e/19.crash-handling.test.js From 4691118c5a5ed1c13be995bc9e2e6d073684f397 Mon Sep 17 00:00:00 2001 From: Luis Naranjo Date: Sun, 9 Sep 2018 15:52:29 -0700 Subject: [PATCH 33/35] uncomment some tests --- detox/test/e2e/06.device.test.js | 116 +++++++++++++++---------------- 1 file changed, 58 insertions(+), 58 deletions(-) diff --git a/detox/test/e2e/06.device.test.js b/detox/test/e2e/06.device.test.js index c74404c644..70a7a874ae 100644 --- a/detox/test/e2e/06.device.test.js +++ b/detox/test/e2e/06.device.test.js @@ -1,43 +1,43 @@ describe('Device', () => { - // it('reloadReactNative - should tap successfully', async () => { - // await device.reloadReactNative(); - // await element(by.text('Sanity')).tap(); - // await element(by.text('Say Hello')).tap(); - // await expect(element(by.text('Hello!!!'))).toBeVisible(); - // }); + it('reloadReactNative - should tap successfully', async () => { + await device.reloadReactNative(); + await element(by.text('Sanity')).tap(); + await element(by.text('Say Hello')).tap(); + await expect(element(by.text('Hello!!!'))).toBeVisible(); + }); - // it('relaunchApp - should tap successfully', async () => { - // await device.relaunchApp(); - // await element(by.text('Sanity')).tap(); - // await element(by.text('Say Hello')).tap(); - // await expect(element(by.text('Hello!!!'))).toBeVisible(); - // }); + it('relaunchApp - should tap successfully', async () => { + await device.relaunchApp(); + await element(by.text('Sanity')).tap(); + await element(by.text('Say Hello')).tap(); + await expect(element(by.text('Hello!!!'))).toBeVisible(); + }); - // it('relaunchApp({delete: true}) - should tap successfully', async () => { - // await device.relaunchApp({delete: true}); - // await element(by.text('Sanity')).tap(); - // await element(by.text('Say Hello')).tap(); - // await expect(element(by.text('Hello!!!'))).toBeVisible(); - // }); + it('relaunchApp({delete: true}) - should tap successfully', async () => { + await device.relaunchApp({delete: true}); + await element(by.text('Sanity')).tap(); + await element(by.text('Say Hello')).tap(); + await expect(element(by.text('Hello!!!'))).toBeVisible(); + }); - // it('uninstall() + install() + relaunch() - should tap successfully', async () => { - // await device.uninstallApp(); - // await device.installApp(); - // await device.relaunchApp(); - // await element(by.text('Sanity')).tap(); - // await element(by.text('Say Hello')).tap(); - // await expect(element(by.text('Hello!!!'))).toBeVisible(); - // }); + it('uninstall() + install() + relaunch() - should tap successfully', async () => { + await device.uninstallApp(); + await device.installApp(); + await device.relaunchApp(); + await element(by.text('Sanity')).tap(); + await element(by.text('Say Hello')).tap(); + await expect(element(by.text('Hello!!!'))).toBeVisible(); + }); - // it('launchApp({newInstance: true}) + sendToHome() + launchApp() - should bring up previous instance', async () => { - // await device.launchApp({newInstance: true}); - // await element(by.text('Sanity')).tap(); - // await element(by.text('Say Hello')).tap(); - // await device.sendToHome(); - // await device.launchApp(); + it('launchApp({newInstance: true}) + sendToHome() + launchApp() - should bring up previous instance', async () => { + await device.launchApp({newInstance: true}); + await element(by.text('Sanity')).tap(); + await element(by.text('Say Hello')).tap(); + await device.sendToHome(); + await device.launchApp(); - // await expect(element(by.text('Hello!!!'))).toBeVisible(); - // }); + await expect(element(by.text('Hello!!!'))).toBeVisible(); + }); it('launchApp in a different language', async () => { let languageAndLocale = { @@ -61,32 +61,32 @@ describe('Device', () => { await expect(element(by.text(`Current language: ${languageAndLocale.language}`))).toBeVisible(); }); - // it('resetContentAndSettings() + install() + relaunch() - should tap successfully', async () => { - // await device.resetContentAndSettings(); - // await device.installApp(); - // await device.launchApp({ newInstance: true }); - // await element(by.text('Sanity')).tap(); - // await element(by.text('Say Hello')).tap(); - // await expect(element(by.text('Hello!!!'))).toBeVisible(); - // }); + it('resetContentAndSettings() + install() + relaunch() - should tap successfully', async () => { + await device.resetContentAndSettings(); + await device.installApp(); + await device.launchApp({ newInstance: true }); + await element(by.text('Sanity')).tap(); + await element(by.text('Say Hello')).tap(); + await expect(element(by.text('Hello!!!'))).toBeVisible(); + }); - // it(':ios: shake() should shake screen', async () => { - // await device.reloadReactNative(); - // await element(by.text('Shake')).tap(); - // await device.shake(); - // await expect(element(by.text('Shaken, not stirred'))).toBeVisible(); - // }); + it(':ios: shake() should shake screen', async () => { + await device.reloadReactNative(); + await element(by.text('Shake')).tap(); + await device.shake(); + await expect(element(by.text('Shaken, not stirred'))).toBeVisible(); + }); - // describe(':android: device back button', () => { - // beforeEach(async() => { - // await device.reloadReactNative(); - // await element(by.text('Actions')).tap(); - // }); + describe(':android: device back button', () => { + beforeEach(async() => { + await device.reloadReactNative(); + await element(by.text('Actions')).tap(); + }); - // it(':android: should show popup back pressed when back button is pressed', async () => { - // await device.pressBack(); - // await expect(element(by.text('Back pressed !'))).toBeVisible(); - // }); - // }); + it(':android: should show popup back pressed when back button is pressed', async () => { + await device.pressBack(); + await expect(element(by.text('Back pressed !'))).toBeVisible(); + }); + }); }); From f7f8e2f0652b9d72a7a29bc4a259b49f9715fb24 Mon Sep 17 00:00:00 2001 From: Luis Naranjo Date: Sun, 9 Sep 2018 15:54:12 -0700 Subject: [PATCH 34/35] comment out the not cross-plat test --- detox/test/e2e/06.device.test.js | 37 ++++++++++++++++---------------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/detox/test/e2e/06.device.test.js b/detox/test/e2e/06.device.test.js index 70a7a874ae..4d189049ee 100644 --- a/detox/test/e2e/06.device.test.js +++ b/detox/test/e2e/06.device.test.js @@ -39,27 +39,28 @@ describe('Device', () => { await expect(element(by.text('Hello!!!'))).toBeVisible(); }); - it('launchApp in a different language', async () => { - let languageAndLocale = { - language: "es-MX", - locale: "es-MX" - }; + // // Passing on iOS, not implemented on Android + // it('launchApp in a different language', async () => { + // let languageAndLocale = { + // language: "es-MX", + // locale: "es-MX" + // }; - await device.launchApp({newInstance: true, languageAndLocale}); - await element(by.text('Language')).tap(); - await expect(element(by.text(`Current locale: ${languageAndLocale.locale}`))).toBeVisible(); - await expect(element(by.text(`Current language: ${languageAndLocale.language}`))).toBeVisible(); + // await device.launchApp({newInstance: true, languageAndLocale}); + // await element(by.text('Language')).tap(); + // await expect(element(by.text(`Current locale: ${languageAndLocale.locale}`))).toBeVisible(); + // await expect(element(by.text(`Current language: ${languageAndLocale.language}`))).toBeVisible(); - languageAndLocale = { - language: "en-US", - locale: "en-US" - }; + // languageAndLocale = { + // language: "en-US", + // locale: "en-US" + // }; - await device.launchApp({newInstance: true, languageAndLocale}); - await element(by.text('Language')).tap(); - await expect(element(by.text(`Current locale: ${languageAndLocale.locale}`))).toBeVisible(); - await expect(element(by.text(`Current language: ${languageAndLocale.language}`))).toBeVisible(); - }); + // await device.launchApp({newInstance: true, languageAndLocale}); + // await element(by.text('Language')).tap(); + // await expect(element(by.text(`Current locale: ${languageAndLocale.locale}`))).toBeVisible(); + // await expect(element(by.text(`Current language: ${languageAndLocale.language}`))).toBeVisible(); + // }); it('resetContentAndSettings() + install() + relaunch() - should tap successfully', async () => { await device.resetContentAndSettings(); From 7c7596d30a8b78e819fe4cf53fc706d7aa896142 Mon Sep 17 00:00:00 2001 From: Luis Naranjo Date: Fri, 28 Sep 2018 13:38:11 -0700 Subject: [PATCH 35/35] update docs --- docs/APIRef.DeviceObjectAPI.md | 42 ++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/docs/APIRef.DeviceObjectAPI.md b/docs/APIRef.DeviceObjectAPI.md index 6396bae06f..509393bdfe 100644 --- a/docs/APIRef.DeviceObjectAPI.md +++ b/docs/APIRef.DeviceObjectAPI.md @@ -135,6 +135,48 @@ Disable touch indicators on iOS. await device.launchApp({disableTouchIndicators: true}); ``` +##### 9. Launch with a specific language (iOS only) +Launch the app with a specific system language + +Information about accepted values can be found [here](https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPInternational/LanguageandLocaleIDs/LanguageandLocaleIDs.html). + +```js +await device.launchApp({ + languageAndLocale: { + language: "es-MX", + locale: "es-MX" + } +}); +``` + +With this API, you can run sets of e2e tests per language. For example: +```js +['es-MX', 'fr-FR', 'pt-BR'].forEach(locale => { + describe(`Test suite in ${locale}`, () => { + + beforeAll(async () => { + await device.launchApp({ + newInstance: true, + languageAndLocale: { + language: locale, + locale + } + }); + }); + + + it('Test A', () => { + + }) + + it('Test B', () => { + + }) + + }); +}); +``` + ### `device.relaunchApp(params)` **Deprecated** Use `device.launchApp(params)` instead. This method is now calling `launchApp({newInstance: true})` for backwards compatibility, it will be removed in Detox 6.X.X.
Kill and relaunch the app defined in the current [`configuration`](APIRef.Configuration.md).