diff --git a/detox/ios/Detox/DetoxAppDelegateProxy.m b/detox/ios/Detox/DetoxAppDelegateProxy.m index 47cdb44cb8..90078db830 100644 --- a/detox/ios/Detox/DetoxAppDelegateProxy.m +++ b/detox/ios/Detox/DetoxAppDelegateProxy.m @@ -38,6 +38,8 @@ - (UIWindow *)overlayWindow static DTXTouchVisualizerWindow* _touchVisualizerWindow; +static BOOL _disableTouchIndicator; + static NSURL* _launchUserNotificationDataURL() { NSString* userNotificationDataPath = [[NSUserDefaults standardUserDefaults] objectForKey:@"detoxUserNotificationDataURL"]; @@ -138,6 +140,8 @@ + (void)load dispatch_once(&onceToken, ^{ _pendingOpenURLs = [NSMutableArray new]; _pendingUserNotificationDispatchers = [NSMutableArray new]; + + _disableTouchIndicator = [NSUserDefaults.standardUserDefaults boolForKey:@"detoxDisableTouchIndicators"]; NSURL* url; @@ -335,7 +339,7 @@ - (void)applicationWillEnterForeground:(UIApplication *)application - (BOOL)touchVisualizerWindowShouldAlwaysShowFingertip:(COSTouchVisualizerWindow *)window { - return YES; + return _disableTouchIndicator == NO; } #if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_10_3 diff --git a/detox/src/devices/Device.js b/detox/src/devices/Device.js index 26168b257d..825afff155 100644 --- a/detox/src/devices/Device.js +++ b/detox/src/devices/Device.js @@ -72,6 +72,10 @@ class Device { await this.deviceDriver.setPermissions(this._deviceId, this._bundleId, params.permissions); } + if (params.disableTouchIndicators) { + baseLaunchArgs['detoxDisableTouchIndicators'] = true; + } + const _bundleId = bundleId || this._bundleId; if (this._isAppInBackground(params, _bundleId)) { if (hasPayload) { diff --git a/detox/src/devices/Device.test.js b/detox/src/devices/Device.test.js index 0326317ece..f5b754cedd 100644 --- a/detox/src/devices/Device.test.js +++ b/detox/src/devices/Device.test.js @@ -182,6 +182,15 @@ describe('Device', () => { }); }); + it(`launchApp() with disableTouchIndicators should send a boolean switch as a param in launchParams`, async () => { + device = await validDevice(); + await device.launchApp({disableTouchIndicators: true}); + + expect(device.deviceDriver.launchApp).toHaveBeenCalledWith(device._deviceId, + device._bundleId, + {"-detoxServer": "ws://localhost:8099", "-detoxSessionId": "test", "-detoxDisableTouchIndicators": true}); + }); + it(`relaunchApp() with userNofitication should send the userNotification as a param in launchParams`, async () => { device = validDevice(); fs.existsSync.mockReturnValue(true); diff --git a/docs/APIRef.DeviceObjectAPI.md b/docs/APIRef.DeviceObjectAPI.md index a93080bdbd..94dafa2894 100644 --- a/docs/APIRef.DeviceObjectAPI.md +++ b/docs/APIRef.DeviceObjectAPI.md @@ -128,6 +128,13 @@ await device.launchApp({launchArgs: {arg1: 1, arg2: "2"}}); The added `launchArgs` will be passed through the launch command to the device and be accessible via `[[NSProcessInfo processInfo] arguments]` +##### 8. Disable touch indicators (iOS only) +Disable touch indicators on iOS. + +```js +await device.launchApp({disableTouchIndicators: true}); +``` + ### `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).