appium-webdriveragent 16.16.3 → 16.16.4

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,14 @@
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
+ ## [16.16.4](https://github.com/appium/appium-ios/compare/appium-webdriveragent@16.16.3...appium-webdriveragent@16.16.4) (2026-10-21)
7
+
8
+ ### Bug Fixes
9
+
10
+ * **webdriveragent:** dispatch Home button HID events on Duo simulators ([#78](https://github.com/appium/appium-ios/issues/78)) ([19ce62f](https://github.com/appium/appium-ios/commit/19ce62f69b657e5b0fe2f7f74545c56f9631beb6)), closes [#85](https://github.com/appium/appium-ios/issues/85)
11
+ * **webdriveragent:** fall back to vendor HID events for Duo rotation ([#81](https://github.com/appium/appium-ios/issues/81)) ([71d1ae0](https://github.com/appium/appium-ios/commit/71d1ae01dd1cea5b85063ed74c1b51f02134c6c5))
12
+
13
+
6
14
  ## [16.16.3](https://github.com/appium/appium-ios/compare/appium-webdriveragent@16.16.2...appium-webdriveragent@16.16.3) (2026-10-19)
7
15
 
8
16
  ### Bug Fixes
@@ -9,7 +9,9 @@
9
9
  #import "XCUIDevice+FBHelpers.h"
10
10
 
11
11
  #import <arpa/inet.h>
12
+ #import <dlfcn.h>
12
13
  #import <ifaddrs.h>
14
+ #import <mach/mach_time.h>
13
15
  #include <notify.h>
14
16
  #import <objc/runtime.h>
15
17
 
@@ -22,11 +24,63 @@
22
24
  #import "FBXCodeCompatibility.h"
23
25
  #import "FBXCTestDaemonsProxy.h"
24
26
  #import "XCUIDevice.h"
27
+ #import "XCUIDevice+FBHinge.h"
25
28
  #import "XCUIApplication.h"
26
29
 
27
30
  static const NSTimeInterval FBHomeButtonCoolOffTime = 1.;
28
31
  static const NSTimeInterval FBScreenLockTimeout = 5.;
29
32
 
33
+ #if !TARGET_OS_TV && !TARGET_OS_WATCH
34
+ // Workaround tracked in https://github.com/appium/appium/issues/22857.
35
+ // Reproduced on the iOS 27.1 Duo simulator with Xcode 27.1: XCTest's Home
36
+ // request returns without backgrounding the app. This direct HID path is also
37
+ // enabled on physical hinged devices, but Home behavior there is unverified.
38
+ // The affected Xcode/runtime version range has not been established. Remove
39
+ // the Home workaround when XCTest-only presses pass testHomeButtonBackgroundsApplication
40
+ // on supported Duo environments, including physical devices and both panels.
41
+ static BOOL FBPressDuoButton(uint32_t usage, NSError **error)
42
+ {
43
+ static CFTypeRef (*createEvent)(CFAllocatorRef, uint64_t, uint32_t, uint32_t, Boolean, uint32_t);
44
+ static CFTypeRef (*createClient)(CFAllocatorRef);
45
+ static void (*dispatchEvent)(CFTypeRef, CFTypeRef);
46
+ static void (*setTimestamp)(CFTypeRef, uint64_t);
47
+ static dispatch_once_t onceToken;
48
+ dispatch_once(&onceToken, ^{
49
+ void *handle = dlopen("/System/Library/Frameworks/IOKit.framework/IOKit", RTLD_LAZY);
50
+ if (NULL != handle) {
51
+ createEvent = dlsym(handle, "IOHIDEventCreateKeyboardEvent");
52
+ createClient = dlsym(handle, "IOHIDEventSystemClientCreate");
53
+ dispatchEvent = dlsym(handle, "IOHIDEventSystemClientDispatchEvent");
54
+ setTimestamp = dlsym(handle, "IOHIDEventSetTimeStamp");
55
+ }
56
+ });
57
+ if (NULL == createEvent || NULL == createClient || NULL == dispatchEvent || NULL == setTimestamp) {
58
+ return [[FBErrorBuilder.builder withDescription:@"The button HID APIs are unavailable"] buildError:error];
59
+ }
60
+ CFTypeRef client = createClient(kCFAllocatorDefault);
61
+ CFTypeRef down = createEvent(kCFAllocatorDefault, mach_absolute_time(), 0x0C, usage, YES, 0);
62
+ CFTypeRef up = createEvent(kCFAllocatorDefault, mach_absolute_time(), 0x0C, usage, NO, 0);
63
+ BOOL ready = NULL != client && NULL != down && NULL != up;
64
+ if (ready) {
65
+ // Dispatch a short paired press. Holding Power for 0.5s invokes Siri on Duo.
66
+ dispatchEvent(client, down);
67
+ [NSThread sleepForTimeInterval:0.03];
68
+ setTimestamp(up, mach_absolute_time());
69
+ dispatchEvent(client, up);
70
+ }
71
+ if (NULL != down) {
72
+ CFRelease(down);
73
+ }
74
+ if (NULL != up) {
75
+ CFRelease(up);
76
+ }
77
+ if (NULL != client) {
78
+ CFRelease(client);
79
+ }
80
+ return ready || [[FBErrorBuilder.builder withDescription:@"Cannot create the button HID event or client"] buildError:error];
81
+ }
82
+ #endif
83
+
30
84
  #if TARGET_OS_WATCH
31
85
  static NSString *const FBClockFaceBundleId = @"com.apple.clockface";
32
86
  #endif
@@ -200,7 +254,18 @@ static bool fb_isLocked;
200
254
  return YES;
201
255
  }
202
256
  #if TARGET_OS_SIMULATOR
203
- [self pressLockButton];
257
+ #if !TARGET_OS_TV && !TARGET_OS_WATCH
258
+ // XCTest locking times out on Duo / iOS 27.1 (Xcode 27.1). Remove this
259
+ // workaround once XCTest alone passes testRepeatedLockUnlockAcrossHingePoses.
260
+ if (self.fb_supportsHingeAngleReading) {
261
+ if (!FBPressDuoButton(0x30, error)) {
262
+ return NO;
263
+ }
264
+ } else
265
+ #endif
266
+ {
267
+ [self pressLockButton];
268
+ }
204
269
  #else
205
270
  if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"27.0")) {
206
271
  // iOS 27: pressLockButton no longer locks; use a short IOHID Power press.
@@ -234,14 +299,19 @@ static bool fb_isLocked;
234
299
  if (!fb_isLocked) {
235
300
  return YES;
236
301
  }
237
- [self pressButton:XCUIDeviceButtonHome];
238
- [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:FBHomeButtonCoolOffTime]];
239
- #if !TARGET_OS_TV
240
- [self pressButton:XCUIDeviceButtonHome];
241
- #else
242
- [self pressButton:XCUIDeviceButtonHome];
302
+ for (NSUInteger attempt = 0; attempt < 2; attempt++) {
303
+ #if TARGET_OS_SIMULATOR && !TARGET_OS_TV && !TARGET_OS_WATCH
304
+ if (self.fb_supportsHingeAngleReading) {
305
+ if (!FBPressDuoButton(0x40, error)) {
306
+ return NO;
307
+ }
308
+ } else
243
309
  #endif
244
- [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:FBHomeButtonCoolOffTime]];
310
+ {
311
+ [self pressButton:XCUIDeviceButtonHome];
312
+ }
313
+ [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:FBHomeButtonCoolOffTime]];
314
+ }
245
315
  return [[[[FBRunLoopSpinner new]
246
316
  timeout:FBScreenLockTimeout]
247
317
  timeoutErrorMessage:@"Timed out while waiting until the screen gets unlocked"]
@@ -408,6 +478,11 @@ static bool fb_isLocked;
408
478
  withDescriptionFormat:@"The button '%@' is not supported. The device under test only supports the following buttons: %@", buttonName, sortedKeys]
