Skip to content

Commit aa02305

Browse files
committed
Fix selector tap coordinate mapping
1 parent 74874d5 commit aa02305

8 files changed

Lines changed: 216 additions & 42 deletions

File tree

cli/DFPrivateSimulatorDisplayBridge.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ NS_SWIFT_NAME(PrivateSimulatorDisplayBridge)
3737
@property (nonatomic, weak, nullable) id<DFPrivateSimulatorDisplayBridgeDelegate> delegate;
3838
@property (nonatomic, readonly, getter=isDisplayReady) BOOL displayReady;
3939
@property (nonatomic, readonly) NSString *displayStatus;
40+
@property (nonatomic, readonly) CGSize displaySize;
4041

4142
- (nullable CVPixelBufferRef)copyPixelBuffer CF_RETURNS_RETAINED;
4243

cli/DFPrivateSimulatorDisplayBridge.m

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2989,6 +2989,21 @@ - (NSString *)displayStatus {
29892989
return status;
29902990
}
29912991

2992+
- (CGSize)displaySize {
2993+
__block CGSize size = CGSizeZero;
2994+
dispatch_block_t work = ^{
2995+
size = self->_displayPixelSize;
2996+
};
2997+
2998+
if (dispatch_get_specific(DFPrivateSimulatorCallbackQueueKey) != NULL) {
2999+
work();
3000+
} else {
3001+
dispatch_sync(_callbackQueue, work);
3002+
}
3003+
3004+
return size;
3005+
}
3006+
29923007
- (BOOL)sendTouchAtNormalizedX:(double)normalizedX
29933008
normalizedY:(double)normalizedY
29943009
phase:(DFPrivateSimulatorTouchPhase)phase

cli/native/XCWNativeBridge.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ char * _Nullable xcw_native_get_pasteboard_text(const char * _Nonnull udid, char
5959

6060
void * _Nullable xcw_native_input_create(const char * _Nonnull udid, char * _Nullable * _Nullable error_message);
6161
void xcw_native_input_destroy(void * _Nullable handle);
62+
bool xcw_native_input_display_size(void * _Nonnull handle, double * _Nullable width, double * _Nullable height);
6263
bool xcw_native_input_send_touch(void * _Nonnull handle, double x, double y, const char * _Nonnull phase, char * _Nullable * _Nullable error_message);
6364
bool xcw_native_input_send_multitouch(void * _Nonnull handle, double x1, double y1, double x2, double y2, const char * _Nonnull phase, char * _Nullable * _Nullable error_message);
6465

cli/native/XCWNativeBridge.m

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,22 @@ void xcw_native_input_destroy(void *handle) {
325325
}
326326
}
327327

328+
bool xcw_native_input_display_size(void *handle, double *width, double *height) {
329+
@autoreleasepool {
330+
if (handle == NULL) {
331+
return false;
332+
}
333+
CGSize size = [(__bridge DFPrivateSimulatorDisplayBridge *)handle displaySize];
334+
if (width != NULL) {
335+
*width = size.width;
336+
}
337+
if (height != NULL) {
338+
*height = size.height;
339+
}
340+
return size.width > 0.0 && size.height > 0.0;
341+
}
342+
}
343+
328344
bool xcw_native_input_send_touch(void *handle, double x, double y, const char *phase, char **error_message) {
329345
@autoreleasepool {
330346
if (handle == NULL) {

scripts/integration/cli.mjs

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -363,18 +363,13 @@ async function runCliControls() {
363363
);
364364
await cliStep(
365365
"CLI focus fixture text field",
366-
["tap", simulatorUDID, "--id", "fixture.message", "--wait-timeout-ms", "5000"],
367-
{},
368-
{ expectFixture: true },
369-
);
370-
await cliStep(
371-
"CLI focus fixture text field normalized",
372366
[
373367
"tap",
374368
simulatorUDID,
375-
"0.708",
376-
"0.5",
377-
"--normalized",
369+
"--id",
370+
"fixture.message",
371+
"--wait-timeout-ms",
372+
"5000",
378373
"--duration-ms",
379374
"120",
380375
"--post-delay-ms",
@@ -900,7 +895,10 @@ async function verifyUi(label, options = {}) {
900895
}
901896

902897
async function resolveKnownSystemPrompts(snapshot, label) {
903-
if (!looksLikeOpenUrlPrompt(snapshot) && !looksLikeKeyboardTipPrompt(snapshot)) {
898+
if (
899+
!looksLikeOpenUrlPrompt(snapshot) &&
900+
!looksLikeKeyboardTipPrompt(snapshot)
901+
) {
904902
return snapshot;
905903
}
906904
const promptKind = looksLikeOpenUrlPrompt(snapshot)
@@ -934,7 +932,10 @@ async function resolveKnownSystemPrompts(snapshot, label) {
934932
maxElapsedMs: describeUiBudgetMs,
935933
},
936934
);
937-
if (!looksLikeOpenUrlPrompt(current) && !looksLikeKeyboardTipPrompt(current)) {
935+
if (
936+
!looksLikeOpenUrlPrompt(current) &&
937+
!looksLikeKeyboardTipPrompt(current)
938+
) {
938939
logStep(`system ${promptKind} prompt cleared by ${action.label}`);
939940
return current;
940941
}
@@ -946,13 +947,21 @@ function openUrlPromptActions(snapshot) {
946947
const actions = [
947948
{
948949
label: "key enter",
949-
run: () => simdeckJson(["key", simulatorUDID, "enter"], { timeoutMs: 60_000 }),
950+
run: () =>
951+
simdeckJson(["key", simulatorUDID, "enter"], { timeoutMs: 60_000 }),
950952
},
951953
{
952954
label: "tap Open by label",
953955
run: () =>
954956
simdeckJson(
955-
["tap", simulatorUDID, "--label", "Open", "--wait-timeout-ms", "5000"],
957+
[
958+
"tap",
959+
simulatorUDID,
960+
"--label",
961+
"Open",
962+
"--wait-timeout-ms",
963+
"5000",
964+
],
956965
{ timeoutMs: 60_000 },
957966
),
958967
},
@@ -1064,10 +1073,7 @@ function buttonCandidatePoints(snapshot, label) {
10641073
return [];
10651074
}
10661075
const bounds = rootBounds(snapshot);
1067-
const candidates = [
1068-
point,
1069-
{ x: point.y, y: point.x },
1070-
];
1076+
const candidates = [point, { x: point.y, y: point.x }];
10711077
if (bounds) {
10721078
candidates.push(
10731079
{ x: bounds.width - point.x, y: point.y },
@@ -1087,10 +1093,7 @@ function openButtonCandidatePoints(snapshot) {
10871093
return [];
10881094
}
10891095
const bounds = rootBounds(snapshot);
1090-
const candidates = [
1091-
point,
1092-
{ x: point.y, y: point.x },
1093-
];
1096+
const candidates = [point, { x: point.y, y: point.x }];
10941097
if (bounds) {
10951098
candidates.push(
10961099
{ x: bounds.width - point.x, y: point.y },
@@ -1266,12 +1269,7 @@ function runBuffer(command, args, options = {}) {
12661269
`${command} ${args.join(" ")} took ${elapsedMs}ms, above ${options.maxElapsedMs}ms budget`,
12671270
);
12681271
}
1269-
logCommandResult(
1270-
command,
1271-
args,
1272-
elapsedMs,
1273-
`<${result.stdout.length} bytes>`,
1274-
);
1272+
logCommandResult(command, args, elapsedMs, `<${result.stdout.length} bytes>`);
12751273
return result.stdout;
12761274
}
12771275

0 commit comments

Comments
 (0)