Skip to content

Commit 3d0daa5

Browse files
author
Justin Martin
authored
Merge pull request #1276 from BrunoMazzo/fix-ios-16
Fix ios 16
2 parents ffa7959 + 7393c3f commit 3d0daa5

File tree

4 files changed

+103
-14
lines changed

4 files changed

+103
-14
lines changed

.github/workflows/build.yml

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,13 @@ jobs:
1515
- name: Validate podspec
1616
run: pod lib lint
1717

18-
build:
19-
runs-on: macos-11
18+
build_xcode14:
19+
runs-on: macos-12
2020
strategy:
2121
matrix:
2222
run-config:
23-
- { xcode_version: '11.7', simulator: 'name=iPhone SE (2nd generation),OS=13.7' }
24-
- { xcode_version: '12.5.1', simulator: 'name=iPhone SE (2nd generation),OS=14.5' }
25-
- { xcode_version: '13.0', simulator: 'name=iPad Pro (12.9-inch) (5th generation),OS=15.0' }
26-
27-
23+
- { xcode_version: '14.1', simulator: 'name=iPad Pro (12.9-inch) (5th generation),OS=16.1' }
24+
- { xcode_version: '14.1', simulator: 'name=iPhone SE (2nd generation),OS=16.1' }
2825
steps:
2926
- name: Checkout Project
3027
uses: actions/checkout@v1
@@ -56,14 +53,13 @@ jobs:
5653
- name: Build & Test
5754
run: ./scripts/ci.sh "${{ matrix.run-config['simulator'] }}"
5855

59-
build_xcode10:
60-
runs-on: macos-10.15
56+
build:
57+
runs-on: macos-11
6158
strategy:
6259
matrix:
6360
run-config:
64-
- { xcode_version: '10.3', simulator: 'name=iPad (5th generation),OS=12.4' }
65-
- { xcode_version: '10.3', simulator: 'name=iPhone 8,OS=12.4' }
66-
61+
- { xcode_version: '13.0', simulator: 'name=iPhone SE (2nd generation),OS=15.0' }
62+
- { xcode_version: '13.0', simulator: 'name=iPad Pro (12.9-inch) (5th generation),OS=15.0' }
6763
steps:
6864
- name: Checkout Project
6965
uses: actions/checkout@v1
@@ -93,4 +89,4 @@ jobs:
9389
run: xcrun simctl list
9490

9591
- name: Build & Test
96-
run: ./scripts/ci.sh "${{ matrix.run-config['simulator'] }}"
92+
run: ./scripts/ci.sh "${{ matrix.run-config['simulator'] }}"

Sources/KIF/Additions/UIView-KIFAdditions.m

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,12 @@ - (UIAccessibilityElement *)accessibilityElementMatchingBlock:(BOOL(^)(UIAccessi
164164
// UITableViewCell is such an offender.
165165
for (UIView *view in [self.subviews reverseObjectEnumerator]) {
166166
UIAccessibilityElement *element = [view accessibilityElementMatchingBlock:matchBlock];
167+
168+
if (!element) {
169+
UIView* fallbackView = [self tryGetiOS16KeyboardFallbackViewFromParentView:view];
170+
element = [fallbackView accessibilityElementMatchingBlock:matchBlock];
171+
}
172+
167173
if (!element) {
168174
continue;
169175
}
@@ -374,12 +380,23 @@ - (NSArray *)subviewsWithClassNamePrefix:(NSString *)prefix;
374380
if ([NSStringFromClass([view class]) hasPrefix:prefix]) {
375381
[result addObject:view];
376382
}
383+
384+
UIView* fallbackView = [self tryGetiOS16KeyboardFallbackViewFromParentView:view];
385+
if ([NSStringFromClass([fallbackView class]) hasPrefix:prefix]) {
386+
[result addObject:fallbackView];
387+
}
377388
}
378389

379390
// Now traverse the subviews of the subviews, adding matches.
380391
for (UIView *view in self.subviews) {
381392
NSArray *matchingSubviews = [view subviewsWithClassNamePrefix:prefix];
382393
[result addObjectsFromArray:matchingSubviews];
394+
395+
UIView* fallbackView = [self tryGetiOS16KeyboardFallbackViewFromParentView:view];
396+
if (fallbackView) {
397+
NSArray *matchingSubviews = [fallbackView subviewsWithClassNamePrefix:prefix];
398+
[result addObjectsFromArray:matchingSubviews];
399+
}
383400
}
384401

385402
return result;
@@ -403,14 +420,30 @@ - (NSArray *)subviewsWithClassNameOrSuperClassNamePrefix:(NSString *)prefix;
403420
// First traverse the next level of subviews, adding matches
404421
for (UIView *view in self.subviews) {
405422
Class klass = [view class];
423+
406424
while (klass) {
407425
if ([NSStringFromClass(klass) hasPrefix:prefix]) {
408426
[result addObject:view];
409427
break;
410428
}
411429

430+
UIView* fallbackView = [self tryGetiOS16KeyboardFallbackViewFromParentView:view];
431+
if (fallbackView) {
432+
Class klass = [fallbackView class];
433+
while (klass) {
434+
if ([NSStringFromClass(klass) hasPrefix:prefix]) {
435+
[result addObject:fallbackView];
436+
break;
437+
}
438+
439+
klass = [klass superclass];
440+
}
441+
}
442+
412443
klass = [klass superclass];
413444
}
445+
446+
414447
}
415448

416449
// Now traverse the subviews of the subviews, adding matches
@@ -1020,5 +1053,13 @@ - (void)performBlockOnAscendentViews:(void (^)(UIView *view, BOOL *stop))block
10201053
}
10211054
}
10221055