409
479
  buildError:error];
410
480
  }
481
+ #if !TARGET_OS_TV && !TARGET_OS_WATCH
482
+ if (buttonValue.unsignedIntegerValue == XCUIDeviceButtonHome && self.fb_supportsHingeAngleReading) {
483
+ return FBPressDuoButton(0x40, error);
484
+ }
485
+ #endif
411
486
  [self pressButton:(XCUIDeviceButton)[buttonValue unsignedIntegerValue]];
412
487
  return YES;
413
488
  }
@@ -8,20 +8,143 @@
8
8
 
9
9
  #import "XCUIDevice+FBRotation.h"
10
10
 
11
+ #import <dlfcn.h>
12
+ #import <mach/mach_time.h>
13
+
11
14
  #import "FBConfiguration.h"
15
+ #import "FBLogger.h"
16
+ #import "FBRunLoopSpinner.h"
17
+ #import "FBScreen.h"
18
+ #import "FBSession.h"
19
+ #import "XCUIScreen.h"
20
+ #import "XCUIDevice+FBHinge.h"
12
21
  #import "XCUIApplication.h"
13
22
  #import "XCUIApplication+FBHelpers.h"
14
23
  #import "XCUIElement+FBUtilities.h"
15
24
 
16
25
  # if !TARGET_OS_TV && !TARGET_OS_WATCH
