appium-webdriveragent 17.0.6 → 17.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/WebDriverAgent.xcodeproj/project.pbxproj +16 -0
- package/WebDriverAgentLib/Commands/FBElementCommands.m +57 -41
- package/WebDriverAgentLib/Info.plist +2 -2
- package/WebDriverAgentLib/Utilities/FBGestureCoordinateContext.h +37 -0
- package/WebDriverAgentLib/Utilities/FBGestureCoordinateContext.m +133 -0
- package/WebDriverAgentLib/Utilities/FBMathUtils.h +0 -7
- package/WebDriverAgentLib/Utilities/FBMathUtils.m +0 -17
- package/WebDriverAgentLib/Utilities/FBScreen.h +3 -0
- package/WebDriverAgentLib/Utilities/FBScreen.m +19 -0
- package/WebDriverAgentLib/Utilities/FBW3CActionsSynthesizer.m +56 -74
- package/WebDriverAgentTests/IntegrationTests/FBDisplayGestureTests.m +272 -1
- package/WebDriverAgentTests/IntegrationTests/FBScreenTests.m +27 -0
- package/WebDriverAgentTests/IntegrationTests/FBW3CTouchActionsIntegrationTests.m +21 -10
- package/WebDriverAgentTests/UnitTests/FBMathUtilsTests.m +0 -30
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,13 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [17.0.7](https://github.com/appium/appium-ios/compare/appium-webdriveragent@17.0.6...appium-webdriveragent@17.0.7) (2026-11-16)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* **webdriveragent:** preserve gesture display affinity across Duo folding ([#155](https://github.com/appium/appium-ios/issues/155)) ([9481b8b](https://github.com/appium/appium-ios/commit/9481b8b793de734e2e0748c6780460a247c3f515))
|
|
11
|
+
|
|
12
|
+
|
|
6
13
|
## [17.0.6](https://github.com/appium/appium-ios/compare/appium-webdriveragent@17.0.5...appium-webdriveragent@17.0.6) (2026-11-14)
|
|
7
14
|
|
|
8
15
|
### Miscellaneous Chores
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
/* Begin PBXBuildFile section */
|
|
10
10
|
005B327C702EF47820887884 /* FBErrorBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = EE3A18601CDE618F00DE4205 /* FBErrorBuilder.h */; };
|
|
11
11
|
00ABDDC324B060006EA182F7 /* FBScreen.m in Sources */ = {isa = PBXBuildFile; fileRef = 715AFAC01FFA29180053896D /* FBScreen.m */; };
|
|
12
|
+
8DF7FE0E7A32499BAA86C4E2 /* FBGestureCoordinateContext.m in Sources */ = {isa = PBXBuildFile; fileRef = 9279D81EB4894A61B2DAB7C8 /* FBGestureCoordinateContext.m */; };
|
|
12
13
|
0161F45997A981E47729DB25 /* RouteResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 01E7CFEBAD717FCF4BCDD383 /* RouteResponse.h */; };
|
|
13
14
|
01A6F9758F11F6EF5B495D97 /* XCTPromise.h in Headers */ = {isa = PBXBuildFile; fileRef = 2CA02992F03AE1E134F2CAF5 /* XCTPromise.h */; };
|
|
14
15
|
01AC2C121519821EC6D2ED6B /* XCTMacCatalystStatusProviding-Protocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 42D2B5A0C490D9698C2A87A9 /* XCTMacCatalystStatusProviding-Protocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
|
@@ -348,12 +349,14 @@
|
|
|
348
349
|
641EE61F2240C5CA00173FCB /* FBXCodeCompatibility.m in Sources */ = {isa = PBXBuildFile; fileRef = EE5A24411F136C8D0078B1D9 /* FBXCodeCompatibility.m */; };
|
|
349
350
|
641EE6212240C5CA00173FCB /* FBElementTypeTransformer.m in Sources */ = {isa = PBXBuildFile; fileRef = EE9AB7901CAEDF0C008C271F /* FBElementTypeTransformer.m */; };
|
|
350
351
|
641EE6232240C5CA00173FCB /* FBScreen.m in Sources */ = {isa = PBXBuildFile; fileRef = 715AFAC01FFA29180053896D /* FBScreen.m */; };
|
|
352
|
+
33B06077BE1041969B44A01A /* FBGestureCoordinateContext.m in Sources */ = {isa = PBXBuildFile; fileRef = 9279D81EB4894A61B2DAB7C8 /* FBGestureCoordinateContext.m */; };
|
|
351
353
|
641EE6242240C5CA00173FCB /* FBXCTestDaemonsProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = EE35AD7A1E3B80C000A02D78 /* FBXCTestDaemonsProxy.m */; };
|
|
352
354
|
641EE6262240C5CA00173FCB /* FBMathUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = EE1888391DA661C400307AA8 /* FBMathUtils.m */; };
|
|
353
355
|
A8FC9D445C9947988C80AFC9 /* FBHIDOperations.m in Sources */ = {isa = PBXBuildFile; fileRef = 3975477AB6C14ABDBBDE3EAD /* FBHIDOperations.m */; };
|
|
354
356
|
641EE6272240C5CA00173FCB /* FBXCAXClientProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = 7157B290221DADD2001C348C /* FBXCAXClientProxy.m */; };
|
|
355
357
|
641EE6312240C5CA00173FCB /* XCUIElement+FBWebDriverAttributes.h in Headers */ = {isa = PBXBuildFile; fileRef = EEE376471D59FAE900ED88DD /* XCUIElement+FBWebDriverAttributes.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
|
356
358
|
641EE6322240C5CA00173FCB /* FBScreen.h in Headers */ = {isa = PBXBuildFile; fileRef = 715AFABF1FFA29180053896D /* FBScreen.h */; };
|
|
359
|
+
ACF532F31E714D8F89FC1F14 /* FBGestureCoordinateContext.h in Headers */ = {isa = PBXBuildFile; fileRef = F719A8616C5A4FBFB5D71020 /* FBGestureCoordinateContext.h */; };
|
|
357
360
|
641EE6332240C5CA00173FCB /* XCTestPrivateSymbols.h in Headers */ = {isa = PBXBuildFile; fileRef = EE6B64FB1D0F86EF00E85F5D /* XCTestPrivateSymbols.h */; };
|
|
358
361
|
641EE6342240C5CA00173FCB /* XCUIElement+FBTyping.h in Headers */ = {isa = PBXBuildFile; fileRef = AD76723B1D6B7CC000610457 /* XCUIElement+FBTyping.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
|
359
362
|
641EE6352240C5CA00173FCB /* XCUIElement+FBUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = EEE3763F1D59F81400ED88DD /* XCUIElement+FBUtilities.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
|
@@ -587,7 +590,9 @@
|
|
|
587
590
|
715A84D12DD92AD3007134CC /* FBElementHelpers.m in Sources */ = {isa = PBXBuildFile; fileRef = 715A84CE2DD92AD3007134CC /* FBElementHelpers.m */; };
|
|
588
591
|
715A84D22DD92AD3007134CC /* FBElementHelpers.h in Headers */ = {isa = PBXBuildFile; fileRef = 715A84CD2DD92AD3007134CC /* FBElementHelpers.h */; };
|
|
589
592
|
715AFAC11FFA29180053896D /* FBScreen.h in Headers */ = {isa = PBXBuildFile; fileRef = 715AFABF1FFA29180053896D /* FBScreen.h */; };
|
|
593
|
+
6D35951C8DB84801B157C5A4 /* FBGestureCoordinateContext.h in Headers */ = {isa = PBXBuildFile; fileRef = F719A8616C5A4FBFB5D71020 /* FBGestureCoordinateContext.h */; };
|
|
590
594
|
715AFAC21FFA29180053896D /* FBScreen.m in Sources */ = {isa = PBXBuildFile; fileRef = 715AFAC01FFA29180053896D /* FBScreen.m */; };
|
|
595
|
+
3EC777E4AE2944C2998E2626 /* FBGestureCoordinateContext.m in Sources */ = {isa = PBXBuildFile; fileRef = 9279D81EB4894A61B2DAB7C8 /* FBGestureCoordinateContext.m */; };
|
|
591
596
|
715AFAC41FFA2AAF0053896D /* FBScreenTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 715AFAC31FFA2AAF0053896D /* FBScreenTests.m */; };
|
|
592
597
|
8EB95DF348A9438BBEAB4501 /* FBDisplayGestureTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EB95DF348A9438BBEAB4502 /* FBDisplayGestureTests.m */; };
|
|
593
598
|
715D554B2229891B00524509 /* FBExceptionHandlerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 715D554A2229891B00524509 /* FBExceptionHandlerTests.m */; };
|
|
@@ -811,6 +816,7 @@
|
|
|
811
816
|
92DC81D2F6E58386AC592482 /* FBXCTestDaemonsProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = EE35AD7A1E3B80C000A02D78 /* FBXCTestDaemonsProxy.m */; };
|
|
812
817
|
932D338E506BD3EDDABBDEA9 /* XCTNSPredicateExpectationObject-Protocol.h in Headers */ = {isa = PBXBuildFile; fileRef = EE35ACEC1E3B77D600A02D78 /* XCTNSPredicateExpectationObject-Protocol.h */; };
|
|
813
818
|
93D5C4C8442EFE91D70780CC /* FBScreen.h in Headers */ = {isa = PBXBuildFile; fileRef = 715AFABF1FFA29180053896D /* FBScreen.h */; };
|
|
819
|
+
00E5348C6BD947E88C6B12A8 /* FBGestureCoordinateContext.h in Headers */ = {isa = PBXBuildFile; fileRef = F719A8616C5A4FBFB5D71020 /* FBGestureCoordinateContext.h */; };
|
|
814
820
|
9452D57FE97CB2ECED093B9F /* FBAccessibilityTraits.h in Headers */ = {isa = PBXBuildFile; fileRef = B316351E2DDF0D0B007D9317 /* FBAccessibilityTraits.h */; };
|
|
815
821
|
9472D6847DFCF79A29E201A1 /* FBFailureProofTestCase.m in Sources */ = {isa = PBXBuildFile; fileRef = EE6A89391D0B38640083E92B /* FBFailureProofTestCase.m */; };
|
|
816
822
|
94D6CDC7620D8C6E67BF2E61 /* XCTMessagingChannel_RunnerToIDE-Protocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 100F37231BF17CA9BB91DF16 /* XCTMessagingChannel_RunnerToIDE-Protocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
|
@@ -1634,7 +1640,9 @@
|
|
|
1634
1640
|
715A84CD2DD92AD3007134CC /* FBElementHelpers.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FBElementHelpers.h; sourceTree = "<group>"; };
|
|
1635
1641
|
715A84CE2DD92AD3007134CC /* FBElementHelpers.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FBElementHelpers.m; sourceTree = "<group>"; };
|
|
1636
1642
|
715AFABF1FFA29180053896D /* FBScreen.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FBScreen.h; sourceTree = "<group>"; };
|
|
1643
|
+
F719A8616C5A4FBFB5D71020 /* FBGestureCoordinateContext.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FBGestureCoordinateContext.h; sourceTree = "<group>"; };
|
|
1637
1644
|
715AFAC01FFA29180053896D /* FBScreen.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FBScreen.m; sourceTree = "<group>"; };
|
|
1645
|
+
9279D81EB4894A61B2DAB7C8 /* FBGestureCoordinateContext.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FBGestureCoordinateContext.m; sourceTree = "<group>"; };
|
|
1638
1646
|
715AFAC31FFA2AAF0053896D /* FBScreenTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FBScreenTests.m; sourceTree = "<group>"; };
|
|
1639
1647
|
8EB95DF348A9438BBEAB4502 /* FBDisplayGestureTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FBDisplayGestureTests.m; sourceTree = "<group>"; };
|
|
1640
1648
|
715D554A2229891B00524509 /* FBExceptionHandlerTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FBExceptionHandlerTests.m; sourceTree = "<group>"; };
|
|
@@ -2643,7 +2651,9 @@
|
|
|
2643
2651
|
71F3E7D625417FF400E0C22C /* FBSettingsHandler.h */,
|
|
2644
2652
|
71F3E7D725417FF400E0C22C /* FBSettingsHandler.m */,
|
|
2645
2653
|
715AFABF1FFA29180053896D /* FBScreen.h */,
|
|
2654
|
+
F719A8616C5A4FBFB5D71020 /* FBGestureCoordinateContext.h */,
|
|
2646
2655
|
715AFAC01FFA29180053896D /* FBScreen.m */,
|
|
2656
|
+
9279D81EB4894A61B2DAB7C8 /* FBGestureCoordinateContext.m */,
|
|
2647
2657
|
71C9EAAA25E8415A00470CD8 /* FBScreenshot.h */,
|
|
2648
2658
|
71C9EAAB25E8415A00470CD8 /* FBScreenshot.m */,
|
|
2649
2659
|
641EE70A2240CE2D00173FCB /* FBTVNavigationTracker.h */,
|
|
@@ -3089,6 +3099,7 @@
|
|
|
3089
3099
|
files = (
|
|
3090
3100
|
641EE6312240C5CA00173FCB /* XCUIElement+FBWebDriverAttributes.h in Headers */,
|
|
3091
3101
|
641EE6322240C5CA00173FCB /* FBScreen.h in Headers */,
|
|
3102
|
+
ACF532F31E714D8F89FC1F14 /* FBGestureCoordinateContext.h in Headers */,
|
|
3092
3103
|
641EE6332240C5CA00173FCB /* XCTestPrivateSymbols.h in Headers */,
|
|
3093
3104
|
641EE6342240C5CA00173FCB /* XCUIElement+FBTyping.h in Headers */,
|
|
3094
3105
|
641EE6352240C5CA00173FCB /* XCUIElement+FBUtilities.h in Headers */,
|
|
@@ -3402,6 +3413,7 @@
|
|
|
3402
3413
|
files = (
|
|
3403
3414
|
43EBA0D0D54EB99815CE63B6 /* XCUIElement+FBWebDriverAttributes.h in Headers */,
|
|
3404
3415
|
93D5C4C8442EFE91D70780CC /* FBScreen.h in Headers */,
|
|
3416
|
+
00E5348C6BD947E88C6B12A8 /* FBGestureCoordinateContext.h in Headers */,
|
|
3405
3417
|
B9FAD6E3F3AB201B59D6F8BD /* XCTestPrivateSymbols.h in Headers */,
|
|
3406
3418
|
CDDEBD9F5F6A380C8D32D671 /* XCUIElement+FBTyping.h in Headers */,
|
|
3407
3419
|
488C4CBD86EBFA2AB5396917 /* XCUIElement+FBUtilities.h in Headers */,
|
|
@@ -3670,6 +3682,7 @@
|
|
|
3670
3682
|
files = (
|
|
3671
3683
|
EEE376491D59FAE900ED88DD /* XCUIElement+FBWebDriverAttributes.h in Headers */,
|
|
3672
3684
|
715AFAC11FFA29180053896D /* FBScreen.h in Headers */,
|
|
3685
|
+
6D35951C8DB84801B157C5A4 /* FBGestureCoordinateContext.h in Headers */,
|
|
3673
3686
|
EE6B64FD1D0F86EF00E85F5D /* XCTestPrivateSymbols.h in Headers */,
|
|
3674
3687
|
AD76723D1D6B7CC000610457 /* XCUIElement+FBTyping.h in Headers */,
|
|
3675
3688
|
EEE376451D59F81400ED88DD /* XCUIElement+FBUtilities.h in Headers */,
|
|
@@ -4580,6 +4593,7 @@
|
|
|
4580
4593
|
641EE6212240C5CA00173FCB /* FBElementTypeTransformer.m in Sources */,
|
|
4581
4594
|
13DE7A5E287CA444003243C6 /* FBXCElementSnapshotWrapper+Helpers.m in Sources */,
|
|
4582
4595
|
641EE6232240C5CA00173FCB /* FBScreen.m in Sources */,
|
|
4596
|
+
33B06077BE1041969B44A01A /* FBGestureCoordinateContext.m in Sources */,
|
|
4583
4597
|
71D04DCB25356C43008A052C /* XCUIElement+FBCaching.m in Sources */,
|
|
4584
4598
|
641EE6242240C5CA00173FCB /* FBXCTestDaemonsProxy.m in Sources */,
|
|
4585
4599
|
13DE7A58287CA1EC003243C6 /* FBXCElementSnapshotWrapper.m in Sources */,
|
|
@@ -4737,6 +4751,7 @@
|
|
|
4737
4751
|
C74712EC760C30DF5D261DF0 /* FBElementTypeTransformer.m in Sources */,
|
|
4738
4752
|
9F9218F11A1D06F8DCC8308B /* FBXCElementSnapshotWrapper+Helpers.m in Sources */,
|
|
4739
4753
|
00ABDDC324B060006EA182F7 /* FBScreen.m in Sources */,
|
|
4754
|
+
8DF7FE0E7A32499BAA86C4E2 /* FBGestureCoordinateContext.m in Sources */,
|
|
4740
4755
|
486F5AEF3C385922994476CD /* XCUIElement+FBCaching.m in Sources */,
|
|
4741
4756
|
92DC81D2F6E58386AC592482 /* FBXCTestDaemonsProxy.m in Sources */,
|
|
4742
4757
|
4819BEAC415E02570C0FA074 /* FBXCElementSnapshotWrapper.m in Sources */,
|
|
@@ -4863,6 +4878,7 @@
|
|
|
4863
4878
|
EE158AE91CBD456F00A3E3F0 /* FBElementTypeTransformer.m in Sources */,
|
|
4864
4879
|
71D3B3D7267FC7260076473D /* XCUIElement+FBResolve.m in Sources */,
|
|
4865
4880
|
715AFAC21FFA29180053896D /* FBScreen.m in Sources */,
|
|
4881
|
+
3EC777E4AE2944C2998E2626 /* FBGestureCoordinateContext.m in Sources */,
|
|
4866
4882
|
71B155DC230711E900646AFB /* FBCommandStatus.m in Sources */,
|
|
4867
4883
|
EE35AD7C1E3B80C000A02D78 /* FBXCTestDaemonsProxy.m in Sources */,
|
|
4868
4884
|
EE18883B1DA661C400307AA8 /* FBMathUtils.m in Sources */,
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
#import "FBConfiguration.h"
|
|
12
12
|
#import "FBScreen.h"
|
|
13
|
+
#import "FBGestureCoordinateContext.h"
|
|
13
14
|
#import "XCUIScreen.h"
|
|
14
15
|
#import "FBRoute.h"
|
|
15
16
|
#import "FBRouteRequest.h"
|
|
@@ -42,6 +43,10 @@
|
|
|
42
43
|
#import "XCUIElementQuery.h"
|
|
43
44
|
#import "FBXCodeCompatibility.h"
|
|
44
45
|
|
|
46
|
+
#if !TARGET_OS_TV
|
|
47
|
+
typedef XCUICoordinate * _Nullable (^FBGestureCoordinateResolver)(CGVector offset, NSError **error);
|
|
48
|
+
#endif
|
|
49
|
+
|
|
45
50
|
@interface FBElementCommands ()
|
|
46
51
|
@end
|
|
47
52
|
|
|
@@ -358,20 +363,15 @@
|
|
|
358
363
|
NSError *error;
|
|
359
364
|
CGVector startOffset = CGVectorMake((CGFloat)[request.arguments[@"fromX"] doubleValue],
|
|
360
365
|
(CGFloat)[request.arguments[@"fromY"] doubleValue]);
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
}
|
|
367
|
-
CGVector endOffset = CGVectorMake((CGFloat)[request.arguments[@"toX"] doubleValue],
|
|
368
|
-
(CGFloat)[request.arguments[@"toY"] doubleValue]);
|
|
369
|
-
XCUICoordinate *endCoordinate = [self.class gestureCoordinateWithOffset:endOffset
|
|
370
|
-
element:application
|
|
371
|
-
error:&error];
|
|
372
|
-
if (nil == endCoordinate) {
|
|
366
|
+
CGVector endOffset = CGVectorMake([request.arguments[@"toX"] doubleValue],
|
|
367
|
+
[request.arguments[@"toY"] doubleValue]);
|
|
368
|
+
NSArray<XCUICoordinate *> *coordinates = [self.class gestureCoordinatesWithOffsets:
|
|
369
|
+
@[[NSValue valueWithCGVector:startOffset], [NSValue valueWithCGVector:endOffset]] element:application error:&error];
|
|
370
|
+
if (nil == coordinates) {
|
|
373
371
|
return FBResponseWithStatus([FBCommandStatus invalidElementStateErrorWithMessage:error.description traceback:nil]);
|
|
374
372
|
}
|
|
373
|
+
XCUICoordinate *startCoordinate = coordinates[0];
|
|
374
|
+
XCUICoordinate *endCoordinate = coordinates[1];
|
|
375
375
|
if (![application fb_pressAtCoordinate:startCoordinate
|
|
376
376
|
forDuration:[request.arguments[@"pressDuration"] doubleValue]
|
|
377
377
|
thenDragToCoordinate:endCoordinate
|
|
@@ -452,16 +452,15 @@
|
|
|
452
452
|
NSError *error;
|
|
453
453
|
CGVector startOffset = CGVectorMake([request.arguments[@"fromX"] doubleValue],
|
|
454
454
|
[request.arguments[@"fromY"] doubleValue]);
|
|
455
|
-
XCUICoordinate *startCoordinate = [self.class gestureCoordinateWithOffset:startOffset element:target error:&error];
|
|
456
|
-
if (nil == startCoordinate) {
|
|
457
|
-
return FBResponseWithStatus([FBCommandStatus invalidElementStateErrorWithMessage:error.description traceback:nil]);
|
|
458
|
-
}
|
|
459
455
|
CGVector endOffset = CGVectorMake([request.arguments[@"toX"] doubleValue],
|
|
460
456
|
[request.arguments[@"toY"] doubleValue]);
|
|
461
|
-
XCUICoordinate *
|
|
462
|
-
|
|
457
|
+
NSArray<XCUICoordinate *> *coordinates = [self.class gestureCoordinatesWithOffsets:
|
|
458
|
+
@[[NSValue valueWithCGVector:startOffset], [NSValue valueWithCGVector:endOffset]] element:target error:&error];
|
|
459
|
+
if (nil == coordinates) {
|
|
463
460
|
return FBResponseWithStatus([FBCommandStatus invalidElementStateErrorWithMessage:error.description traceback:nil]);
|
|
464
461
|
}
|
|
462
|
+
XCUICoordinate *startCoordinate = coordinates[0];
|
|
463
|
+
XCUICoordinate *endCoordinate = coordinates[1];
|
|
465
464
|
NSTimeInterval duration = [request.arguments[@"duration"] doubleValue];
|
|
466
465
|
XCUIApplication *application = [target isKindOfClass:XCUIApplication.class]
|
|
467
466
|
? (XCUIApplication *)target
|
|
@@ -707,34 +706,51 @@ static const NSInteger DEFAULT_MAX_PICKER_ATTEMPTS = 25;
|
|
|
707
706
|
element:(XCUIElement *)element
|
|
708
707
|
error:(NSError **)error
|
|
709
708
|
{
|
|
710
|
-
|
|
711
|
-
|
|
709
|
+
return [self gestureCoordinatesWithOffsets:@[[NSValue valueWithCGVector:offset]] element:element error:error].firstObject;
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
+ (nullable FBGestureCoordinateResolver)gestureCoordinateResolverForElement:(XCUIElement *)element
|
|
713
|
+
error:(NSError **)error
|
|
714
|
+
{
|
|
715
|
+
BOOL isApplication = element.elementType == XCUIElementTypeApplication;
|
|
716
|
+
#if TARGET_OS_WATCH
|
|
717
|
+
// Preserve watchOS application-root coordinates and selected-display validation.
|
|
718
|
+
if (isApplication && nil == [FBScreen currentScreenWithError:error]) {
|
|
719
|
+
return nil;
|
|
720
|
+
}
|
|
721
|
+
#else
|
|
722
|
+
if (isApplication) {
|
|
723
|
+
FBGestureCoordinateContext *context = [FBGestureCoordinateContext contextWithDisplayRequired:YES error:error];
|
|
724
|
+
if (nil == context) {
|
|
725
|
+
return nil;
|
|
726
|
+
}
|
|
727
|
+
return ^XCUICoordinate *(CGVector offset, NSError **coordinateError) {
|
|
728
|
+
return [context coordinateWithApplication:element offset:offset error:coordinateError];
|
|
729
|
+
};
|
|
712
730
|
}
|
|
713
|
-
|
|
714
|
-
|
|
731
|
+
#endif
|
|
732
|
+
return ^XCUICoordinate *(CGVector offset, NSError **coordinateError) {
|
|
733
|
+
return FBCoordinateWithAnchorOffset(element, CGVectorMake(0, 0), offset, coordinateError);
|
|
734
|
+
};
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
+ (nullable NSArray<XCUICoordinate *> *)gestureCoordinatesWithOffsets:(NSArray<NSValue *> *)offsets
|
|
738
|
+
element:(XCUIElement *)element
|
|
739
|
+
error:(NSError **)error
|
|
740
|
+
{
|
|
741
|
+
FBGestureCoordinateResolver resolveCoordinate = [self gestureCoordinateResolverForElement:element error:error];
|
|
742
|
+
if (nil == resolveCoordinate) {
|
|
715
743
|
return nil;
|
|
716
744
|
}
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
// It is only a coordinate anchor, not a hit-test boundary. Preserve edge and
|
|
723
|
-
// outside offsets just as on the main display; XCTest handles their delivery.
|
|
724
|
-
CGPoint point = CGPointMake(offset.dx, offset.dy);
|
|
725
|
-
for (XCUIElement *window in [element childrenMatchingType:XCUIElementTypeWindow].allElementsBoundByIndex) {
|
|
726
|
-
// Resolve the window before reading its display affinity: an unresolved
|
|
727
|
-
// element may report displayID == 0.
|
|
728
|
-
(void)window.frame;
|
|
729
|
-
CGRect frame = window.wdFrame;
|
|
730
|
-
if (window.screen.displayID == screen.displayID && !CGRectIsEmpty(frame)) {
|
|
731
|
-
return FBCoordinateWithAnchorOffset(window, CGVectorMake(0, 0),
|
|
732
|
-
CGVectorMake(point.x - frame.origin.x, point.y - frame.origin.y), error);
|
|
745
|
+
NSMutableArray<XCUICoordinate *> *coordinates = [NSMutableArray arrayWithCapacity:offsets.count];
|
|
746
|
+
for (NSValue *value in offsets) {
|
|
747
|
+
XCUICoordinate *coordinate = resolveCoordinate(value.CGVectorValue, error);
|
|
748
|
+
if (nil == coordinate) {
|
|
749
|
+
return nil;
|
|
733
750
|
}
|
|
751
|
+
[coordinates addObject:coordinate];
|
|
734
752
|
}
|
|
735
|
-
|
|
736
|
-
buildError:error];
|
|
737
|
-
return nil;
|
|
753
|
+
return coordinates.copy;
|
|
738
754
|
}
|
|
739
755
|
|
|
740
756
|
/**
|
|
@@ -15,11 +15,11 @@
|
|
|
15
15
|
<key>CFBundlePackageType</key>
|
|
16
16
|
<string>FMWK</string>
|
|
17
17
|
<key>CFBundleShortVersionString</key>
|
|
18
|
-
<string>17.0.
|
|
18
|
+
<string>17.0.7</string>
|
|
19
19
|
<key>CFBundleSignature</key>
|
|
20
20
|
<string>????</string>
|
|
21
21
|
<key>CFBundleVersion</key>
|
|
22
|
-
<string>17.0.
|
|
22
|
+
<string>17.0.7</string>
|
|
23
23
|
<key>NSPrincipalClass</key>
|
|
24
24
|
<string/>
|
|
25
25
|
</dict>
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2015-present, Facebook, Inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
#import <XCTest/XCTest.h>
|
|
10
|
+
|
|
11
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
12
|
+
|
|
13
|
+
#if !TARGET_OS_TV && !TARGET_OS_WATCH
|
|
14
|
+
/** Display routing and window anchors scoped to one W3C command or native gesture. */
|
|
15
|
+
@interface FBGestureCoordinateContext : NSObject
|
|
16
|
+
@property (nonatomic, readonly) XCUIScreen *screen;
|
|
17
|
+
@property (nonatomic, readonly) BOOL usesWindowCoordinates;
|
|
18
|
+
|
|
19
|
+
- (instancetype)init NS_UNAVAILABLE;
|
|
20
|
+
+ (instancetype)new NS_UNAVAILABLE;
|
|
21
|
+
|
|
22
|
+
/** Keyboard/pause-only actions use the main screen without selected-display lookup. */
|
|
23
|
+
+ (nullable instancetype)contextWithDisplayRequired:(BOOL)requiresDisplay error:(NSError **)error;
|
|
24
|
+
|
|
25
|
+
/** Native application-root or multi-display viewport coordinates. */
|
|
26
|
+
- (nullable XCUICoordinate *)coordinateWithApplication:(XCUIElement *)application
|
|
27
|
+
offset:(CGVector)offset
|
|
28
|
+
error:(NSError **)error;
|
|
29
|
+
|
|
30
|
+
/** Multi-display W3C Application origin: reported rect midpoint plus client offset. */
|
|
31
|
+
- (nullable XCUICoordinate *)coordinateWithApplicationOrigin:(XCUIElement *)application
|
|
32
|
+
offset:(CGVector)offset
|
|
33
|
+
error:(NSError **)error;
|
|
34
|
+
@end
|
|
35
|
+
#endif
|
|
36
|
+
|
|
37
|
+
NS_ASSUME_NONNULL_END
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2015-present, Facebook, Inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
#import "FBGestureCoordinateContext.h"
|
|
10
|
+
|
|
11
|
+
#if !TARGET_OS_TV && !TARGET_OS_WATCH
|
|
12
|
+
#import "FBErrorBuilder.h"
|
|
13
|
+
#import "FBMathUtils.h"
|
|
14
|
+
#import "FBScreen.h"
|
|
15
|
+
#import "XCUIElement.h"
|
|
16
|
+
#import "XCUIElement+FBWebDriverAttributes.h"
|
|
17
|
+
#import "XCUIScreen.h"
|
|
18
|
+
|
|
19
|
+
@interface FBWindowCoordinateAnchor : NSObject
|
|
20
|
+
@property (nonatomic) XCUIElement *window;
|
|
21
|
+
@property (nonatomic) CGRect frame;
|
|
22
|
+
@end
|
|
23
|
+
|
|
24
|
+
@implementation FBWindowCoordinateAnchor
|
|
25
|
+
- (XCUICoordinate *)coordinateWithOffset:(CGVector)offset
|
|
26
|
+
{
|
|
27
|
+
// Use the captured frame; FBCoordinateWithAnchorOffset would query it again.
|
|
28
|
+
return [self.window coordinateWithNormalizedOffset:CGVectorMake(
|
|
29
|
+
(offset.dx - self.frame.origin.x) / self.frame.size.width,
|
|
30
|
+
(offset.dy - self.frame.origin.y) / self.frame.size.height)];
|
|
31
|
+
}
|
|
32
|
+
@end
|
|
33
|
+
|
|
34
|
+
@interface FBGestureCoordinateContext ()
|
|
35
|
+
@property (nonatomic) NSMapTable<XCUIElement *, FBWindowCoordinateAnchor *> *windowAnchors;
|
|
36
|
+
- (instancetype)initWithScreen:(XCUIScreen *)screen usesWindowCoordinates:(BOOL)usesWindowCoordinates;
|
|
37
|
+
@end
|
|
38
|
+
|
|
39
|
+
@implementation FBGestureCoordinateContext
|
|
40
|
+
|
|
41
|
+
+ (nullable instancetype)contextWithDisplayRequired:(BOOL)requiresDisplay error:(NSError **)error
|
|
42
|
+
{
|
|
43
|
+
XCUIScreen *screen = requiresDisplay ? [FBScreen currentScreenWithError:error] : XCUIScreen.mainScreen;
|
|
44
|
+
if (nil == screen) {
|
|
45
|
+
return nil;
|
|
46
|
+
}
|
|
47
|
+
NSNumber *hasMultipleScreens = requiresDisplay ? [FBScreen hasMultipleScreensWithError:error] : @NO;
|
|
48
|
+
if (nil == hasMultipleScreens) {
|
|
49
|
+
return nil;
|
|
50
|
+
}
|
|
51
|
+
return [[self alloc] initWithScreen:screen usesWindowCoordinates:hasMultipleScreens.boolValue];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
- (instancetype)initWithScreen:(XCUIScreen *)screen usesWindowCoordinates:(BOOL)usesWindowCoordinates
|
|
55
|
+
{
|
|
56
|
+
self = [super init];
|
|
57
|
+
if (self) {
|
|
58
|
+
_screen = screen;
|
|
59
|
+
_usesWindowCoordinates = usesWindowCoordinates;
|
|
60
|
+
if (usesWindowCoordinates) {
|
|
61
|
+
// Object identity avoids XCTest equality queries and keeps distinct app origins separate.
|
|
62
|
+
_windowAnchors = [NSMapTable mapTableWithKeyOptions:NSPointerFunctionsObjectPointerPersonality
|
|
63
|
+
valueOptions:NSPointerFunctionsStrongMemory];
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return self;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
- (nullable XCUICoordinate *)coordinateWithApplication:(XCUIElement *)application
|
|
70
|
+
offset:(CGVector)offset
|
|
71
|
+
error:(NSError **)error
|
|
72
|
+
{
|
|
73
|
+
if (!self.usesWindowCoordinates) {
|
|
74
|
+
return FBCoordinateWithAnchorOffset(application, CGVectorMake(0, 0), offset, error);
|
|
75
|
+
}
|
|
76
|
+
FBWindowCoordinateAnchor *anchor = [self windowAnchorForApplication:application error:error];
|
|
77
|
+
return [anchor coordinateWithOffset:offset];
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
- (nullable XCUICoordinate *)coordinateWithApplicationOrigin:(XCUIElement *)application
|
|
81
|
+
offset:(CGVector)offset
|
|
82
|
+
error:(NSError **)error
|
|
83
|
+
{
|
|
84
|
+
CGRect frame = application.wdFrame;
|
|
85
|
+
if (CGRectIsEmpty(frame)) {
|
|
86
|
+
[[[FBErrorBuilder builder] withDescription:@"The application origin has an empty frame"] buildError:error];
|
|
87
|
+
return nil;
|
|
88
|
+
}
|
|
89
|
+
return [self coordinateWithApplication:application
|
|
90
|
+
offset:CGVectorMake(CGRectGetMidX(frame) + offset.dx, CGRectGetMidY(frame) + offset.dy)
|
|
91
|
+
error:error];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
- (nullable FBWindowCoordinateAnchor *)windowAnchorForApplication:(XCUIElement *)application error:(NSError **)error
|
|
95
|
+
{
|
|
96
|
+
FBWindowCoordinateAnchor *anchor = [self.windowAnchors objectForKey:application];
|
|
97
|
+
if (nil == anchor) {
|
|
98
|
+
anchor = [self.class windowAnchorWithApplication:application screen:self.screen error:error];
|
|
99
|
+
if (nil != anchor) {
|
|
100
|
+
[self.windowAnchors setObject:anchor forKey:application];
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return anchor;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
+ (nullable FBWindowCoordinateAnchor *)windowAnchorWithApplication:(XCUIElement *)application
|
|
107
|
+
screen:(XCUIScreen *)screen
|
|
108
|
+
error:(NSError **)error
|
|
109
|
+
{
|
|
110
|
+
// Application-root coordinates can retain cover-display geometry after main
|
|
111
|
+
// switches to the inner panel. Resolve an anchor on the selected display.
|
|
112
|
+
// A window coordinate keeps XCTest's display affinity and rotation intact.
|
|
113
|
+
// It is only a coordinate anchor, not a hit-test boundary. Preserve edge and
|
|
114
|
+
// outside offsets just as on the main display; XCTest handles their delivery.
|
|
115
|
+
for (XCUIElement *window in [application childrenMatchingType:XCUIElementTypeWindow].allElementsBoundByIndex) {
|
|
116
|
+
// Resolve the window before reading its display affinity: an unresolved
|
|
117
|
+
// element may report displayID == 0.
|
|
118
|
+
(void)window.frame;
|
|
119
|
+
CGRect frame = window.wdFrame;
|
|
120
|
+
if (window.screen.displayID == screen.displayID && !CGRectIsEmpty(frame)) {
|
|
121
|
+
FBWindowCoordinateAnchor *anchor = [FBWindowCoordinateAnchor new];
|
|
122
|
+
anchor.window = window;
|
|
123
|
+
anchor.frame = frame;
|
|
124
|
+
return anchor;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
[[[FBErrorBuilder builder] withDescriptionFormat:@"No non-empty application window on display %lld is available as a coordinate anchor", screen.displayID]
|
|
128
|
+
buildError:error];
|
|
129
|
+
return nil;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
@end
|
|
133
|
+
#endif
|
|
@@ -41,13 +41,6 @@ CGRect FBRectFromPortraitCoordinates(CGRect frame, CGSize screenSize, UIInterfac
|
|
|
41
41
|
/*! Inverts size if necessary to match current screen orientation */
|
|
42
42
|
CGSize FBAdjustDimensionsForApplication(CGSize actualSize, UIInterfaceOrientation orientation);
|
|
43
43
|
|
|
44
|
-
/*!
|
|
45
|
-
Offsets XCTest screenPoint coordinates for an explicitly selected display.
|
|
46
|
-
XCTest rotates these coordinates using the main screen's dimensions even when
|
|
47
|
-
the synthesized event record targets another display. Sizes are in points.
|
|
48
|
-
*/
|
|
49
|
-
CGVector FBDisplayCoordinateOffset(CGSize mainSize, CGSize displaySize,
|
|
50
|
-
UIInterfaceOrientation orientation);
|
|
51
44
|
#endif
|
|
52
45
|
|
|
53
46
|
#if !TARGET_OS_TV
|
|
@@ -128,20 +128,3 @@ BOOL FBScrollGestureOffsets(CGRect scrollingFrame,
|
|
|
128
128
|
(endPoint.y - anchorFrame.origin.y) / anchorFrame.size.height);
|
|
129
129
|
return YES;
|
|
130
130
|
}
|
|
131
|
-
|
|
132
|
-
#if !TARGET_OS_TV && !TARGET_OS_WATCH
|
|
133
|
-
CGVector FBDisplayCoordinateOffset(CGSize mainSize, CGSize displaySize,
|
|
134
|
-
UIInterfaceOrientation orientation)
|
|
135
|
-
{
|
|
136
|
-
CGVector offset = CGVectorMake(0, 0);
|
|
137
|
-
if (orientation == UIInterfaceOrientationLandscapeRight
|
|
138
|
-
|| orientation == UIInterfaceOrientationPortraitUpsideDown) {
|
|
139
|
-
offset.dx = displaySize.width - mainSize.width;
|
|
140
|
-
}
|
|
141
|
-
if (orientation == UIInterfaceOrientationLandscapeLeft
|
|
142
|
-
|| orientation == UIInterfaceOrientationPortraitUpsideDown) {
|
|
143
|
-
offset.dy = displaySize.height - mainSize.height;
|
|
144
|
-
}
|
|
145
|
-
return offset;
|
|
146
|
-
}
|
|
147
|
-
#endif
|
|
@@ -17,6 +17,9 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
17
17
|
*/
|
|
18
18
|
+ (nullable NSArray<NSDictionary<NSString *, id> *> *)screensWithError:(NSError **)error;
|
|
19
19
|
|
|
20
|
+
/** Whether multiple displays are available, or nil if enumeration fails. */
|
|
21
|
+
+ (nullable NSNumber *)hasMultipleScreensWithError:(NSError **)error;
|
|
22
|
+
|
|
20
23
|
/**
|
|
21
24
|
The display with the given identifier
|
|
22
25
|
|
|
@@ -56,6 +56,25 @@ static NSArray<XCUIScreen *> *FBScreensForDevice(id device, NSError **error)
|
|
|
56
56
|
return result.copy;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
// Kept separate from sharedDevice so enumeration failures can be tested.
|
|
60
|
+
+ (nullable NSNumber *)hasMultipleScreensForDevice:(id)device error:(NSError **)error
|
|
61
|
+
{
|
|
62
|
+
NSError *enumerationError = nil;
|
|
63
|
+
NSArray<XCUIScreen *> *screens = FBScreensForDevice(device, &enumerationError);
|
|
64
|
+
if (nil == screens) {
|
|
65
|
+
if (NULL != error) {
|
|
66
|
+
*error = enumerationError ?: [[FBErrorBuilder.builder withDescription:@"Could not enumerate device displays"] build];
|
|
67
|
+
}
|
|
68
|
+
return nil;
|
|
69
|
+
}
|
|
70
|
+
return @(screens.count > 1);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
+ (nullable NSNumber *)hasMultipleScreensWithError:(NSError **)error
|
|
74
|
+
{
|
|
75
|
+
return [self hasMultipleScreensForDevice:XCUIDevice.sharedDevice error:error];
|
|
76
|
+
}
|
|
77
|
+
|
|
59
78
|
// Kept separate from sharedDevice so legacy lookup behavior can be tested.
|
|
60
79
|
+ (nullable XCUIScreen *)screenWithDisplayID:(long long)displayID
|
|
61
80
|
device:(XCUIDevice *)device
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
#import "FBMacros.h"
|
|
16
16
|
#import "FBMathUtils.h"
|
|
17
17
|
#import "FBProtocolHelpers.h"
|
|
18
|
-
#import "
|
|
18
|
+
#import "FBGestureCoordinateContext.h"
|
|
19
19
|
#import "FBW3CActionsHelpers.h"
|
|
20
20
|
#import "FBXCodeCompatibility.h"
|
|
21
21
|
#import "FBXCTestDaemonsProxy.h"
|
|
@@ -69,9 +69,8 @@ static NSString *const FB_KEY_ACTIONS = @"actions";
|
|
|
69
69
|
@interface FBW3CGestureItem : FBBaseGestureItem
|
|
70
70
|
|
|
71
71
|
@property (nullable, readonly, nonatomic) FBW3CGestureItem *previousItem;
|
|
72
|
-
@property (nonatomic) CGVector displayCorrection;
|
|
73
|
-
@property (nonatomic) BOOL usesDisplayCorrection;
|
|
74
72
|
@property (readonly, nonatomic) CGPoint screenPoint;
|
|
73
|
+
@property (nonatomic) FBGestureCoordinateContext *coordinateContext;
|
|
75
74
|
|
|
76
75
|
@end
|
|
77
76
|
|
|
@@ -123,6 +122,7 @@ static NSString *const FB_KEY_ACTIONS = @"actions";
|
|
|
123
122
|
- (nullable instancetype)initWithActionItem:(NSDictionary<NSString *, id> *)actionItem
|
|
124
123
|
application:(XCUIApplication *)application
|
|
125
124
|
previousItem:(nullable FBW3CGestureItem *)previousItem
|
|
125
|
+
coordinateContext:(FBGestureCoordinateContext *)coordinateContext
|
|
126
126
|
offset:(double)offset
|
|
127
127
|
error:(NSError **)error
|
|
128
128
|
{
|
|
@@ -132,7 +132,7 @@ static NSString *const FB_KEY_ACTIONS = @"actions";
|
|
|
132
132
|
self.application = application;
|
|
133
133
|
self.offset = offset;
|
|
134
134
|
_previousItem = previousItem;
|
|
135
|
-
|
|
135
|
+
_coordinateContext = coordinateContext;
|
|
136
136
|
NSNumber *durationObj = FBOptDuration(actionItem, @0, error);
|
|
137
137
|
if (nil == durationObj) {
|
|
138
138
|
return nil;
|
|
@@ -150,10 +150,7 @@ static NSString *const FB_KEY_ACTIONS = @"actions";
|
|
|
150
150
|
|
|
151
151
|
- (CGPoint)screenPoint
|
|
152
152
|
{
|
|
153
|
-
|
|
154
|
-
return self.usesDisplayCorrection
|
|
155
|
-
? CGPointMake(point.x + self.displayCorrection.dx, point.y + self.displayCorrection.dy)
|
|
156
|
-
: point;
|
|
153
|
+
return self.atPosition.screenPoint;
|
|
157
154
|
}
|
|
158
155
|
|
|
159
156
|
- (nullable XCUICoordinate *)positionWithError:(NSError **)error
|
|
@@ -172,27 +169,25 @@ static NSString *const FB_KEY_ACTIONS = @"actions";
|
|
|
172
169
|
positionOffset:(nullable NSValue *)positionOffset
|
|
173
170
|
error:(NSError **)error
|
|
174
171
|
{
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
if (nil ==
|
|
172
|
+
if (self.coordinateContext.usesWindowCoordinates) {
|
|
173
|
+
CGPoint point = nil == positionOffset ? CGPointZero : positionOffset.CGPointValue;
|
|
174
|
+
CGVector offset = CGVectorMake(point.x, point.y);
|
|
175
|
+
if (nil == element) {
|
|
176
|
+
return [self.coordinateContext coordinateWithApplication:self.application offset:offset error:error];
|
|
177
|
+
}
|
|
178
|
+
if (element.elementType == XCUIElementTypeApplication) {
|
|
179
|
+
XCUIElement *application = element;
|
|
180
|
+
return [self.coordinateContext coordinateWithApplicationOrigin:application offset:offset error:error];
|
|
181
|
+
}
|
|
182
|
+
// Resolve display affinity before combining element and viewport origins.
|
|
183
|
+
(void)element.frame;
|
|
184
|
+
if (element.screen.displayID != self.coordinateContext.screen.displayID) {
|
|
185
|
+
[[[FBErrorBuilder builder] withDescriptionFormat:
|
|
186
|
+
@"The element origin is not on the selected display %lld", self.coordinateContext.screen.displayID] buildError:error];
|
|
179
187
|
return nil;
|
|
180
188
|
}
|
|
181
189
|
}
|
|
182
|
-
|
|
183
|
-
// Unlike ordinary elements, application-root coordinates rotate using the
|
|
184
|
-
// main display. Resolve the client-visible rect's center into viewport
|
|
185
|
-
// coordinates, then let screenPoint apply the selected-display correction.
|
|
186
|
-
// Do not use a normalized app center: XCTest may report a portrait app rect
|
|
187
|
-
// for a landscape window, so its normalized center uses a different space.
|
|
188
|
-
CGRect frame = element.wdFrame;
|
|
189
|
-
if (CGRectIsEmpty(frame)) {
|
|
190
|
-
return [super hitpointWithElement:element positionOffset:positionOffset error:error];
|
|
191
|
-
}
|
|
192
|
-
CGPoint offset = nil == positionOffset ? CGPointZero : positionOffset.CGPointValue;
|
|
193
|
-
CGPoint point = CGPointMake(CGRectGetMidX(frame) + offset.x, CGRectGetMidY(frame) + offset.y);
|
|
194
|
-
return [super hitpointWithElement:nil positionOffset:[NSValue valueWithCGPoint:point] error:error];
|
|
195
|
-
}
|
|
190
|
+
// Single-display viewport and application origins retain the legacy path.
|
|
196
191
|
if (nil == element || nil == positionOffset) {
|
|
197
192
|
return [super hitpointWithElement:element positionOffset:positionOffset error:error];
|
|
198
193
|
}
|
|
@@ -221,10 +216,11 @@ static NSString *const FB_KEY_ACTIONS = @"actions";
|
|
|
221
216
|
- (nullable instancetype)initWithActionItem:(NSDictionary<NSString *, id> *)actionItem
|
|
222
217
|
application:(XCUIApplication *)application
|
|
223
218
|
previousItem:(nullable FBW3CGestureItem *)previousItem
|
|
219
|
+
coordinateContext:(FBGestureCoordinateContext *)coordinateContext
|
|
224
220
|
offset:(double)offset
|
|
225
221
|
error:(NSError **)error
|
|
226
222
|
{
|
|
227
|
-
self = [super initWithActionItem:actionItem application:application previousItem:previousItem offset:offset error:error];
|
|
223
|
+
self = [super initWithActionItem:actionItem application:application previousItem:previousItem coordinateContext:coordinateContext offset:offset error:error];
|
|
228
224
|
if (self) {
|
|
229
225
|
_pressure = [actionItem objectForKey:FB_ACTION_ITEM_KEY_PRESSURE];
|
|
230
226
|
}
|
|
@@ -315,10 +311,6 @@ static NSString *const FB_KEY_ACTIONS = @"actions";
|
|
|
315
311
|
}
|
|
316
312
|
|
|
317
313
|
if (nil != element) {
|
|
318
|
-
// Application origins need viewport display correction; other elements use their own display.
|
|
319
|
-
// This correction does not fix XCTest's legacy-SDK compatibility issue:
|
|
320
|
-
// see docs/multiple-displays.md#legacy-sdk-compatibility-windows.
|
|
321
|
-
self.usesDisplayCorrection = element.elementType == XCUIElementTypeApplication;
|
|
322
314
|
if (nil == x && nil == y) {
|
|
323
315
|
return [self hitpointWithElement:element positionOffset:nil error:error];
|
|
324
316
|
}
|
|
@@ -326,7 +318,6 @@ static NSString *const FB_KEY_ACTIONS = @"actions";
|
|
|
326
318
|
}
|
|
327
319
|
|
|
328
320
|
if ([origin isKindOfClass:NSString.class] && [origin isEqualToString:FB_ORIGIN_TYPE_VIEWPORT]) {
|
|
329
|
-
self.usesDisplayCorrection = YES;
|
|
330
321
|
return [self hitpointWithElement:nil positionOffset:[NSValue valueWithCGPoint:CGPointMake(x.floatValue, y.floatValue)] error:error];
|
|
331
322
|
}
|
|
332
323
|
|
|
@@ -678,10 +669,6 @@ static NSString *const FB_KEY_ACTIONS = @"actions";
|
|
|
678
669
|
@end
|
|
679
670
|
|
|
680
671
|
|
|
681
|
-
@interface FBW3CActionsSynthesizer ()
|
|
682
|
-
@property (nonatomic) CGVector displayCorrection;
|
|
683
|
-
@end
|
|
684
|
-
|
|
685
672
|
@implementation FBW3CActionsSynthesizer
|
|
686
673
|
|
|
687
674
|
- (NSArray<NSDictionary<NSString *, id> *> *)preprocessedActionItemsWith:(NSArray<NSDictionary<NSString *, id> *> *)actionItems
|
|
@@ -798,7 +785,10 @@ static NSString *const FB_KEY_ACTIONS = @"actions";
|
|
|
798
785
|
return [chain asEventPathsWithError:error];
|
|
799
786
|
}
|
|
800
787
|
|
|
801
|
-
- (nullable NSArray<XCPointerEventPath *> *)eventPathsWithGestureAction:(NSDictionary<NSString *, id> *)actionDescription
|
|
788
|
+
- (nullable NSArray<XCPointerEventPath *> *)eventPathsWithGestureAction:(NSDictionary<NSString *, id> *)actionDescription
|
|
789
|
+
forActionId:(NSString *)actionId
|
|
790
|
+
coordinateContext:(FBGestureCoordinateContext *)coordinateContext
|
|
791
|
+
error:(NSError **)error
|
|
802
792
|
{
|
|
803
793
|
static NSDictionary<NSString *, Class> *gestureItemsMapping;
|
|
804
794
|
static NSArray<NSString *> *supportedActionItemTypes;
|
|
@@ -861,19 +851,21 @@ static NSString *const FB_KEY_ACTIONS = @"actions";
|
|
|
861
851
|
return nil;
|
|
862
852
|
}
|
|
863
853
|
|
|
864
|
-
FBW3CGestureItem *gestureItem = [[gestureItemClass alloc] initWithActionItem:actionItem application:self.application previousItem:[chain.items lastObject] offset:chain.durationOffset error:error];
|
|
854
|
+
FBW3CGestureItem *gestureItem = [[gestureItemClass alloc] initWithActionItem:actionItem application:self.application previousItem:[chain.items lastObject] coordinateContext:coordinateContext offset:chain.durationOffset error:error];
|
|
865
855
|
if (nil == gestureItem) {
|
|
866
856
|
return nil;
|
|
867
857
|
}
|
|
868
858
|
|
|
869
|
-
gestureItem.displayCorrection = self.displayCorrection;
|
|
870
859
|
[chain addItem:gestureItem];
|
|
871
860
|
}
|
|
872
861
|
|
|
873
862
|
return [chain asEventPathsWithError:error];
|
|
874
863
|
}
|
|
875
864
|
|
|
876
|
-
- (nullable NSArray<XCPointerEventPath *> *)eventPathsWithActionDescription:(NSDictionary<NSString *, id> *)actionDescription
|
|
865
|
+
- (nullable NSArray<XCPointerEventPath *> *)eventPathsWithActionDescription:(NSDictionary<NSString *, id> *)actionDescription
|
|
866
|
+
forActionId:(NSString *)actionId
|
|
867
|
+
coordinateContext:(FBGestureCoordinateContext *)coordinateContext
|
|
868
|
+
error:(NSError **)error
|
|
877
869
|
{
|
|
878
870
|
id actionType = [actionDescription objectForKey:FB_KEY_TYPE];
|
|
879
871
|
if (![actionType isKindOfClass:NSString.class] ||
|
|
@@ -887,7 +879,7 @@ static NSString *const FB_KEY_ACTIONS = @"actions";
|
|
|
887
879
|
}
|
|
888
880
|
|
|
889
881
|
if ([actionType isEqualToString:FB_ACTION_TYPE_POINTER]) {
|
|
890
|
-
return [self eventPathsWithGestureAction:actionDescription forActionId:actionId error:error];
|
|
882
|
+
return [self eventPathsWithGestureAction:actionDescription forActionId:actionId coordinateContext:coordinateContext error:error];
|
|
891
883
|
}
|
|
892
884
|
|
|
893
885
|
return [self eventPathsWithKeyAction:actionDescription forActionId:actionId error:error];
|
|
@@ -947,41 +939,25 @@ static NSString *const FB_KEY_ACTIONS = @"actions";
|
|
|
947
939
|
return NO;
|
|
948
940
|
}
|
|
949
941
|
|
|
950
|
-
- (nullable XCSynthesizedEventRecord *)
|
|
951
|
-
|
|
942
|
+
- (nullable XCSynthesizedEventRecord *)eventRecordForContext:(FBGestureCoordinateContext *)coordinateContext
|
|
943
|
+
error:(NSError **)error
|
|
952
944
|
{
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
945
|
+
XCUIScreen *screen = coordinateContext.screen;
|
|
946
|
+
if (coordinateContext.usesWindowCoordinates
|
|
947
|
+
&& [XCSynthesizedEventRecord instancesRespondToSelector:@selector(initWithName:displayID:interfaceOrientation:)]) {
|
|
948
|
+
return [[XCSynthesizedEventRecord alloc] initWithName:@"W3C Touch Action"
|
|
949
|
+
displayID:(unsigned long long)screen.displayID
|
|
950
|
+
interfaceOrientation:self.application.interfaceOrientation];
|
|
958
951
|
}
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
interfaceOrientation:self.application.interfaceOrientation];
|
|
964
|
-
} else {
|
|
965
|
-
if (![XCSynthesizedEventRecord instancesRespondToSelector:@selector(initWithName:displayID:interfaceOrientation:)]) {
|
|
966
|
-
if (error) {
|
|
967
|
-
*error = [[FBErrorBuilder.builder
|
|
968
|
-
withDescription:@"Actions on a display other than the main one are not supported by this XCTest version"] build];
|
|
969
|
-
}
|
|
970
|
-
return nil;
|
|
952
|
+
if (screen.displayID != XCUIScreen.mainScreen.displayID) {
|
|
953
|
+
if (error) {
|
|
954
|
+
*error = [[FBErrorBuilder.builder
|
|
955
|
+
withDescription:@"Actions on a display other than the main one are not supported by this XCTest version"] build];
|
|
971
956
|
}
|
|
972
|
-
|
|
973
|
-
displayID:(unsigned long long)screen.displayID
|
|
974
|
-
interfaceOrientation:self.application.interfaceOrientation];
|
|
975
|
-
// Viewport coordinates use the main display's size when rotating screenPoint.
|
|
976
|
-
// Element coordinates already use their own display. Apply this correction
|
|
977
|
-
// per gesture item so mixed origins and pointer-relative moves stay aligned.
|
|
978
|
-
XCUIScreen *mainScreen = XCUIScreen.mainScreen;
|
|
979
|
-
self.displayCorrection = FBDisplayCoordinateOffset(
|
|
980
|
-
CGSizeMake(mainScreen.bounds.size.width / mainScreen.scale, mainScreen.bounds.size.height / mainScreen.scale),
|
|
981
|
-
CGSizeMake(screen.bounds.size.width / screen.scale, screen.bounds.size.height / screen.scale),
|
|
982
|
-
eventRecord.interfaceOrientation);
|
|
957
|
+
return nil;
|
|
983
958
|
}
|
|
984
|
-
return
|
|
959
|
+
return [[XCSynthesizedEventRecord alloc] initWithName:@"W3C Touch Action"
|
|
960
|
+
interfaceOrientation:self.application.interfaceOrientation];
|
|
985
961
|
}
|
|
986
962
|
|
|
987
963
|
- (nullable XCSynthesizedEventRecord *)synthesizeWithError:(NSError **)error
|
|
@@ -990,13 +966,19 @@ static NSString *const FB_KEY_ACTIONS = @"actions";
|
|
|
990
966
|
if (nil == actions) {
|
|
991
967
|
return nil;
|
|
992
968
|
}
|
|
993
|
-
|
|
969
|
+
// A fresh context owns routing and anchors for every pointer source in this command.
|
|
970
|
+
FBGestureCoordinateContext *coordinateContext = [FBGestureCoordinateContext
|
|
971
|
+
contextWithDisplayRequired:[self actionsRequireDisplay:actions] error:error];
|
|
972
|
+
if (nil == coordinateContext) {
|
|
973
|
+
return nil;
|
|
974
|
+
}
|
|
975
|
+
XCSynthesizedEventRecord *eventRecord = [self eventRecordForContext:coordinateContext error:error];
|
|
994
976
|
if (nil == eventRecord) {
|
|
995
977
|
return nil;
|
|
996
978
|
}
|
|
997
979
|
for (NSDictionary<NSString *, id> *actionDescription in actions) {
|
|
998
980
|
NSString *actionId = actionDescription[FB_KEY_ID];
|
|
999
|
-
NSArray<XCPointerEventPath *> *eventPaths = [self eventPathsWithActionDescription:actionDescription forActionId:actionId error:error];
|
|
981
|
+
NSArray<XCPointerEventPath *> *eventPaths = [self eventPathsWithActionDescription:actionDescription forActionId:actionId coordinateContext:coordinateContext error:error];
|
|
1000
982
|
if (nil == eventPaths) {
|
|
1001
983
|
return nil;
|
|
1002
984
|
}
|
|
@@ -7,18 +7,28 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
#import <XCTest/XCTest.h>
|
|
10
|
+
#import <objc/runtime.h>
|
|
10
11
|
|
|
11
12
|
#import "FBIntegrationTestCase.h"
|
|
12
13
|
#import "FBConfiguration.h"
|
|
13
14
|
#import "FBScreen.h"
|
|
15
|
+
#import "FBGestureCoordinateContext.h"
|
|
14
16
|
#import "FBRunLoopSpinner.h"
|
|
15
17
|
#import "FBExceptions.h"
|
|
16
18
|
#import "FBElementCommands.h"
|
|
17
19
|
#import "FBElementCache.h"
|
|
20
|
+
#import "FBBaseActionsSynthesizer.h"
|
|
21
|
+
#import "FBW3CActionsSynthesizer.h"
|
|
22
|
+
#import "FBMathUtils.h"
|
|
18
23
|
#import "XCUIElement+FBWebDriverAttributes.h"
|
|
19
24
|
|
|
20
25
|
@interface FBElementCommands (CoordinateTests)
|
|
21
26
|
+ (nullable XCUICoordinate *)gestureCoordinateWithOffset:(CGVector)offset element:(XCUIElement *)element error:(NSError **)error;
|
|
27
|
+
+ (nullable NSArray<XCUICoordinate *> *)gestureCoordinatesWithOffsets:(NSArray<NSValue *> *)offsets element:(XCUIElement *)element error:(NSError **)error;
|
|
28
|
+
@end
|
|
29
|
+
|
|
30
|
+
@interface FBGestureCoordinateContext (CoordinateTests)
|
|
31
|
+
+ (nullable id)windowAnchorWithApplication:(XCUIElement *)application screen:(XCUIScreen *)screen error:(NSError **)error;
|
|
22
32
|
@end
|
|
23
33
|
|
|
24
34
|
#import "XCUIApplication+FBTouchAction.h"
|
|
@@ -26,6 +36,11 @@
|
|
|
26
36
|
#import "XCUIDevice+FBRotation.h"
|
|
27
37
|
#import "XCUIDevice+FBHinge.h"
|
|
28
38
|
|
|
39
|
+
// The private gesture item is exercised directly to isolate origin resolution.
|
|
40
|
+
@interface FBW3CGestureItem : FBBaseGestureItem
|
|
41
|
+
@property (nonatomic) FBGestureCoordinateContext *coordinateContext;
|
|
42
|
+
@end
|
|
43
|
+
|
|
29
44
|
@interface FBDisplayGestureTests : FBIntegrationTestCase
|
|
30
45
|
@property (nonatomic) NSNumber *previousDisplayId;
|
|
31
46
|
@property (nonatomic) XCUIElement *canvas;
|
|
@@ -234,7 +249,7 @@
|
|
|
234
249
|
NSArray<NSNumber *> *frame = [self measurement][@"canvasWindowRect"];
|
|
235
250
|
BOOL checkedSecondaryDisplay = NO;
|
|
236
251
|
for (NSDictionary *screen in [FBScreen screensWithError:nil]) {
|
|
237
|
-
if ([screen[@"
|
|
252
|
+
if ([screen[@"displayId"] isEqual:fixtureDisplay]) {
|
|
238
253
|
continue;
|
|
239
254
|
}
|
|
240
255
|
checkedSecondaryDisplay = YES;
|
|
@@ -251,6 +266,261 @@
|
|
|
251
266
|
XCTSkipIf(!checkedSecondaryDisplay, @"Requires an available secondary display without the fixture");
|
|
252
267
|
}
|
|
253
268
|
|
|
269
|
+
- (void)testApplicationOriginUsesItsOwnAppInsteadOfTheSessionApp
|
|
270
|
+
{
|
|
271
|
+
XCTSkipIf(![FBScreen hasMultipleScreensWithError:nil].boolValue, @"Requires multiple displays");
|
|
272
|
+
FBW3CGestureItem *item = [NSClassFromString(@"FBW3CGestureItem") new];
|
|
273
|
+
// Accessing this app's windows would fail. Only the supplied origin should be used.
|
|
274
|
+
item.application = [[XCUIApplication alloc] initWithBundleIdentifier:@"com.appium.nonexistent-session-app"];
|
|
275
|
+
NSError *error = nil;
|
|
276
|
+
item.coordinateContext = [FBGestureCoordinateContext contextWithDisplayRequired:YES error:&error];
|
|
277
|
+
XCTAssertNotNil(item.coordinateContext);
|
|
278
|
+
XCUICoordinate *coordinate = [item hitpointWithElement:self.testedApplication
|
|
279
|
+
positionOffset:[NSValue valueWithCGPoint:CGPointZero] error:&error];
|
|
280
|
+
XCTAssertNotNil(coordinate);
|
|
281
|
+
XCTAssertNil(error);
|
|
282
|
+
CGRect frame = self.testedApplication.wdFrame;
|
|
283
|
+
XCUICoordinate *expected = [item.coordinateContext coordinateWithApplication:self.testedApplication
|
|
284
|
+
offset:CGVectorMake(CGRectGetMidX(frame), CGRectGetMidY(frame)) error:&error];
|
|
285
|
+
XCTAssertNotNil(expected);
|
|
286
|
+
XCTAssertEqualWithAccuracy(coordinate.screenPoint.x, expected.screenPoint.x, 1);
|
|
287
|
+
XCTAssertEqualWithAccuracy(coordinate.screenPoint.y, expected.screenPoint.y, 1);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
- (void)testSingleDisplayW3COriginsRetainLegacyCoordinates
|
|
291
|
+
{
|
|
292
|
+
XCTSkipIf([FBScreen hasMultipleScreensWithError:nil].boolValue, @"Requires a single display");
|
|
293
|
+
FBW3CGestureItem *item = [NSClassFromString(@"FBW3CGestureItem") new];
|
|
294
|
+
item.application = self.testedApplication;
|
|
295
|
+
item.coordinateContext = [FBGestureCoordinateContext contextWithDisplayRequired:YES error:nil];
|
|
296
|
+
XCTAssertNotNil(item.coordinateContext);
|
|
297
|
+
FBBaseGestureItem *legacy = [FBBaseGestureItem new];
|
|
298
|
+
legacy.application = self.testedApplication;
|
|
299
|
+
for (NSNumber *orientation in @[@(UIDeviceOrientationPortrait), @(UIDeviceOrientationLandscapeLeft), @(UIDeviceOrientationLandscapeRight)]) {
|
|
300
|
+
[XCUIDevice.sharedDevice fb_setDeviceInterfaceOrientation:orientation.integerValue];
|
|
301
|
+
NSError *error = nil;
|
|
302
|
+
NSValue *offset = [NSValue valueWithCGPoint:CGPointMake(30, 40)];
|
|
303
|
+
XCUICoordinate *viewport = [item hitpointWithElement:nil positionOffset:offset error:&error];
|
|
304
|
+
XCUICoordinate *expectedViewport = [legacy hitpointWithElement:nil positionOffset:offset error:&error];
|
|
305
|
+
XCTAssertNotNil(viewport);
|
|
306
|
+
XCTAssertTrue(CGPointEqualToPoint(viewport.screenPoint, expectedViewport.screenPoint));
|
|
307
|
+
XCUICoordinate *app = [item hitpointWithElement:self.testedApplication positionOffset:nil error:&error];
|
|
308
|
+
XCUICoordinate *expectedApp = [legacy hitpointWithElement:self.testedApplication positionOffset:nil error:&error];
|
|
309
|
+
XCTAssertNotNil(app);
|
|
310
|
+
XCTAssertTrue(CGPointEqualToPoint(app.screenPoint, expectedApp.screenPoint));
|
|
311
|
+
XCUICoordinate *appOffset = [item hitpointWithElement:self.testedApplication positionOffset:offset error:&error];
|
|
312
|
+
XCUICoordinate *expectedAppOffset = FBCoordinateWithAnchorOffset(self.testedApplication,
|
|
313
|
+
CGVectorMake(0.5, 0.5), CGVectorMake(30, 40), &error);
|
|
314
|
+
XCTAssertNotNil(appOffset);
|
|
315
|
+
XCTAssertTrue(CGPointEqualToPoint(appOffset.screenPoint, expectedAppOffset.screenPoint));
|
|
316
|
+
XCTAssertNil(error);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
- (void)testDisplayAndWindowResolutionRunsOncePerCommand
|
|
321
|
+
{
|
|
322
|
+
BOOL hasMultipleScreens = [FBScreen hasMultipleScreensWithError:nil].boolValue;
|
|
323
|
+
SEL selector = @selector(hasMultipleScreensWithError:);
|
|
324
|
+
Method method = class_getClassMethod(FBScreen.class, selector);
|
|
325
|
+
IMP original = method_getImplementation(method);
|
|
326
|
+
__block NSUInteger calls = 0;
|
|
327
|
+
IMP counting = imp_implementationWithBlock(^NSNumber *(id receiver, NSError **error) {
|
|
328
|
+
calls++;
|
|
329
|
+
return ((NSNumber *(*)(id, SEL, NSError **))original)(receiver, selector, error);
|
|
330
|
+
});
|
|
331
|
+
SEL anchorSelector = @selector(windowAnchorWithApplication:screen:error:);
|
|
332
|
+
Method anchorMethod = class_getClassMethod(FBGestureCoordinateContext.class, anchorSelector);
|
|
333
|
+
IMP originalAnchor = method_getImplementation(anchorMethod);
|
|
334
|
+
__block NSUInteger anchorCalls = 0;
|
|
335
|
+
IMP countingAnchors = imp_implementationWithBlock(^id(id receiver, XCUIElement *application, XCUIScreen *screen, NSError **error) {
|
|
336
|
+
anchorCalls++;
|
|
337
|
+
return ((id (*)(id, SEL, XCUIElement *, XCUIScreen *, NSError **))originalAnchor)(receiver, anchorSelector, application, screen, error);
|
|
338
|
+
});
|
|
339
|
+
method_setImplementation(method, counting);
|
|
340
|
+
method_setImplementation(anchorMethod, countingAnchors);
|
|
341
|
+
@try {
|
|
342
|
+
// Exercise serialized origins and sharing between independent pointer sources.
|
|
343
|
+
self.actionElementCache = [FBElementCache new];
|
|
344
|
+
NSDictionary *finger = @{
|
|
345
|
+
@"type": @"pointer", @"id": @"finger", @"parameters": @{@"pointerType": @"touch"},
|
|
346
|
+
@"actions": @[
|
|
347
|
+
[self moveFrom:@"viewport" x:100 y:100 duration:0],
|
|
348
|
+
[self moveFrom:self.testedApplication x:0 y:0 duration:100],
|
|
349
|
+
[self moveFrom:self.canvas x:0 y:0 duration:100],
|
|
350
|
+
[self moveFrom:@"pointer" x:10 y:10 duration:100],
|
|
351
|
+
[self moveFrom:@"viewport" x:120 y:120 duration:100],
|
|
352
|
+
],
|
|
353
|
+
};
|
|
354
|
+
NSMutableDictionary *secondFinger = finger.mutableCopy;
|
|
355
|
+
secondFinger[@"id"] = @"secondFinger";
|
|
356
|
+
NSError *error = nil;
|
|
357
|
+
FBW3CActionsSynthesizer *synthesizer = [[FBW3CActionsSynthesizer alloc]
|
|
358
|
+
initWithActions:@[finger, secondFinger] forApplication:self.testedApplication elementCache:self.actionElementCache error:&error];
|
|
359
|
+
// Even the same synthesizer must resolve a fresh anchor for each command.
|
|
360
|
+
for (NSUInteger invocation = 1; invocation <= 2; invocation++) {
|
|
361
|
+
XCTAssertNotNil([synthesizer synthesizeWithError:&error]);
|
|
362
|
+
XCTAssertNil(error);
|
|
363
|
+
XCTAssertEqual(calls, invocation);
|
|
364
|
+
XCTAssertEqual(anchorCalls, hasMultipleScreens ? invocation : 0);
|
|
365
|
+
}
|
|
366
|
+
NSArray<NSValue *> *offsets = @[
|
|
367
|
+
[NSValue valueWithCGVector:CGVectorMake(100, 100)],
|
|
368
|
+
[NSValue valueWithCGVector:CGVectorMake(120, 120)],
|
|
369
|
+
];
|
|
370
|
+
// A native drag shares one resolution between its endpoints, on iPhone too.
|
|
371
|
+
for (NSUInteger invocation = 3; invocation <= 4; invocation++) {
|
|
372
|
+
NSArray<XCUICoordinate *> *coordinates = [FBElementCommands gestureCoordinatesWithOffsets:offsets
|
|
373
|
+
element:self.testedApplication error:&error];
|
|
374
|
+
XCTAssertEqual(coordinates.count, 2);
|
|
375
|
+
XCTAssertNil(error);
|
|
376
|
+
XCTAssertEqual(calls, invocation);
|
|
377
|
+
XCTAssertEqual(anchorCalls, hasMultipleScreens ? invocation : 0);
|
|
378
|
+
}
|
|
379
|
+
XCTAssertEqual([FBElementCommands gestureCoordinatesWithOffsets:offsets element:self.canvas error:&error].count, 2);
|
|
380
|
+
XCTAssertNil(error);
|
|
381
|
+
XCTAssertEqual(calls, 4); // Ordinary element gestures do not enumerate displays.
|
|
382
|
+
XCTAssertEqual(anchorCalls, hasMultipleScreens ? 4 : 0);
|
|
383
|
+
} @finally {
|
|
384
|
+
method_setImplementation(method, original);
|
|
385
|
+
method_setImplementation(anchorMethod, originalAnchor);
|
|
386
|
+
imp_removeBlock(counting);
|
|
387
|
+
imp_removeBlock(countingAnchors);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
- (void)testWindowAnchorCacheDoesNotHideAnotherApplicationsFailure
|
|
392
|
+
{
|
|
393
|
+
XCTSkipIf(![FBScreen hasMultipleScreensWithError:nil].boolValue, @"Requires multiple displays");
|
|
394
|
+
XCUIApplication *otherApplication = self.springboard;
|
|
395
|
+
NSError *expectedError = [NSError errorWithDomain:@"WindowAnchorLookup" code:1 userInfo:nil];
|
|
396
|
+
SEL selector = @selector(windowAnchorWithApplication:screen:error:);
|
|
397
|
+
Method method = class_getClassMethod(FBGestureCoordinateContext.class, selector);
|
|
398
|
+
IMP original = method_getImplementation(method);
|
|
399
|
+
__block NSUInteger sessionAppCalls = 0;
|
|
400
|
+
__block NSUInteger otherAppCalls = 0;
|
|
401
|
+
IMP replacement = imp_implementationWithBlock(^id(id receiver, XCUIElement *application, XCUIScreen *screen, NSError **error) {
|
|
402
|
+
if (application == otherApplication) {
|
|
403
|
+
otherAppCalls++;
|
|
404
|
+
if (NULL != error) {
|
|
405
|
+
*error = expectedError;
|
|
406
|
+
}
|
|
407
|
+
return nil;
|
|
408
|
+
}
|
|
409
|
+
sessionAppCalls++;
|
|
410
|
+
return ((id (*)(id, SEL, XCUIElement *, XCUIScreen *, NSError **))original)(receiver, selector, application, screen, error);
|
|
411
|
+
});
|
|
412
|
+
method_setImplementation(method, replacement);
|
|
413
|
+
@try {
|
|
414
|
+
NSArray *actions = @[@{
|
|
415
|
+
@"type": @"pointer", @"id": @"finger", @"parameters": @{@"pointerType": @"touch"},
|
|
416
|
+
@"actions": @[
|
|
417
|
+
[self moveFrom:@"viewport" x:100 y:100 duration:0],
|
|
418
|
+
[self moveFrom:self.testedApplication x:0 y:0 duration:100],
|
|
419
|
+
[self moveFrom:otherApplication x:0 y:0 duration:100],
|
|
420
|
+
],
|
|
421
|
+
}];
|
|
422
|
+
NSError *error = nil;
|
|
423
|
+
FBW3CActionsSynthesizer *synthesizer = [[FBW3CActionsSynthesizer alloc]
|
|
424
|
+
initWithActions:actions forApplication:self.testedApplication elementCache:nil error:&error];
|
|
425
|
+
XCTAssertNil([synthesizer synthesizeWithError:&error]);
|
|
426
|
+
XCTAssertEqualObjects(error, expectedError);
|
|
427
|
+
XCTAssertEqual(sessionAppCalls, 1);
|
|
428
|
+
XCTAssertEqual(otherAppCalls, 1);
|
|
429
|
+
} @finally {
|
|
430
|
+
method_setImplementation(method, original);
|
|
431
|
+
imp_removeBlock(replacement);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
- (void)testMixedOriginsRejectAnElementOnAnotherDisplay
|
|
436
|
+
{
|
|
437
|
+
NSNumber *fixtureDisplay = FBConfiguration.sharedInstance.currentDisplayId;
|
|
438
|
+
BOOL checkedOtherDisplay = NO;
|
|
439
|
+
for (NSDictionary *screen in [FBScreen screensWithError:nil]) {
|
|
440
|
+
if ([screen[@"displayId"] isEqual:fixtureDisplay]) {
|
|
441
|
+
continue;
|
|
442
|
+
}
|
|
443
|
+
checkedOtherDisplay = YES;
|
|
444
|
+
FBConfiguration.sharedInstance.currentDisplayId = screen[@"displayId"];
|
|
445
|
+
NSArray *actions = @[@{
|
|
446
|
+
@"type": @"pointer", @"id": @"finger", @"parameters": @{@"pointerType": @"touch"},
|
|
447
|
+
@"actions": @[
|
|
448
|
+
[self moveFrom:self.canvas x:0 y:0 duration:0],
|
|
449
|
+
[self moveFrom:@"viewport" x:100 y:100 duration:0],
|
|
450
|
+
[self moveFrom:@"pointer" x:10 y:10 duration:0],
|
|
451
|
+
],
|
|
452
|
+
}];
|
|
453
|
+
NSError *error = nil;
|
|
454
|
+
FBW3CActionsSynthesizer *synthesizer = [[FBW3CActionsSynthesizer alloc]
|
|
455
|
+
initWithActions:actions forApplication:self.testedApplication elementCache:nil error:&error];
|
|
456
|
+
XCTAssertNil([synthesizer synthesizeWithError:&error]);
|
|
457
|
+
XCTAssertNotNil(error);
|
|
458
|
+
XCTAssertTrue([error.localizedDescription containsString:@"element origin is not on the selected display"]);
|
|
459
|
+
}
|
|
460
|
+
XCTSkipIf(!checkedOtherDisplay, @"Requires another display without the fixture");
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
- (void)testDisplayEnumerationFailureStopsGestureResolution
|
|
464
|
+
{
|
|
465
|
+
NSError *expectedError = [NSError errorWithDomain:@"DisplayEnumeration" code:1 userInfo:nil];
|
|
466
|
+
SEL selector = @selector(hasMultipleScreensWithError:);
|
|
467
|
+
Method method = class_getClassMethod(FBScreen.class, selector);
|
|
468
|
+
IMP original = method_getImplementation(method);
|
|
469
|
+
IMP replacement = imp_implementationWithBlock(^NSNumber *(id receiver, NSError **error) {
|
|
470
|
+
if (NULL != error) {
|
|
471
|
+
*error = expectedError;
|
|
472
|
+
}
|
|
473
|
+
return nil;
|
|
474
|
+
});
|
|
475
|
+
method_setImplementation(method, replacement);
|
|
476
|
+
@try {
|
|
477
|
+
NSError *error = nil;
|
|
478
|
+
NSArray *offsets = @[[NSValue valueWithCGVector:CGVectorMake(100, 100)],
|
|
479
|
+
[NSValue valueWithCGVector:CGVectorMake(120, 120)]];
|
|
480
|
+
XCTAssertNil([FBElementCommands gestureCoordinatesWithOffsets:offsets element:self.testedApplication error:&error]);
|
|
481
|
+
XCTAssertEqualObjects(error, expectedError);
|
|
482
|
+
error = nil;
|
|
483
|
+
NSArray *actions = @[@{
|
|
484
|
+
@"type": @"pointer", @"id": @"finger", @"parameters": @{@"pointerType": @"touch"},
|
|
485
|
+
@"actions": @[[self moveFrom:@"viewport" x:100 y:100 duration:0]],
|
|
486
|
+
}];
|
|
487
|
+
FBW3CActionsSynthesizer *synthesizer = [[FBW3CActionsSynthesizer alloc]
|
|
488
|
+
initWithActions:actions forApplication:self.testedApplication elementCache:nil error:&error];
|
|
489
|
+
XCTAssertNil([synthesizer synthesizeWithError:&error]);
|
|
490
|
+
XCTAssertEqualObjects(error, expectedError);
|
|
491
|
+
} @finally {
|
|
492
|
+
method_setImplementation(method, original);
|
|
493
|
+
imp_removeBlock(replacement);
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
- (void)verifyNativeDragCoordinates
|
|
498
|
+
{
|
|
499
|
+
NSDictionary *geometry = [self measurement];
|
|
500
|
+
NSArray<NSNumber *> *bounds = geometry[@"canvasBounds"];
|
|
501
|
+
NSArray<NSNumber *> *frame = geometry[@"canvasWindowRect"];
|
|
502
|
+
CGPoint end = CGPointMake(bounds[0].doubleValue / 2, bounds[1].doubleValue / 2 - 40);
|
|
503
|
+
CGVector endOffset = CGVectorMake(frame[0].doubleValue + end.x, frame[1].doubleValue + end.y);
|
|
504
|
+
CGVector startOffset = CGVectorMake(endOffset.dx, endOffset.dy + 40);
|
|
505
|
+
NSError *error = nil;
|
|
506
|
+
NSArray<XCUICoordinate *> *coordinates = [FBElementCommands gestureCoordinatesWithOffsets:
|
|
507
|
+
@[[NSValue valueWithCGVector:startOffset], [NSValue valueWithCGVector:endOffset]]
|
|
508
|
+
element:self.testedApplication error:&error];
|
|
509
|
+
XCTAssertEqual(coordinates.count, 2);
|
|
510
|
+
XCTAssertNil(error);
|
|
511
|
+
[coordinates[0] pressForDuration:0.1 thenDragToCoordinate:coordinates[1]];
|
|
512
|
+
NSDictionary *result = [self measurement];
|
|
513
|
+
XCTAssertEqual([result[@"count"] unsignedIntegerValue], [geometry[@"count"] unsignedIntegerValue] + 1);
|
|
514
|
+
XCTAssertEqualObjects(result[@"phase"], @"ended");
|
|
515
|
+
XCTAssertEqualWithAccuracy([result[@"last"][0] doubleValue], end.x, 1);
|
|
516
|
+
XCTAssertEqualWithAccuracy([result[@"last"][1] doubleValue], end.y, 1);
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
- (void)testNativeDragCoordinates
|
|
520
|
+
{
|
|
521
|
+
[self verifyNativeDragCoordinates];
|
|
522
|
+
}
|
|
523
|
+
|
|
254
524
|
- (void)testNativeCoordinatesAcrossFoldStates
|
|
255
525
|
{
|
|
256
526
|
XCUIDevice *device = XCUIDevice.sharedDevice;
|
|
@@ -271,6 +541,7 @@
|
|
|
271
541
|
[self selectFixtureDisplay];
|
|
272
542
|
[self verifyNativeApplicationCoordinates];
|
|
273
543
|
[self verifyNativeEdgeCoordinates];
|
|
544
|
+
[self verifyNativeDragCoordinates];
|
|
274
545
|
}
|
|
275
546
|
}
|
|
276
547
|
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
@end
|
|
31
31
|
|
|
32
32
|
@interface FBScreen (FBLookupTesting)
|
|
33
|
+
+ (nullable NSNumber *)hasMultipleScreensForDevice:(id)device error:(NSError **)error;
|
|
33
34
|
+ (nullable XCUIScreen *)screenWithDisplayID:(long long)displayID device:(id)device error:(NSError **)error;
|
|
34
35
|
@end
|
|
35
36
|
|
|
@@ -142,6 +143,32 @@
|
|
|
142
143
|
XCTAssertTrue([error.localizedDescription containsString:availableDisplays]);
|
|
143
144
|
}
|
|
144
145
|
|
|
146
|
+
- (void)testDisplayCountDoesNotTreatEnumerationFailureAsSingleDisplay
|
|
147
|
+
{
|
|
148
|
+
FBScreenDeviceDouble *device = [FBScreenDeviceDouble new];
|
|
149
|
+
device.enumerationError = [NSError errorWithDomain:@"Enumeration" code:2 userInfo:nil];
|
|
150
|
+
NSError *error = nil;
|
|
151
|
+
XCTAssertNil([FBScreen hasMultipleScreensForDevice:device error:&error]);
|
|
152
|
+
XCTAssertEqualObjects(error, device.enumerationError);
|
|
153
|
+
|
|
154
|
+
device.enumerationError = nil;
|
|
155
|
+
error = nil;
|
|
156
|
+
XCTAssertNil([FBScreen hasMultipleScreensForDevice:device error:&error]);
|
|
157
|
+
XCTAssertNotNil(error);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
- (void)testDisplayCountDistinguishesSingleAndMultipleDisplays
|
|
161
|
+
{
|
|
162
|
+
FBScreenDeviceDouble *device = [FBScreenDeviceDouble new];
|
|
163
|
+
device.screens = @[XCUIScreen.mainScreen];
|
|
164
|
+
NSError *error = nil;
|
|
165
|
+
XCTAssertEqualObjects([FBScreen hasMultipleScreensForDevice:device error:&error], @NO);
|
|
166
|
+
XCTAssertNil(error);
|
|
167
|
+
device.screens = @[XCUIScreen.mainScreen, XCUIScreen.mainScreen];
|
|
168
|
+
XCTAssertEqualObjects([FBScreen hasMultipleScreensForDevice:device error:&error], @YES);
|
|
169
|
+
XCTAssertNil(error);
|
|
170
|
+
}
|
|
171
|
+
|
|
145
172
|
- (void)testNativeScreenLookupDoesNotEnumerateOnSuccess
|
|
146
173
|
{
|
|
147
174
|
FBScreenDeviceDouble *device = [FBScreenDeviceDouble new];
|
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
|
|
11
11
|
#import "FBIntegrationTestCase.h"
|
|
12
12
|
#import "FBConfiguration.h"
|
|
13
|
-
#import "FBMathUtils.h"
|
|
14
13
|
#import "FBScreen.h"
|
|
15
14
|
|
|
16
15
|
#import "XCUIElement.h"
|
|
16
|
+
#import "XCUIElement+FBWebDriverAttributes.h"
|
|
17
17
|
#import "XCUIDevice.h"
|
|
18
18
|
#import "XCUIApplication+FBTouchAction.h"
|
|
19
19
|
#import "FBTestMacros.h"
|
|
@@ -167,21 +167,32 @@
|
|
|
167
167
|
if (nil == secondary) {
|
|
168
168
|
XCTSkip(@"The device has no secondary display");
|
|
169
169
|
}
|
|
170
|
-
XCSynthesizedEventRecord *baseline = [self tapRecordWithError:&error];
|
|
171
170
|
FBConfiguration.sharedInstance.currentDisplayId = @(secondary.displayID);
|
|
171
|
+
XCUIElement *anchor = nil;
|
|
172
|
+
for (XCUIElement *window in [self.testedApplication childrenMatchingType:XCUIElementTypeWindow].allElementsBoundByIndex) {
|
|
173
|
+
(void)window.frame;
|
|
174
|
+
if (window.screen.displayID == secondary.displayID && !CGRectIsEmpty(window.wdFrame)) {
|
|
175
|
+
anchor = window;
|
|
176
|
+
break;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
172
179
|
XCSynthesizedEventRecord *selected = [self tapRecordWithError:&error];
|
|
180
|
+
if (nil == anchor) {
|
|
181
|
+
XCTAssertNil(selected);
|
|
182
|
+
XCTAssertNotNil(error);
|
|
183
|
+
XCTAssertTrue([error.localizedDescription containsString:@"No non-empty application window"]);
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
173
186
|
XCTAssertNotNil(selected);
|
|
174
187
|
XCTAssertNil(error);
|
|
175
188
|
XCTAssertEqual(selected.displayID, (unsigned long long)secondary.displayID);
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
selected.interfaceOrientation);
|
|
181
|
-
CGPoint expected = [self pointerEventsOfRecord:baseline].firstObject.coordinate;
|
|
189
|
+
CGRect frame = anchor.wdFrame;
|
|
190
|
+
CGPoint expected = [anchor coordinateWithNormalizedOffset:
|
|
191
|
+
CGVectorMake((100 - frame.origin.x) / frame.size.width,
|
|
192
|
+
(100 - frame.origin.y) / frame.size.height)].screenPoint;
|
|
182
193
|
CGPoint actual = [self pointerEventsOfRecord:selected].firstObject.coordinate;
|
|
183
|
-
|
|
184
|
-
|
|
194
|
+
XCTAssertEqualWithAccuracy(actual.x, expected.x, 1);
|
|
195
|
+
XCTAssertEqualWithAccuracy(actual.y, expected.y, 1);
|
|
185
196
|
}
|
|
186
197
|
|
|
187
198
|
- (void)testErroneousGestures
|
|
@@ -148,36 +148,6 @@
|
|
|
148
148
|
XCTAssertTrue(endOffset.dx == -1 && endOffset.dy == -1);
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
-
- (void)testDisplayCoordinateOffsets
|
|
152
|
-
{
|
|
153
|
-
CGSize mainSize = CGSizeMake(402, 874);
|
|
154
|
-
CGSize innerSize = CGSizeMake(669, 951);
|
|
155
|
-
NSArray<NSNumber *> *orientations = @[
|
|
156
|
-
@(UIInterfaceOrientationPortrait),
|
|
157
|
-
@(UIInterfaceOrientationLandscapeLeft),
|
|
158
|
-
@(UIInterfaceOrientationLandscapeRight),
|
|
159
|
-
@(UIInterfaceOrientationPortraitUpsideDown),
|
|
160
|
-
];
|
|
161
|
-
NSArray<NSValue *> *expected = @[
|
|
162
|
-
[NSValue valueWithCGPoint:CGPointZero],
|
|
163
|
-
[NSValue valueWithCGPoint:CGPointMake(0, 77)],
|
|
164
|
-
[NSValue valueWithCGPoint:CGPointMake(267, 0)],
|
|
165
|
-
[NSValue valueWithCGPoint:CGPointMake(267, 77)],
|
|
166
|
-
];
|
|
167
|
-
for (NSUInteger i = 0; i < orientations.count; i++) {
|
|
168
|
-
UIInterfaceOrientation orientation = orientations[i].integerValue;
|
|
169
|
-
CGVector offset = FBDisplayCoordinateOffset(mainSize, innerSize, orientation);
|
|
170
|
-
XCTAssertEqual(offset.dx, expected[i].CGPointValue.x);
|
|
171
|
-
XCTAssertEqual(offset.dy, expected[i].CGPointValue.y);
|
|
172
|
-
CGVector sameDisplay = FBDisplayCoordinateOffset(mainSize, mainSize, orientation);
|
|
173
|
-
XCTAssertEqual(sameDisplay.dx, 0);
|
|
174
|
-
XCTAssertEqual(sameDisplay.dy, 0);
|
|
175
|
-
CGVector reverse = FBDisplayCoordinateOffset(innerSize, mainSize, orientation);
|
|
176
|
-
XCTAssertEqual(reverse.dx, -expected[i].CGPointValue.x);
|
|
177
|
-
XCTAssertEqual(reverse.dy, -expected[i].CGPointValue.y);
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
|
|
181
151
|
- (void)testPortraitVisibleFrameRotation
|
|
182
152
|
{
|
|
183
153
|
CGSize size = CGSizeMake(669, 951);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "appium-webdriveragent",
|
|
3
|
-
"version": "17.0.
|
|
3
|
+
"version": "17.0.7",
|
|
4
4
|
"description": "Package bundling WebDriverAgent",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Appium",
|
|
@@ -83,5 +83,5 @@
|
|
|
83
83
|
"node": "^22.22.2 || ^24.15.0 || >=26.0.0",
|
|
84
84
|
"npm": ">=10"
|
|
85
85
|
},
|
|
86
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "d7d177f55102776f22794034ff7337b9213610dd"
|
|
87
87
|
}
|