Skip to content

Commit f5e9d2c

Browse files
committed
fix: synthesize iOS swipe gestures
1 parent 110cdde commit f5e9d2c

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

src/platforms/ios/__tests__/index.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ for (const [name, device] of [
252252
});
253253
}
254254

255-
test('iosRunnerOverrides maps swipe to XCTest iOS drag duration', async () => {
255+
test('iosRunnerOverrides maps iOS swipe duration to synthesized drag', async () => {
256256
mockRunIosRunnerCommand.mockResolvedValue({});
257257

258258
const { overrides } = iosRunnerOverrides(IOS_TEST_SIMULATOR, {
@@ -270,6 +270,7 @@ test('iosRunnerOverrides maps swipe to XCTest iOS drag duration', async () => {
270270
x2: 180,
271271
y2: 200,
272272
durationMs: 300,
273+
synthesized: true,
273274
appBundleId: 'com.example.App',
274275
});
275276
assert.deepEqual(mockRunIosRunnerCommand.mock.calls[1]?.[1], {
@@ -279,6 +280,7 @@ test('iosRunnerOverrides maps swipe to XCTest iOS drag duration', async () => {
279280
x2: 180,
280281
y2: 200,
281282
durationMs: 250,
283+
synthesized: true,
282284
appBundleId: 'com.example.App',
283285
});
284286
assert.deepEqual(mockRunIosRunnerCommand.mock.calls[2]?.[1], {

src/platforms/ios/interactions.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ type NormalizedScrollOptions = {
2929
preferProvidedPixels?: boolean;
3030
};
3131

32+
type IosDragCommandOptions = {
33+
defaultDurationMs: number;
34+
legacyDefaultDurationMs?: number;
35+
synthesized?: boolean;
36+
};
37+
3238
type IosRunnerOverrides = Pick<
3339
Interactor,
3440
| 'tap'
@@ -101,6 +107,7 @@ export function iosRunnerOverrides(
101107
device,
102108
iosDragCommand(device, ctx, x1, y1, x2, y2, durationMs, {
103109
defaultDurationMs: IOS_SWIPE_DEFAULT_DURATION_MS,
110+
synthesized: device.platform === 'ios' && device.target !== 'tv',
104111
}),
105112
runnerOpts,
106113
);
@@ -265,10 +272,7 @@ function iosDragCommand(
265272
x2: number,
266273
y2: number,
267274
durationMs: number | undefined,
268-
options: {
269-
defaultDurationMs: number;
270-
legacyDefaultDurationMs?: number;
271-
},
275+
options: IosDragCommandOptions,
272276
): RunnerCommand {
273277
const normalizedDurationMs =
274278
device.platform === 'ios' && device.target !== 'tv'
@@ -281,6 +285,7 @@ function iosDragCommand(
281285
x2,
282286
y2,
283287
...(normalizedDurationMs !== undefined ? { durationMs: normalizedDurationMs } : {}),
288+
...(options.synthesized === true ? { synthesized: true } : {}),
284289
appBundleId: ctx.appBundleId,
285290
};
286291
}

0 commit comments

Comments
 (0)