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.
@@ -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
- XCUIScreen *main = XCUIScreen.mainScreen;
177
- CGVector offset = FBDisplayCoordinateOffset(
178
- CGSizeMake(main.bounds.size.width / main.scale, main.bounds.size.height / main.scale),
179
- CGSizeMake(secondary.bounds.size.width / secondary.scale, secondary.bounds.size.height / secondary.scale),
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
- XCTAssertEqual(actual.x, expected.x + offset.dx);
184
- XCTAssertEqual(actual.y, expected.y + offset.dy);
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);
@@ -12,6 +12,8 @@
12
12
  #import "FBSession-Private.h"
13
13
  #import "FBExceptions.h"
14
14
  #import "FBConfiguration.h"
15
+ #import "FBScreenRecordingContainer.h"
16
+ #import "FBScreenRecordingPromise.h"
15
17
  #import "XCUIApplicationDouble.h"
16
18
 
17
19
  @interface FBSession (SystemApplicationTests)
@@ -70,6 +72,39 @@ static id (^FBSystemApplicationLookup)(void);
70
72
  }
71
73
  @end
72
74
 
75
+ @interface FBTestScreenRecordingPromise : FBScreenRecordingPromise
76
+ @property (nonatomic, strong) NSUUID *testIdentifier;
77
+ @property (nonatomic, copy, nullable) id (^onNativePromiseAccess)(void);
78
+ - (instancetype)initWithUUID:(NSUUID *)uuid
79
+ onNativePromiseAccess:(nullable id (^)(void))onNativePromiseAccess;
80
+ @end
81
+
82
+ @implementation FBTestScreenRecordingPromise
83
+ - (instancetype)initWithUUID:(NSUUID *)uuid
84
+ onNativePromiseAccess:(nullable id (^)(void))onNativePromiseAccess
85
+ {
86
+ XCTAttachment *attachment = [XCTAttachment attachmentWithString:@"video"];
87
+ if ((self = [super initWithNativePromise:attachment])) {
88
+ _testIdentifier = uuid;
89
+ _onNativePromiseAccess = [onNativePromiseAccess copy];
90
+ }
91
+ return self;
92
+ }
93
+
94
+ - (NSUUID *)identifier
95
+ {
96
+ return self.testIdentifier;
97
+ }
98
+
99
+ - (id)nativePromise
100
+ {
101
+ if (self.onNativePromiseAccess) {
102
+ return self.onNativePromiseAccess();
103
+ }
104
+ return [super nativePromise];
105
+ }
106
+ @end
107
+
73
108
  @interface FBSessionTests : XCTestCase
74
109
  @property (nonatomic, strong) FBSession *session;
75
110
  @property (nonatomic, strong) XCUIApplication *testedApplication;
@@ -93,6 +128,7 @@ static id (^FBSystemApplicationLookup)(void);
93
128
  ((FBAUTLaunchSession *)self.session).launchApplication.duringLaunch = nil;
94
129
  }
95
130
  FBSystemApplicationLookup = nil;
131
+ [FBScreenRecordingContainer.sharedInstance reset];
96
132
  [self.session kill];
97
133
  FBConfiguration.sharedInstance.shouldTerminateApp = self.shouldTerminateAppValue;
98
134
  [super tearDown];
@@ -265,4 +301,103 @@ static id (^FBSystemApplicationLookup)(void);
265
301
  }
266
302
  }
267
303
 