1056+
-(UIView*)tryGetiOS16KeyboardFallbackViewFromParentView:(UIView*) parentView {
1057+
if([parentView isKindOfClass:NSClassFromString(@"_UIRemoteKeyboardPlaceholderView")]) {
1058+
UIView* fallbackView = [parentView valueForKey:@"_fallbackView"];
1059+
return fallbackView;
1060+
}
1061+
1062+
return nil;
1063+
}
10231064

10241065
@end

Sources/KIF/Classes/KIFSystemTestActor.m

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,54 @@ - (void)simulateMemoryWarning
5858

5959
- (void)simulateDeviceRotationToOrientation:(UIDeviceOrientation)orientation
6060
{
61-
[[UIDevice currentDevice] setValue:@(orientation) forKey:@"orientation"];
61+
#ifdef __IPHONE_16_0
62+
if (@available(iOS 16.0, *)) {
63+
NSSet<UIScene *> *scenes = [[UIApplication sharedApplication] connectedScenes];
64+
UIWindowScene* windowScene;
65+
for (UIScene* scene in scenes) {
66+
if([scene isKindOfClass:[UIWindowScene class]]) {
67+
windowScene = (UIWindowScene*) scene;
68+
break;
69+
}
70+
}
71+
72+
if (windowScene) {
73+
UIInterfaceOrientationMask orientationMask;
74+
switch (orientation) {
75+
case UIDeviceOrientationUnknown:
76+
orientationMask = UIInterfaceOrientationMaskAll;
77+
break;
78+
case UIDeviceOrientationPortrait:
79+
orientationMask = UIInterfaceOrientationMaskPortrait;
80+
break;
81+
case UIDeviceOrientationPortraitUpsideDown:
82+
orientationMask = UIInterfaceOrientationMaskPortraitUpsideDown;
83+
break;
84+
case UIDeviceOrientationLandscapeLeft:
85+
orientationMask = UIInterfaceOrientationMaskLandscapeLeft;
86+
break;
87+
case UIDeviceOrientationLandscapeRight:
88+
orientationMask = UIInterfaceOrientationMaskLandscapeRight;
89+
break;
90+
case UIDeviceOrientationFaceUp:
91+
orientationMask = UIInterfaceOrientationMaskAll;
92+
break;
93+
case UIDeviceOrientationFaceDown:
94+
orientationMask = UIInterfaceOrientationMaskAll;
95+
break;
96+
}
97+
98+
UIWindowSceneGeometryPreferencesIOS* preferences = [[UIWindowSceneGeometryPreferencesIOS alloc]initWithInterfaceOrientations:orientationMask];
99+
[windowScene requestGeometryUpdateWithPreferences:preferences errorHandler:^(NSError * _Nonnull error) {
100+
[self failWithError:[NSError KIFErrorWithUnderlyingError:error format:@"Could not rotate the screen"] stopTest:YES];
101+
}];
102+
}
103+
} else {
104+
#endif
105+
[[UIDevice currentDevice] setValue:@(orientation) forKey:@"orientation"];
106+
#ifdef __IPHONE_16_0
107+
}
108+
#endif
62109
}
63110

64111

Sources/KIF/Classes/KIFUITestActor.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -835,11 +835,16 @@ - (void)selectPickerViewRowWithTitle:(NSString *)title inComponent:(NSInteger)co
835835
// Find all pickers in view. Either UIDatePickerView or UIPickerView
836836
NSArray *datePickerViews = [[[UIApplication sharedApplication] datePickerWindow] subviewsWithClassNameOrSuperClassNamePrefix:@"UIPickerView"];
837837
NSArray *pickerViews = [[[UIApplication sharedApplication] pickerViewWindow] subviewsWithClassNameOrSuperClassNamePrefix:@"UIPickerView"];
838+
839+
NSArray *iOS16DatePickerViews = [[[UIApplication sharedApplication] datePickerWindow] subviewsWithClassNameOrSuperClassNamePrefix:@"UIDatePicker"];
838840

839841
// Grab one picker and assume it is datePicker and then test our hypothesis later!
840842
pickerView = [datePickerViews lastObject];
841843
if ([pickerView respondsToSelector:@selector(setDate:animated:)] || [pickerView isKindOfClass:NSClassFromString(@"_UIDatePickerView")]) {
842844
pickerType = KIFUIDatePicker;
845+
}else if([[iOS16DatePickerViews lastObject] respondsToSelector:@selector(setDate:animated:)]) {
846+
pickerView = [[iOS16DatePickerViews lastObject] valueForKey:@"_pickerView"];
847+
pickerType = KIFUIDatePicker;
843848
} else {
844849
pickerView = [pickerViews lastObject];
845850
pickerType = KIFUIPickerView;

0 commit comments

Comments
 (0)