@@ -37,6 +37,7 @@ typedef id (*RunnerDragPointerPathFactory)(
3737);
3838static NSString * _Nullable RunnerCreateEventRecord (
3939 id application,
40+ id _Nullable resolvedWindow,
4041 NSString *recordName,
4142 RunnerGestureEventBridge *bridge,
4243 id *record
@@ -74,13 +75,14 @@ static id RunnerSampledDragPointerPath(
7475static double RunnerSmoothstepProgress (double t);
7576static NSString * _Nullable RunnerTrySynthesizeDrag (
7677 id application,
78+ id _Nullable resolvedWindow,
7779 CGPoint start,
7880 CGPoint end,
7981 double durationMs,
8082 NSString *recordName,
8183 RunnerDragPointerPathFactory pathFactory
8284);
83- static NSString * _Nullable RunnerTrySynthesizeTap (id application, CGPoint point);
85+ static NSString * _Nullable RunnerTrySynthesizeTap (id application, id _Nullable resolvedWindow, CGPoint point);
8486// XCTest's proven swipe profile reaches the endpoint in 100 ms, then holds for the planned
8587// fling duration. Fast movement is what lets UIKit distinguish a fling from a timed pan.
8688static const NSTimeInterval RunnerSwipeMovementDurationSeconds = 0.1 ;
@@ -94,14 +96,16 @@ static id RunnerTapPointerPath(
9496@implementation RunnerSynthesizedGesture
9597
9698+ (NSString * _Nullable)synthesizeSwipeWithApplication : (id )application
97- x : (double )x
98- y : (double )y
99- x2 : (double )x2
100- y2 : (double )y2
99+ resolvedWindow : (id _Nullable)resolvedWindow
100+ x : (double )x
101+ y : (double )y
102+ x2 : (double )x2
103+ y2 : (double )y2
101104 durationMs : (double )durationMs {
102105 @try {
103106 return RunnerTrySynthesizeDrag (
104107 application,
108+ resolvedWindow,
105109 CGPointMake (x, y),
106110 CGPointMake (x2, y2),
107111 durationMs,
@@ -114,6 +118,7 @@ + (NSString * _Nullable)synthesizeSwipeWithApplication:(id)application
114118}
115119
116120+ (NSString * _Nullable)synthesizeContinuousDragWithApplication : (id )application
121+ resolvedWindow : (id _Nullable)resolvedWindow
117122 x : (double )x
118123 y : (double )y
119124 x2 : (double )x2
@@ -122,6 +127,7 @@ + (NSString * _Nullable)synthesizeContinuousDragWithApplication:(id)application
122127 @try {
123128 return RunnerTrySynthesizeDrag (
124129 application,
130+ resolvedWindow,
125131 CGPointMake (x, y),
126132 CGPointMake (x2, y2),
127133 durationMs,
@@ -134,14 +140,16 @@ + (NSString * _Nullable)synthesizeContinuousDragWithApplication:(id)application
134140}
135141
136142+ (NSString * _Nullable)synthesizeControlledScrollWithApplication : (id )application
143+ resolvedWindow : (id _Nullable)resolvedWindow
137144 x : (double )x
138145 y : (double )y
139146 x2 : (double )x2
140- y2 : (double )y2
141- durationMs : (double )durationMs {
147+ y2 : (double )y2
148+ durationMs : (double )durationMs {
142149 @try {
143150 return RunnerTrySynthesizeDrag (
144151 application,
152+ resolvedWindow,
145153 CGPointMake (x, y),
146154 CGPointMake (x2, y2),
147155 durationMs,
@@ -154,22 +162,25 @@ + (NSString * _Nullable)synthesizeControlledScrollWithApplication:(id)applicatio
154162}
155163
156164+ (NSString * _Nullable)synthesizeTapWithApplication : (id )application
165+ resolvedWindow : (id _Nullable)resolvedWindow
157166 x : (double )x
158167 y : (double )y {
159168 @try {
160- return RunnerTrySynthesizeTap (application, CGPointMake (x, y));
169+ return RunnerTrySynthesizeTap (application, resolvedWindow, CGPointMake (x, y));
161170 } @catch (NSException *exception) {
162171 return RunnerFormatXCTestException (exception, @" private XCTest event synthesis failed" );
163172 }
164173}
165174
166175+ (NSString * _Nullable)synthesizeGestureWithApplication : (id )application
176+ resolvedWindow : (id _Nullable)resolvedWindow
167177 pointerSamples : (NSArray <NSArray<NSDictionary<NSString *, NSNumber *> *> *> *)pointerSamples {
168178 @try {
169179 RunnerGestureEventBridge bridge;
170180 id record = nil ;
171181 NSString *error = RunnerCreateEventRecord (
172182 application,
183+ resolvedWindow,
173184 @" agent-device-gesture-plan" ,
174185 &bridge,
175186 &record
@@ -224,6 +235,7 @@ + (NSInteger)interfaceOrientationForApplication:(id)application {
224235
225236static NSString * _Nullable RunnerTrySynthesizeDrag (
226237 id application,
238+ id _Nullable resolvedWindow,
227239 CGPoint start,
228240 CGPoint end,
229241 double durationMs,
@@ -232,7 +244,7 @@ + (NSInteger)interfaceOrientationForApplication:(id)application {
232244) {
233245 RunnerGestureEventBridge bridge;
234246 id record = nil ;
235- NSString *error = RunnerCreateEventRecord (application, recordName, &bridge, &record);
247+ NSString *error = RunnerCreateEventRecord (application, resolvedWindow, recordName, &bridge, &record);
236248 if (error != nil ) return error;
237249
238250 id path = pathFactory (&bridge, start, end, durationMs);
@@ -244,11 +256,12 @@ + (NSInteger)interfaceOrientationForApplication:(id)application {
244256 return RunnerSynthesizeEventRecord (&bridge, record);
245257}
246258
247- static NSString * _Nullable RunnerTrySynthesizeTap (id application, CGPoint point) {
259+ static NSString * _Nullable RunnerTrySynthesizeTap (id application, id _Nullable resolvedWindow, CGPoint point) {
248260 RunnerGestureEventBridge bridge;
249261 id record = nil ;
250262 NSString *error = RunnerCreateEventRecord (
251263 application,
264+ resolvedWindow,
252265 @" agent-device-tap" ,
253266 &bridge,
254267 &record
@@ -311,6 +324,7 @@ + (NSInteger)interfaceOrientationForApplication:(id)application {
311324
312325static NSString * _Nullable RunnerCreateEventRecord (
313326 id application,
327+ id _Nullable resolvedWindow,
314328 NSString *recordName,
315329 RunnerGestureEventBridge *bridge,
316330 id *record
@@ -319,7 +333,9 @@ + (NSInteger)interfaceOrientationForApplication:(id)application {
319333 if (missing != nil ) return missing;
320334
321335 NSUInteger displayID = 0 ;
322- NSString *displayError = RunnerResolveApplicationDisplayID (application, &displayID);
336+ NSString *displayError = resolvedWindow != nil
337+ ? RunnerResolveWindowDisplayID (resolvedWindow, &displayID)
338+ : RunnerResolveApplicationDisplayID (application, &displayID);
323339 if (displayError != nil ) return displayError;
324340 NSInteger interfaceOrientation =
325341 ((RunnerMsgSendInteger)objc_msgSend)(application, bridge->interfaceOrientationSelector );
0 commit comments