304
+ - (void)testScreenRecordingContainerResetClearsStateWhenCleanupThrows
305
+ {
306
+ FBScreenRecordingContainer *container = FBScreenRecordingContainer.sharedInstance;
307
+ FBTestScreenRecordingPromise *promise = [[FBTestScreenRecordingPromise alloc] initWithUUID:NSUUID.UUID
308
+ onNativePromiseAccess:^id{
309
+ @throw [NSException exceptionWithName:@"CleanupFailure" reason:@"Simulated attachment failure" userInfo:nil];
310
+ }];
311
+ [container storeScreenRecordingPromise:promise fps:24 codec:0];
312
+
313
+ XCTAssertNoThrow([container reset]);
314
+ XCTAssertNil(container.screenRecordingPromise);
315
+ XCTAssertNil(container.startedAt);
316
+ XCTAssertEqual(container.fps, 0U);
317
+ XCTAssertEqual(container.codec, 0LL);
318
+ XCTAssertNil([container toDictionary]);
319
+ }
320
+
321
+ - (void)testScreenRecordingContainerStateIsClearedDuringCleanup
322
+ {
323
+ FBScreenRecordingContainer *container = FBScreenRecordingContainer.sharedInstance;
324
+ __block FBScreenRecordingPromise *promiseDuringCleanup = nil;
325
+ __block NSNumber *startedAtDuringCleanup = nil;
326
+ __block NSDictionary *dictionaryDuringCleanup = nil;
327
+ XCTAttachment *attachment = [XCTAttachment attachmentWithString:@"video"];
328
+ FBTestScreenRecordingPromise *promise = [[FBTestScreenRecordingPromise alloc] initWithUUID:NSUUID.UUID
329
+ onNativePromiseAccess:^id{
330
+ promiseDuringCleanup = container.screenRecordingPromise;
331
+ startedAtDuringCleanup = container.startedAt;
332
+ dictionaryDuringCleanup = [container toDictionary];
333
+ return attachment;
334
+ }];
335
+ [container storeScreenRecordingPromise:promise fps:24 codec:1];
336
+
337
+ [container reset];
338
+ XCTAssertNil(promiseDuringCleanup);
339
+ XCTAssertNil(startedAtDuringCleanup);
340
+ XCTAssertNil(dictionaryDuringCleanup);
341
+ }
342
+
343
+ - (void)testScreenRecordingContainerResetAllowsConcurrentReplacementDuringCleanup
344
+ {
345
+ FBScreenRecordingContainer *container = FBScreenRecordingContainer.sharedInstance;
346
+ FBTestScreenRecordingPromise *replacement = [[FBTestScreenRecordingPromise alloc] initWithUUID:NSUUID.UUID
347
+ onNativePromiseAccess:nil];
348
+ XCTAttachment *attachment = [XCTAttachment attachmentWithString:@"video"];
349
+ FBTestScreenRecordingPromise *initial = [[FBTestScreenRecordingPromise alloc] initWithUUID:NSUUID.UUID
350
+ onNativePromiseAccess:^id{
351
+ XCTestExpectation *replacementStored = [self expectationWithDescription:@"Replacement stored during cleanup"];
352
+ dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0), ^{
353
+ [container storeScreenRecordingPromise:replacement fps:60 codec:1];
354
+ [replacementStored fulfill];
355
+ });
356
+ [self waitForExpectationsWithTimeout:2. handler:nil];
357
+ return attachment;
358
+ }];
359
+ [container storeScreenRecordingPromise:initial fps:24 codec:0];
360
+
361
+ XCTAssertTrue([container resetIfPromiseIs:initial]);
362
+ XCTAssertEqual(container.screenRecordingPromise, replacement);
363
+ XCTAssertEqual(container.fps, 60U);
364
+ XCTAssertEqual(container.codec, 1LL);
365
+ XCTAssertEqualObjects([container toDictionary][@"uuid"], replacement.identifier.UUIDString);
366
+ }
367
+
368
+ - (void)testScreenRecordingContainerStaleResetPreservesActiveRecording
369
+ {
370
+ FBScreenRecordingContainer *container = FBScreenRecordingContainer.sharedInstance;
371
+ __block BOOL didRunCleanup = NO;
372
+ XCTAttachment *attachment = [XCTAttachment attachmentWithString:@"video"];
373
+ FBTestScreenRecordingPromise *active = [[FBTestScreenRecordingPromise alloc] initWithUUID:NSUUID.UUID
374
+ onNativePromiseAccess:^id{
375
+ didRunCleanup = YES;
376
+ return attachment;
377
+ }];
378
+ FBTestScreenRecordingPromise *stale = [[FBTestScreenRecordingPromise alloc] initWithUUID:NSUUID.UUID
379
+ onNativePromiseAccess:nil];
380
+ [container storeScreenRecordingPromise:active fps:30 codec:1];
381
+
382
+ XCTAssertFalse([container resetIfPromiseIs:stale]);
383
+ XCTAssertFalse(didRunCleanup);
384
+ XCTAssertEqual(container.screenRecordingPromise, active);
385
+ XCTAssertEqual(container.fps, 30U);
386
+ XCTAssertEqual(container.codec, 1LL);
387
+ }
388
+
389
+ - (void)testScreenRecordingContainerResetOnEmptyContainer
390
+ {
391
+ FBScreenRecordingContainer *container = FBScreenRecordingContainer.sharedInstance;
392
+ [container reset];
393
+ FBTestScreenRecordingPromise *stale = [[FBTestScreenRecordingPromise alloc] initWithUUID:NSUUID.UUID
394
+ onNativePromiseAccess:nil];
395
+
396
+ XCTAssertNil([container toDictionary]);
397
+ XCTAssertNoThrow([container reset]);
398
+ XCTAssertFalse([container resetIfPromiseIs:stale]);
399
+ XCTAssertNil(container.screenRecordingPromise);
400
+ XCTAssertNil(container.startedAt);
401
+ }
402
+
268
403
  @end
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "appium-webdriveragent",
3
- "version": "17.0.6",
3
+ "version": "17.0.8",
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": "d3d5b4d61cfc16788a9591090cde6e91fa0309bd"
86
+ "gitHead": "e2a754f27f3d2b3c4932a16f71eaa2c49fbcedae"
87
87
  }