Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for disabling touch indicators with launch args #899

Merged
merged 3 commits into from
Aug 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion detox/ios/Detox/DetoxAppDelegateProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ - (UIWindow *)overlayWindow

static DTXTouchVisualizerWindow* _touchVisualizerWindow;

static BOOL _disableTouchIndicator;

static NSURL* _launchUserNotificationDataURL()
{
NSString* userNotificationDataPath = [[NSUserDefaults standardUserDefaults] objectForKey:@"detoxUserNotificationDataURL"];
Expand Down Expand Up @@ -138,6 +140,8 @@ + (void)load
dispatch_once(&onceToken, ^{
_pendingOpenURLs = [NSMutableArray new];
_pendingUserNotificationDispatchers = [NSMutableArray new];

_disableTouchIndicator = [NSUserDefaults.standardUserDefaults boolForKey:@"detoxDisableTouchIndicators"];

NSURL* url;

Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions detox/src/devices/Device.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
9 changes: 9 additions & 0 deletions detox/src/devices/Device.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 7 additions & 0 deletions docs/APIRef.DeviceObjectAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.<Br>
Kill and relaunch the app defined in the current [`configuration`](APIRef.Configuration.md).
Expand Down