appium-webdriveragent 4.2.0 → 4.3.0

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.
@@ -135,6 +135,13 @@ typedef NS_ENUM(NSUInteger, FBUIInterfaceAppearance) {
135
135
  */
136
136
  - (BOOL)fb_setAppearance:(FBUIInterfaceAppearance)appearance error:(NSError **)error;
137
137
 
138
+ /**
139
+ Get current appearance prefefence.
140
+
141
+ @return 0 (automatic), 1 (light) or 2 (dark), or nil
142
+ */
143
+ - (nullable NSNumber *)fb_getAppearance;
144
+
138
145
  @end
139
146
 
140
147
  NS_ASSUME_NONNULL_END
@@ -326,4 +326,11 @@ static bool fb_isLocked;
326
326
  buildError:error];
327
327
  }
328
328
 
329
+ - (NSNumber *)fb_getAppearance
330
+ {
331
+ return [self respondsToSelector:@selector(appearanceMode)]
332
+ ? [NSNumber numberWithLongLong:[self appearanceMode]]
333
+ : nil;
334
+ }
335
+
329
336
  @end
@@ -426,6 +426,16 @@
426
426
  */
427
427
  + (NSString *)userInterfaceStyle
428
428
  {
429
+
430
+ if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"15.0")) {
431
+ // Only iOS 15+ simulators/devices return correct data while
432
+ // the api itself works in iOS 13 and 14 that has style preference.
433
+ NSNumber *appearance = [XCUIDevice.sharedDevice fb_getAppearance];
434
+ if (appearance != nil) {
435
+ return [self getAppearanceName:appearance];
436
+ }
437
+ }
438
+
429
439
  static id userInterfaceStyle = nil;
430
440
  static dispatch_once_t styleOnceToken;
431
441
  dispatch_once(&styleOnceToken, ^{
@@ -441,10 +451,17 @@
441
451
  return @"unsupported";
442
452
  }
443
453
 
444
- switch ([userInterfaceStyle integerValue]) {
445
- case 1: // UIUserInterfaceStyleLight
454
+ return [self getAppearanceName:userInterfaceStyle];
455
+ }
456
+
457
+ + (NSString *)getAppearanceName:(NSNumber *)appearance
458
+ {
459
+ switch ([appearance longLongValue]) {
460
+ case FBUIInterfaceAppearanceUnspecified:
461
+ return @"automatic";
462
+ case FBUIInterfaceAppearanceLight:
446
463
  return @"light";
447
- case 2: // UIUserInterfaceStyleDark
464
+ case FBUIInterfaceAppearanceDark:
448
465
  return @"dark";
449
466
  default:
450
467
  return @"unknown";
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "appium-webdriveragent",
3
- "version": "4.2.0",
3
+ "version": "4.3.0",
4
4
  "description": "Package bundling WebDriverAgent",
5
5
  "main": "build/index.js",
6
6
  "scripts": {