Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ios 16 #1276

Merged
merged 9 commits into from
Feb 26, 2023
Merged

Fix ios 16 #1276

merged 9 commits into from
Feb 26, 2023

Conversation

BrunoMazzo
Copy link
Contributor

Fix for iOS 16.

  • Adding the pickerView into the inputView of a textfield is handle different than the other iOS versions. On iOS 16, it is part of the property _fallbackView from _UIRemoteKeyboardPlaceholderView, but it is not part of the UI hierarchy (I don't know why). So in the parts that checked for elements, I added another validation for the _UIRemoteKeyboardPlaceholderView
  • UIDatePicker is not a subclass of UIPickerView. And it has doesn't has an UIPickerView as subview. The hierarchy is UIDatePicker -> _UIDatePickerView -> ... -> UIPickerColumnView ... But it has an _UIPickerView property that works if used.
  • [[UIDevice currentDevice] setValue:@(orientation) forKey:@"orientation"] doesn't work anymore. We need to use requestGeometryUpdateWithPreferences from UIWindowScene.

I'm not 100% familiar with the code, so I may be missing some context, so please let me know if there is anything I should fix.

Copy link
Contributor

@justinseanmartin justinseanmartin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much for your contribution! 2 minor improvement requests and we should remove the commits that are also included in #1275. This is great!

Does this get the full KIF integration test suite passing on iOS 16 devices? If so, it would be great to get CI validating that. If not, maybe we should start working towards that and explicitly bailing out for the specific tests that we know are broken on iOS 16.

@@ -13,4 +13,6 @@
+ (instancetype)KIFErrorWithUnderlyingError:(NSError *)underlyingError format:(NSString *)format, ... NS_FORMAT_FUNCTION(2,3);
+ (instancetype)KIFErrorWithFormat:(NSString *)format, ... NS_FORMAT_FUNCTION(1,2);

+ (instancetype)KIFErrorFromException:(NSException *)exception;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this got pulled over from the other PR. Worth reverting here, as it seems unused in this context.

@@ -374,12 +382,25 @@ - (NSArray *)subviewsWithClassNamePrefix:(NSString *)prefix;
if ([NSStringFromClass([view class]) hasPrefix:prefix]) {
[result addObject:view];
}

if([NSStringFromClass([view class]) isEqualToString:@"_UIRemoteKeyboardPlaceholderView"]) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than duplicating this logic, it'd be cleaner to add a subviewsWithPlaceholderFallbackView method that can be used in place of self.subviews in the 4 places we're iterating over self.subviews in this file.


UIWindowSceneGeometryPreferencesIOS* preferences = [[UIWindowSceneGeometryPreferencesIOS alloc]initWithInterfaceOrientations:orientationMask];
[windowScene requestGeometryUpdateWithPreferences:preferences errorHandler:^(NSError * _Nonnull error) {
NSLog(@"error: %@", error);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this happen in a expected case? If not, makes sense to emit an error and fail the test.

@@ -137,33 +137,44 @@ extern NSString *const inputFieldTestString;
@abstract Tap a view matching the tester's search predicate.
@discussion The tester will evaluate the accessibility hierarchy against it's search predicate and perform a tap on the first match.
*/
- (void)tap;
- (void)tap CF_SWIFT_UNAVAILABLE_FROM_ASYNC("use async version");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be reverted and decoupled from then changes in this PR I believe.

@BrunoMazzo
Copy link
Contributor Author

Thanks for the feedback. I will work on it and push the changes probably in the weekend.

This fix the full suite of tests. I will remove the changes for the async stuff that I forgot (I starting work in the same branch and forgot to clean up), add the CI validation, and do the other changes.

@justinseanmartin
Copy link
Contributor

That's great to hear! It is probably worth bumping the CI config to validate that we don't regress it. That's definitely not a blocker for landing these changes though.

Copy link
Contributor

@justinseanmartin justinseanmartin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tour contributions are very much appreciated! If we can get CI green, then we should be good to go.


steps:
- { xcode_version: '14.1', simulator: 'name=iPad Pro (12.9-inch) (5th generation),OS=16.1' }
steps: &build_steps
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bummer... I liked the cleanup with the anchor, but GitHub doesn't like it:

The workflow is not valid. .github/workflows/build.yml: Anchors are not currently supported. Remove the anchor 'build_steps'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad. I will fix it and push it right now!

@dostrander
Copy link
Contributor

@BrunoMazzo thanks 🎉 for finding this! So this allows you to use pickers and keyboads in iOS 16??

I was under the impression this was out of process from my debugging in this so was expecting a larger reverse engineering effort to be able to call what XCUITest calls. But if that's not that case that's amazing. Thank you SOOO much for digging into this!

@dostrander
Copy link
Contributor

If you need some help getting it to run on iOS 16 feel free to use anything from here: #1268

I added this a while ago but since the tests weren't passing it didn't make sense to merge

@justinseanmartin
Copy link
Contributor

I'm rerunning the failed jobs to see if the results are consistent or not. I think at this point, supporting only Xcode 13.4.1 (Monterey) & 14.2 (Ventura) seems reasonable to me. Maybe we could do one iPad + iPhone device on each platform? Not changing the device type will help eliminate some variable that might lead other test failures related to screen dimensions and whatnot. WDYT? Just trying to limit how many things we need to chase down here to get this landed.

@justinseanmartin
Copy link
Contributor

It looks like we might need some availability checking for the behavior to be backwards compatible with the iOS 15 (Xcode 13) SDK:

❌  /Users/runner/work/KIF/KIF/Sources/KIF/Classes/KIFSystemTestActor.m:98:26: no visible @interface for 'UIWindowScene' declares the selector 'requestGeometryUpdateWithPreferences:errorHandler:'

@BrunoMazzo
Copy link
Contributor Author

I added a check to compile on other versions of Xcode and changed the CI to run on iPhone SE and iPad Pro, Xcode 13 and 14.

Copy link
Contributor

@justinseanmartin justinseanmartin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once CI is green, we should be good to go with this.



- { xcode_version: '14.1', simulator: 'name=iPad Pro (12.9-inch) (5th generation),OS=16.1' }
- { xcode_version: '14.1', simulator: 'name=iPhone SE (3nd generation),OS=16.1' }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meant for this to be 2nd instead of the 3nd?

@justinseanmartin justinseanmartin merged commit 3d0daa5 into kif-framework:master Feb 26, 2023
@dostrander dostrander mentioned this pull request Mar 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants