appium-webdriveragent 17.0.6 → 17.0.8

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 CHANGED
@@ -3,6 +3,20 @@
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.8](https://github.com/appium/appium-ios/compare/appium-webdriveragent@17.0.7...appium-webdriveragent@17.0.8) (2026-11-16)
7
+
8
+ ### Bug Fixes
9
+
10
+ * **webdriveragent:** clear screen recording state before attachment cleanup ([#115](https://github.com/appium/appium-ios/issues/115)) ([9caef7e](https://github.com/appium/appium-ios/commit/9caef7ee9a77541a785a5248576fd3266afae4a2))
11
+
12
+
13
+ ## [17.0.7](https://github.com/appium/appium-ios/compare/appium-webdriveragent@17.0.6...appium-webdriveragent@17.0.7) (2026-11-16)
14
+
15
+ ### Bug Fixes
16
+
17
+ * **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))
18
+
19
+
6
20
  ## [17.0.6](https://github.com/appium/appium-ios/compare/appium-webdriveragent@17.0.5...appium-webdriveragent@17.0.6) (2026-11-14)
7
21
 
8
22
  ### 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
- XCUICoordinate *startCoordinate = [self.class gestureCoordinateWithOffset:startOffset
362
- element:application
363
- error:&error];
364
- if (nil == startCoordinate) {
365
- return FBResponseWithStatus([FBCommandStatus invalidElementStateErrorWithMessage:error.description traceback:nil]);
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 *endCoordinate = [self.class gestureCoordinateWithOffset:endOffset element:target error:&error];
462
- if (nil == endCoordinate) {
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
- if (element.elementType != XCUIElementTypeApplication) {
711
- return FBCoordinateWithAnchorOffset(element, CGVectorMake(0, 0), offset, error);
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
- XCUIScreen *screen = [FBScreen currentScreenWithError:error];
714
- if (nil == screen) {
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
- if (screen.displayID == XCUIScreen.mainScreen.displayID) {
718
- return FBCoordinateWithAnchorOffset(element, CGVectorMake(0, 0), offset, error);
719
- }
720
- // Application-root coordinates are rotated using the main display on Duo.
721
- // A window coordinate keeps XCTest's display affinity and rotation intact.
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
- [[[FBErrorBuilder builder] withDescriptionFormat:@"No non-empty application window on display %lld is available as a coordinate anchor", screen.displayID]
736
- buildError:error];
737
- return nil;
753
+ return coordinates.copy;
738
754
  }
739
755
 
740
756
  /**
@@ -69,10 +69,10 @@ const NSUInteger DEFAULT_CODEC = 0;
69
69
  NSDictionary *response = [FBScreenRecordingContainer.sharedInstance toDictionary];
70
70
  NSError *error;
71
71
  if (![FBXCTestDaemonsProxy stopScreenRecordingWithUUID:recordingId error:&error]) {
72
- [FBScreenRecordingContainer.sharedInstance reset];
72
+ [FBScreenRecordingContainer.sharedInstance resetIfPromiseIs:activeScreenRecording];
73
73
  return FBResponseWithUnknownError(error);
74
74
  }
75
- [FBScreenRecordingContainer.sharedInstance reset];
75
+ [FBScreenRecordingContainer.sharedInstance resetIfPromiseIs:activeScreenRecording];
76
76
  return FBResponseWithObject(response);
77
77
  }
78
78
 
@@ -15,11 +15,11 @@
15
15
  <key>CFBundlePackageType</key>
16
16
  <string>FMWK</string>
17
17
  <key>CFBundleShortVersionString</key>
18
- <string>17.0.6</string>
18
+ <string>17.0.8</string>
19
19
  <key>CFBundleSignature</key>
20
20
  <string>????</string>
21
21
  <key>CFBundleVersion</key>
22
- <string>17.0.6</string>
22
+ <string>17.0.8</string>
23
23
  <key>NSPrincipalClass</key>
24
24
  <string/>
25
25
  </dict>
@@ -9,19 +9,16 @@
9
9
 
10
10
  #import "FBScreenRecordingContainer.h"
11
11
 
12
+ #import "FBLogger.h"
12
13
  #import "FBScreenRecordingPromise.h"
13
14
 
14
- @interface FBScreenRecordingContainer ()
15
-
16
- @property (readwrite) NSUInteger fps;
17
- @property (readwrite) long long codec;
18
- @property (readwrite) FBScreenRecordingPromise* screenRecordingPromise;
19
- @property (readwrite) NSNumber *startedAt;
20
-
21
- @end
22
-
23
15
  @implementation FBScreenRecordingContainer
24
16
 
17
+ @synthesize fps = _fps;
18
+ @synthesize codec = _codec;
19
+ @synthesize screenRecordingPromise = _screenRecordingPromise;
20
+ @synthesize startedAt = _startedAt;
21
+
25
22
  + (instancetype)sharedInstance
26
23
  {
27
24
  static FBScreenRecordingContainer *instance;
@@ -32,57 +29,105 @@
32
29
  return instance;
33
30
  }
34
31
 
32
+ - (NSUInteger)fps
33
+ {
34
+ @synchronized (self) {
35
+ return _fps;
36
+ }
37
+ }
38
+
39
+ - (long long)codec
40
+ {
41
+ @synchronized (self) {
42
+ return _codec;
43
+ }
44
+ }
45
+
46
+ - (nullable FBScreenRecordingPromise *)screenRecordingPromise
47
+ {
48
+ @synchronized (self) {
49
+ return _screenRecordingPromise;
50
+ }
51
+ }
52
+
53
+ - (nullable NSNumber *)startedAt
54
+ {
55
+ @synchronized (self) {
56
+ return _startedAt;
57
+ }
58
+ }
59
+
35
60
  - (void)storeScreenRecordingPromise:(FBScreenRecordingPromise *)screenRecordingPromise
36
61
  fps:(NSUInteger)fps
37
62
  codec:(long long)codec;
38
63
  {
39
64
  @synchronized (self) {
40
- self.fps = fps;
41
- self.codec = codec;
42
- self.screenRecordingPromise = screenRecordingPromise;
43
- self.startedAt = @([NSDate.date timeIntervalSince1970]);
65
+ _fps = fps;
66
+ _codec = codec;
67
+ _screenRecordingPromise = screenRecordingPromise;
68
+ _startedAt = @([NSDate.date timeIntervalSince1970]);
44
69
  }
45
70
  }
46
71
 
47
- - (void)reset;
72
+ - (nullable FBScreenRecordingPromise *)detachScreenRecordingPromise
48
73
  {
49
74
  @synchronized (self) {
50
- self.fps = 0;
51
- self.codec = 0;
52
- if (nil != self.screenRecordingPromise) {
53
- [XCTContext runActivityNamed:@"Video Cleanup" block:^(id<XCTActivity> activity){
54
- [activity addAttachment:(XCTAttachment *)self.screenRecordingPromise.nativePromise];
55
- }];
56
- self.screenRecordingPromise = nil;
57
- }
58
- self.startedAt = nil;
75
+ FBScreenRecordingPromise *detachedPromise = _screenRecordingPromise;
76
+ _fps = 0;
77
+ _codec = 0;
78
+ _screenRecordingPromise = nil;
79
+ _startedAt = nil;
80
+ return detachedPromise;
81
+ }
82
+ }
83
+
84
+ - (void)cleanupDetachedPromise:(nullable FBScreenRecordingPromise *)promise
85
+ {
86
+ if (nil == promise) {
87
+ return;
88
+ }
89
+ @try {
90
+ [XCTContext runActivityNamed:@"Video Cleanup" block:^(id<XCTActivity> activity){
91
+ [activity addAttachment:(XCTAttachment *)promise.nativePromise];
92
+ }];
93
+ } @catch (NSException *exception) {
94
+ [FBLogger logFmt:@"Failed to clean up screen recording attachment: %@", exception.reason];
59
95
  }
60
96
  }
61
97
 
98
+ - (void)reset;
99
+ {
100
+ FBScreenRecordingPromise *detachedPromise = [self detachScreenRecordingPromise];
101
+ [self cleanupDetachedPromise:detachedPromise];
102
+ }
103
+
62
104
  - (BOOL)resetIfPromiseIs:(FBScreenRecordingPromise *)screenRecordingPromise
63
105
  {
64
- // @synchronized is recursive, so -reset may take the very same lock again below.
106
+ FBScreenRecordingPromise *detachedPromise = nil;
65
107
  @synchronized (self) {
66
- if (self.screenRecordingPromise != screenRecordingPromise) {
108
+ if (_screenRecordingPromise != screenRecordingPromise) {
67
109
  return NO;
68
110
  }
69
- [self reset];
70
- return YES;
111
+ detachedPromise = [self detachScreenRecordingPromise];
71
112
  }
113
+ [self cleanupDetachedPromise:detachedPromise];
114
+ return YES;
72
115
  }
73
116
 
74
117
  - (nullable NSDictionary *)toDictionary
75
118
  {
76
- if (nil == self.screenRecordingPromise) {
77
- return nil;
78
- }
119
+ @synchronized (self) {
120
+ if (nil == _screenRecordingPromise) {
121
+ return nil;
122
+ }
79
123
 
80
- return @{
81
- @"fps": @(self.fps),
82
- @"codec": @(self.codec),
83
- @"uuid": [self.screenRecordingPromise identifier].UUIDString ?: [NSNull null],
84
- @"startedAt": self.startedAt ?: [NSNull null],
85
- };
124
+ return @{
125
+ @"fps": @(_fps),
126
+ @"codec": @(_codec),
127
+ @"uuid": [_screenRecordingPromise identifier].UUIDString ?: [NSNull null],
128
+ @"startedAt": _startedAt ?: [NSNull null],
129
+ };
130
+ }
86
131
  }
87
132
 
88
133
  @end
@@ -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