17
26
 
27
+ // Work around XCTest updating Duo device orientation without rotating the app.
28
+ // Reproduction details and checks required before removing this workaround:
29
+ // https://github.com/appium/appium-ios/pull/81
30
+ static BOOL FBDispatchDuoOrientation(UIDeviceOrientation orientation)
31
+ {
32
+ XCUIScreen *screen = [FBScreen currentScreenWithError:nil];
33
+ if (nil == screen) {
34
+ return NO;
35
+ }
36
+ // The inner panel's native orientation is a quarter turn from the cover.
37
+ // Values match DeviceKit's orientation-picker-control (Xcode 27.1).
38
+ NSString *value;
39
+ switch (orientation) {
40
+ case UIDeviceOrientationPortrait:
41
+ value = screen.isMainScreen ? @"portrait" : @"landscape-left";
42
+ break;
43
+ case UIDeviceOrientationLandscapeLeft:
44
+ value = screen.isMainScreen ? @"landscape-left" : @"pud";
45
+ break;
46
+ case UIDeviceOrientationLandscapeRight:
47
+ value = screen.isMainScreen ? @"landscape-right" : @"portrait";
48
+ break;
49
+ case UIDeviceOrientationPortraitUpsideDown:
50
+ value = screen.isMainScreen ? @"pud" : @"landscape-right";
51
+ break;
52
+ case UIDeviceOrientationUnknown:
53
+ case UIDeviceOrientationFaceUp:
54
+ case UIDeviceOrientationFaceDown:
55
+ default:
56
+ return NO;
57
+ }
58
+
59
+ static CFDataRef (*serialize)(CFTypeRef, CFOptionFlags);
60
+ static CFTypeRef (*createEvent)(CFAllocatorRef, uint64_t, uint32_t, uint32_t,
61
+ uint32_t, uint8_t *, CFIndex, uint32_t);
62
+ static CFTypeRef (*createClient)(CFAllocatorRef);
63
+ static void (*dispatchEvent)(CFTypeRef, CFTypeRef);
64
+ static dispatch_once_t onceToken;
65
+ dispatch_once(&onceToken, ^{
66
+ void *handle = dlopen("/System/Library/Frameworks/IOKit.framework/IOKit", RTLD_LAZY);
67
+ if (NULL != handle) {
68
+ serialize = (CFDataRef (*)(CFTypeRef, CFOptionFlags))dlsym(handle, "IOCFSerialize");
69
+ createEvent = (CFTypeRef (*)(CFAllocatorRef, uint64_t, uint32_t, uint32_t,
70
+ uint32_t, uint8_t *, CFIndex, uint32_t))dlsym(handle, "IOHIDEventCreateVendorDefinedEvent");
71
+ createClient = (CFTypeRef (*)(CFAllocatorRef))dlsym(handle, "IOHIDEventSystemClientCreate");
72
+ dispatchEvent = (void (*)(CFTypeRef, CFTypeRef))dlsym(handle, "IOHIDEventSystemClientDispatchEvent");
73
+ }
74
+ });
75
+ if (NULL == serialize || NULL == createEvent || NULL == createClient || NULL == dispatchEvent) {
76
+ return NO;
77
+ }
78
+ NSDictionary *payload = @{
79
+ @"provider": @"com.apple.Virtualization.VirtualMachines",
80
+ @"source": @"orientation-picker-control",
81
+ @"type": @"enum",
82
+ @"value": value,
83
+ };
84
+ // The receiver expects IOCF binary serialization, not a binary plist.
85
+ CFDataRef data = serialize((__bridge CFTypeRef)payload, 1);
86
+ if (NULL == data) {
87
+ return NO;
88
+ }
89
+ CFTypeRef event = createEvent(kCFAllocatorDefault, mach_absolute_time(), 0xff61, 0x5b, 0,
90
+ (uint8_t *)CFDataGetBytePtr(data), CFDataGetLength(data), 0);
91
+ CFRelease(data);
92
+ CFTypeRef client = createClient(kCFAllocatorDefault);
93
+ BOOL canDispatch = NULL != event && NULL != client;
94
+ if (canDispatch) {
95
+ dispatchEvent(client, event);
96
+ }
97
+ if (NULL != event) {
98
+ CFRelease(event);
99
+ }
100
+ if (NULL != client) {
101
+ CFRelease(client);
102
+ }
103
+ return canDispatch;
104
+ }
105
+
106
+ static UIInterfaceOrientation FBInterfaceOrientationFromDeviceOrientation(UIDeviceOrientation orientation);
107
+
18
108
  @implementation XCUIDevice (FBRotation)
19
109
 
20
110
  - (BOOL)fb_setDeviceInterfaceOrientation:(UIDeviceOrientation)orientation
21
111
  {
112
+ BOOL supportsHinge = self.fb_supportsHingeAngleReading;
22
113
  XCUIApplication *application = XCUIApplication.fb_activeApplication;
114
+ if (supportsHinge) {
115
+ // Point-based detection can select the cover SpringBoard while the app
116
+ // is on the inner panel. Prefer the session's active application.
117
+ application = FBSession.activeSession.activeApplication ?: application;
118
+ }
119
+ // Keep XCTest's reported device orientation in sync on the simulator too.
23
120
  [XCUIDevice sharedDevice].orientation = orientation;
24
- return [self waitUntilInterfaceIsAtOrientation:orientation application:application];
121
+ #if TARGET_OS_SIMULATOR
122
+ if (!supportsHinge) {
123
+ return [self waitUntilInterfaceIsAtOrientation:orientation application:application];
124
+ }
125
+ // On Duo simulators XCTest can update its value without rotating the app.
126
+ // Dispatch directly instead of waiting for the XCTest path to fail.
127
+ #else
128
+ if ([self waitUntilInterfaceIsAtOrientation:orientation application:application]) {
129
+ return YES;
130
+ }
131
+ if (!supportsHinge) {
132
+ return NO;
133
+ }
134
+ [FBLogger logFmt:@"XCTest did not rotate the app to device orientation %ld on a physical Duo device. "
135
+ @"Falling back to the vendor HID orientation event; physical-device support is unverified.",
136
+ (long)orientation];
137
+ #endif
138
+ if (!FBDispatchDuoOrientation(orientation)) {
139
+ return NO;
140
+ }
141
+ // Event dispatch is asynchronous. Keep checking the app, not just XCTest's
142
+ // device-orientation value, which can change without rotating the scene.
143
+ BOOL reachedOrientation = [[[FBRunLoopSpinner new] timeout:5.0] spinUntilTrue:^BOOL{
144
+ return application.interfaceOrientation == FBInterfaceOrientationFromDeviceOrientation(orientation);
145
+ }];
146
+ return reachedOrientation
147
+ && [self waitUntilInterfaceIsAtOrientation:orientation application:application];
25
148
  }
26
149
 
27
150
  - (BOOL)fb_setDeviceRotation:(NSDictionary *)rotationObj
@@ -31,9 +154,7 @@
31
154
  return NO;
32
155
  }
33
156
  UIDeviceOrientation orientation = (UIDeviceOrientation)keysForRotationObj.firstObject.integerValue;
34
- XCUIApplication *application = XCUIApplication.fb_activeApplication;
35
- [XCUIDevice sharedDevice].orientation = orientation;
36
- return [self waitUntilInterfaceIsAtOrientation:orientation application:application];
157
+ return [self fb_setDeviceInterfaceOrientation:orientation];
37
158
  }
38
159
 
39
160
  static UIInterfaceOrientation FBInterfaceOrientationFromDeviceOrientation(UIDeviceOrientation orientation)
@@ -15,11 +15,11 @@
15
15
  <key>CFBundlePackageType</key>
16
16
  <string>FMWK</string>
17
17
  <key>CFBundleShortVersionString</key>
18
- <string>16.16.3</string>
18
+ <string>16.16.4</string>
19
19
  <key>CFBundleSignature</key>
20
20
  <string>????</string>
21
21
  <key>CFBundleVersion</key>
22
- <string>16.16.3</string>
22
+ <string>16.16.4</string>
23
23
  <key>NSPrincipalClass</key>
24
24
  <string/>
25
25
  </dict>
@@ -111,10 +111,20 @@
111
111
  }
112
112
 
113
113
  #if !TARGET_OS_TV
114
+ - (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
115
+ {
116
+ [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
117
+ [coordinator animateAlongsideTransition:nil completion:^(id<UIViewControllerTransitionCoordinatorContext> context) {
118
+ // A 180-degree rotation can leave bounds unchanged. Read the scene after
119
+ // the transition as well as during layout.
120
+ [self updateOrentationLabel];
121
+ }];
122
+ }
123
+
114
124
  - (void)updateOrentationLabel
115
125
  {
116
126
  NSString *orientation = nil;
117
- switch (UIDevice.currentDevice.orientation) {
127
+ switch (self.view.window.windowScene.interfaceOrientation) {
118
128
  case UIInterfaceOrientationPortrait:
119
129
  orientation = @"Portrait";
120
130
  break;
@@ -127,12 +137,6 @@
127
137
  case UIInterfaceOrientationLandscapeRight:
128
138
  orientation = @"LandscapeRight";
129
139
  break;
130
- case UIDeviceOrientationFaceUp:
131
- orientation = @"FaceUp";
132
- break;
133
- case UIDeviceOrientationFaceDown:
134
- orientation = @"FaceDown";
135
- break;
136
140
  case UIInterfaceOrientationUnknown:
137
141
  orientation = @"Unknown";
138
142
  break;
@@ -7,6 +7,7 @@
7
7
  */
8
8
 
9
9
  #import <XCTest/XCTest.h>
10
+ #import <math.h>
10
11
 
11
12
  #import "FBIntegrationTestCase.h"
12
13
  #import "FBImageUtils.h"
@@ -15,6 +16,7 @@
15
16
  #import "XCUIApplication.h"
16
17
  #import "XCUIApplication+FBHelpers.h"
17
18
  #import "XCUIDevice+FBHelpers.h"
19
+ #import "XCUIDevice+FBHinge.h"
18
20
  #import "XCUIDevice+FBRotation.h"
19
21
  #import "XCUIScreen.h"
20
22
 
@@ -104,6 +106,53 @@
104
106
  FBAssertWaitTillBecomesTrue([XCUIApplication fb_activeApplication].icons[@"Safari"].exists);
105
107
  }
106
108
 
109
+ - (void)testHomeButtonBackgroundsApplication
110
+ {
111
+ XCUIDevice *device = XCUIDevice.sharedDevice;
112
+ BOOL hasHinge = NO;
113
+ #if TARGET_OS_SIMULATOR
114
+ hasHinge = device.fb_canAttemptSimulatedHingeAngleInjection;
115
+ #endif
116
+ NSNumber *originalAngle = hasHinge ? [device fb_getSimulatedHingeAngle:nil] : nil;
117
+ if (hasHinge && nil == originalAngle) {
118
+ XCTFail(@"Cannot read the original hinge angle");
119
+ return;
120
+ }
121
+ BOOL (^setAngleAndWait)(NSNumber *) = ^BOOL(NSNumber *angle) {
122
+ return [device fb_setSimulatedHingeAngle:angle.doubleValue error:nil]
123
+ && [[[FBRunLoopSpinner new] timeout:5] spinUntilTrue:^BOOL{
124
+ NSNumber *reading = [device fb_getSimulatedHingeAngle:nil];
125
+ return nil != reading && fabs(reading.doubleValue - angle.doubleValue) < 1;
126
+ }];
127
+ };
128
+ @try {
129
+ for (NSNumber *angle in (hasHinge ? @[@0, @180] : @[@0])) {
130
+ if (hasHinge) {
131
+ if (!setAngleAndWait(angle)) {
132
+ XCTFail(@"Hinge angle did not reach %@", angle);
133
+ return;
134
+ }
135
+ }
136
+ for (NSUInteger attempt = 0; attempt < 2; attempt++) {
137
+ [self.testedApplication activate];
138
+ XCTAssertEqual(self.testedApplication.state, XCUIApplicationStateRunningForeground);
139
+ NSError *error = nil;
140
+ XCTAssertTrue([device fb_pressButton:@"home" forDuration:nil error:&error]);
141
+ XCTAssertNil(error);
142
+ XCTAssertTrue([[[FBRunLoopSpinner new] timeout:5] spinUntilTrue:^BOOL{
143
+ return self.testedApplication.state == XCUIApplicationStateRunningBackground
144
+ || self.testedApplication.state == XCUIApplicationStateRunningBackgroundSuspended;
145
+ }]);
146
+ XCTAssertTrue([XCUIApplication.fb_activeApplication.bundleID isEqualToString:@"com.apple.springboard"]);
147
+ }
148
+ }
149
+ } @finally {
150
+ if (nil != originalAngle) {
151
+ XCTAssertTrue(setAngleAndWait(originalAngle));
152
+ }
153
+ }
154
+ }
155
+
107
156
  - (void)testLockUnlockScreen
108
157
  {
109
158
  XCTAssertFalse([[XCUIDevice sharedDevice] fb_isScreenLocked]);
@@ -116,6 +165,54 @@
116
165
  XCTAssertNil(error);
117
166
  }
118
167
 
168
+ - (void)testRepeatedLockUnlockAcrossHingePoses
169
+ {
170
+ XCTSkipIf(self.class.isRunningInCI, @"Repeated lock/unlock is unreliable on slow CI hosts");
171
+ XCUIDevice *device = XCUIDevice.sharedDevice;
172
+ BOOL hasHinge = NO;
173
+ #if TARGET_OS_SIMULATOR
174
+ hasHinge = device.fb_canAttemptSimulatedHingeAngleInjection;
175
+ #endif
176
+ NSNumber *originalAngle = hasHinge ? [device fb_getSimulatedHingeAngle:nil] : nil;
177
+ if (hasHinge) {
178
+ XCTAssertNotNil(originalAngle);
179
+ }
180
+ BOOL (^setAngleAndWait)(NSNumber *) = ^BOOL(NSNumber *angle) {
181
+ return [device fb_setSimulatedHingeAngle:angle.doubleValue error:nil]
182
+ && [[[FBRunLoopSpinner new] timeout:5] spinUntilTrue:^BOOL{
183
+ NSNumber *reading = [device fb_getSimulatedHingeAngle:nil];
184
+ return nil != reading && fabs(reading.doubleValue - angle.doubleValue) < 1;
185
+ }];
186
+ };
187
+ @try {
188
+ for (NSNumber *angle in (hasHinge ? @[@0, @90, @180] : @[@0])) {
189
+ if (hasHinge) {
190
+ XCTAssertTrue(setAngleAndWait(angle));
191
+ }
192
+ for (NSUInteger attempt = 0; attempt < 3; attempt++) {
193
+ XCTAssertFalse(device.fb_isScreenLocked);
194
+ NSError *error = nil;
195
+ XCTAssertTrue([device fb_lockScreen:&error]);
196
+ XCTAssertNil(error);
197
+ XCTAssertTrue(device.fb_isScreenLocked);
198
+ // Repeating lock must not toggle the screen back to unlocked.
199
+ XCTAssertTrue([device fb_lockScreen:&error]);
200
+ XCTAssertTrue(device.fb_isScreenLocked);
201
+ XCTAssertTrue([device fb_unlockScreen:&error]);
202
+ XCTAssertNil(error);
203
+ XCTAssertFalse(device.fb_isScreenLocked);
204
+ XCTAssertTrue([device fb_unlockScreen:&error]);
205
+ XCTAssertFalse(device.fb_isScreenLocked);
206
+ }
207
+ }
208
+ } @finally {
209
+ [device fb_unlockScreen:nil];
210
+ if (nil != originalAngle) {
211
+ XCTAssertTrue(setAngleAndWait(originalAngle));
212
+ }
213
+ }
214
+ }
215
+
119
216
  - (void)testUrlSchemeActivation
120
217
  {
121
218
  if (SYSTEM_VERSION_LESS_THAN(@"16.4")) {
@@ -10,8 +10,13 @@
10
10
  #import <UIKit/UIKit.h>
11
11
  #import "FBIntegrationTestCase.h"
12
12
  #import "XCUIDevice+FBRotation.h"
13
+ #import "XCUIDevice+FBHinge.h"
14
+ #import "FBConfiguration.h"
15
+ #import "FBScreen.h"
16
+ #import "FBSession.h"
13
17
 
14
18
  @interface XCUIDeviceRotationTests : FBIntegrationTestCase
19
+ @property (nonatomic, strong) FBSession *session;
15
20
 
16
21
  @end
17
22
 
@@ -21,11 +26,13 @@
21
26
  {
22
27
  [super setUp];
23
28
  [self launchApplication];
29
+ self.session = [FBSession initWithApplication:self.testedApplication];
24
30
  }
25
31
 
26
32
  - (void)tearDown
27
33
  {
28
34
  [self resetOrientation];
35
+ [self.session kill];
29
36
  [super tearDown];
30
37
  }
31
38
 
@@ -102,4 +109,50 @@
102
109
  XCTAssertEqual(currentRotation, [XCUIDevice sharedDevice].orientation, @"Device doesnt support tilt, should be at previous orientation");
103
110
  }
104
111
 
112
+ - (void)testRotationOnSelectedDuoDisplay
113
+ {
114
+ #if TARGET_OS_SIMULATOR
115
+ XCUIDevice *device = XCUIDevice.sharedDevice;
116
+ XCTSkipIf(!device.fb_supportsHingeAngleReading || !device.fb_canAttemptSimulatedHingeAngleInjection,
117
+ @"Requires hinge angle reading and injection support");
118
+ NSNumber *originalDisplay = FBConfiguration.sharedInstance.currentDisplayId;
119
+ NSNumber *originalAngle = [device fb_getSimulatedHingeAngle:nil];
120
+ XCTAssertNotNil(originalAngle);
121
+ @try {
122
+ for (NSNumber *angle in @[@0, @90, @180]) {
123
+ XCTAssertTrue([device fb_setSimulatedHingeAngle:angle.doubleValue error:nil]);
124
+ [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:3]];
125
+ for (NSDictionary *screen in [FBScreen screensWithError:nil]) {
126
+ if ([screen[@"isMain"] boolValue] == (angle.intValue == 0)) {
127
+ FBConfiguration.sharedInstance.currentDisplayId = screen[@"displayId"];
128
+ }
129
+ }
130
+ [self.testedApplication activate];
131
+ NSArray *orientations = @[@(UIDeviceOrientationLandscapeLeft),
132
+ @(UIDeviceOrientationLandscapeRight),
133
+ @(UIDeviceOrientationPortrait)];
134
+ NSArray *labels = @[@"LandscapeRight", @"LandscapeLeft", @"Portrait"];
135
+ for (NSUInteger i = 0; i < orientations.count; i++) {
136
+ UIDeviceOrientation orientation = [orientations[i] integerValue];
137
+ XCTAssertTrue([device fb_setDeviceInterfaceOrientation:orientation]);
138
+ XCTAssertTrue([self.testedApplication.staticTexts[labels[i]] waitForExistenceWithTimeout:5]);
139
+ XCTAssertEqual(device.orientation, orientation);
140
+ }
141
+ BOOL rotated = [device fb_setDeviceRotation:@{@"x": @0, @"y": @0, @"z": @270}];
142
+ XCTAssertTrue(rotated);
143
+ XCTAssertTrue(self.testedApplication.staticTexts[@"LandscapeRight"].exists);
144
+ }
145
+ } @finally {
146
+ [device fb_setSimulatedHingeAngle:0 error:nil];
147
+ [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:3]];
148
+ FBConfiguration.sharedInstance.currentDisplayId = nil;
149
+ [device fb_setDeviceInterfaceOrientation:UIDeviceOrientationPortrait];
150
+ if (nil != originalAngle) {
151
+ [device fb_setSimulatedHingeAngle:originalAngle.doubleValue error:nil];
152
+ }
153
+ FBConfiguration.sharedInstance.currentDisplayId = originalDisplay;
154
+ }
155
+ #endif
156
+ }
157
+
105
158
  @end
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "appium-webdriveragent",
3
- "version": "16.16.3",
3
+ "version": "16.16.4",
4
4
  "description": "Package bundling WebDriverAgent",
5
5
  "keywords": [
6
6
  "Appium",
@@ -85,5 +85,5 @@
85
85
  "node": "^20.19.0 || ^22.12.0 || >=24.0.0",
86
86
  "npm": ">=10"
87
87
  },
88
- "gitHead": "9a31ba1944198c3a718165153394f53ab6b2b63f"
88
+ "gitHead": "9acf30a6e265ea83362af63100d1b66e8a836f10"
89
89
  }