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

Xcode 16 in CI #1306

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ jobs:

- name: Validate podspec
run: pod lib lint

build_macos14:
runs-on: macos-14
strategy:
Expand All @@ -23,7 +22,9 @@ jobs:
- { xcode_version: '14.3.1', simulator: 'name=iPad Air (5th generation),OS=16.4', run_extra_validations: 'false' }
- { xcode_version: '14.3.1', simulator: 'name=iPhone 14,OS=16.4', run_extra_validations: 'false' }
- { xcode_version: '15.4', simulator: 'name=iPad Air (5th generation),OS=17.5', run_extra_validations: 'false' }
- { xcode_version: '15.4', simulator: 'name=iPhone 15,OS=17.5', run_extra_validations: 'true' }
- { xcode_version: '15.4', simulator: 'name=iPhone 15,OS=17.5', run_extra_validations: 'false' }
- { xcode_version: '16.0', simulator: 'name=iPad Air (5th generation),OS=18.0', run_extra_validations: 'false' }
- { xcode_version: '16.0', simulator: 'name=iPhone 16,OS=18.0', run_extra_validations: 'true' }
steps:
- name: Checkout Project
uses: actions/checkout@v1
Expand Down
26 changes: 23 additions & 3 deletions Sources/KIF/Additions/CALayer-KIFAdditions.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,32 @@ - (BOOL)hasAnimations

[layer.animationKeys enumerateObjectsUsingBlock:^(NSString *animationKey, NSUInteger idx, BOOL *innerStop) {
CAAnimation *animation = [layer animationForKey:animationKey];
double beginTime = [animation beginTime];

double completionTime = [animation KIF_completionTime];

// Ignore long running animations (> 1 minute duration)
if (currentTime >= beginTime && completionTime < currentTime + 60 && currentTime < completionTime) {
// Ignore long running animations (> 1 minute duration), as we don't want to wait on them
if (completionTime > currentTime + 60) {
return;
}

// If an animation is set to be removed on completion, it must still be in progress if we enumerated it
// This is the default behavior for animations, so we should often hit this codepath.
if ([animation isRemovedOnCompletion]) {
result = YES;
} else if ([animation.delegate isKindOfClass:NSClassFromString(@"UIViewAnimationState")]) {
// Use a private property on the private class to determine if the animation state has completed
BOOL animationDidStopSent = [[(NSObject *)animation.delegate valueForKey:@"_animationDidStopSent"] boolValue];

if (!animationDidStopSent) {
result = YES;
}
} else if (currentTime > completionTime) {
// Otherwise, use the completion time to determine if the animation has been completed.
// This doesn't seem to always be exactly right however.
Copy link
Contributor

Choose a reason for hiding this comment

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

Curious about the cases where it's not quite right, can you elaborate?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What I was seeing was when running TypingTests.testEnteringTextIntoFirstResponder, it would try to tap on "Select All" before it was finished being presented on Xcode 16. For some reason, startTime + duration was before the animation completed if I was watching it run in the simulator.

result = YES;
}

if (result) {
*innerStop = YES;
*stop = YES;
}
Expand Down
3 changes: 3 additions & 0 deletions Sources/KIF/Additions/NSObject+KIFSwizzle.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ + (void)swizzleSEL:(SEL)originalSEL withSEL:(SEL)swizzledSEL
Method originalMethod = class_getInstanceMethod(class, originalSEL);
Method swizzledMethod = class_getInstanceMethod(class, swizzledSEL);

NSAssert(originalMethod != nil, @"The original method for selector '%@' couldn't be found", NSStringFromSelector(originalSEL));
NSAssert(swizzledMethod != nil, @"The swizzled method for selector '%@' couldn't be found", NSStringFromSelector(swizzledSEL));

method_exchangeImplementations(originalMethod, swizzledMethod);
}

Expand Down
20 changes: 14 additions & 6 deletions Sources/KIF/Additions/UIWindow+KIFSwizzle.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,31 @@
#import "UIApplication-KIFAdditions.h"
#import "NSObject+KIFSwizzle.h"

@interface UIWindow ()

- (instancetype)_initWithFrame:(CGRect)rect debugName:(NSString *)debugName windowScene:(UIWindowScene *)windowScene API_AVAILABLE(ios(13));

@end


@implementation UIWindow (KIFSwizzle)

+ (void)load
{
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
[self swizzleSEL:@selector(init) withSEL:@selector(swizzle_init)];
[self swizzleSEL:@selector(becomeKeyWindow) withSEL:@selector(swizzle_becomeKeyWindow)];
if (@available(iOS 13.0, *)) {
[self swizzleSEL:@selector(initWithWindowScene:) withSEL:@selector(swizzle_initWithWindowScene:)];
if (@available(iOS 13, *)) {
[self swizzleSEL:@selector(_initWithFrame:debugName:windowScene:) withSEL:@selector(swizzle__initWithFrame:debugName:windowScene:)];
} else {
[self swizzleSEL:@selector(init) withSEL:@selector(swizzle_init)];
}
[self swizzleSEL:@selector(becomeKeyWindow) withSEL:@selector(swizzle_becomeKeyWindow)];
});
}

- (instancetype)swizzle_initWithWindowScene:(UIWindowScene *)scene API_AVAILABLE(ios(13))
- (instancetype)swizzle__initWithFrame:(CGRect)rect debugName:(NSString *)debugName windowScene:(UIWindowScene *)windowScene API_AVAILABLE(ios(13))
{
UIWindow *window = [self swizzle_initWithWindowScene:scene];
UIWindow *window = [self swizzle__initWithFrame:rect debugName:debugName windowScene:windowScene];
window.layer.speed = [UIApplication sharedApplication].animationSpeed;

return window;
Expand Down
3 changes: 1 addition & 2 deletions Sources/KIF/Classes/KIFUITestActor.m
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,8 @@ - (void)waitForAnimationsToFinishWithTimeout:(NSTimeInterval)timeout stabilizati
[self waitForTimeInterval:maximumWaitingTimeInterval relativeToAnimationSpeed:YES];
}
} else {

// Wait for the view to stabilize and give them a chance to start animations before we wait for them.
[self waitForTimeInterval:stabilizationTime relativeToAnimationSpeed:YES];
[self waitForTimeInterval:MAX(stabilizationTime / [UIApplication sharedApplication].animationSpeed, 0.25) relativeToAnimationSpeed:NO];
maximumWaitingTimeInterval -= stabilizationTime;

NSTimeInterval startTime = [NSDate timeIntervalSinceReferenceDate];
Expand Down
6 changes: 3 additions & 3 deletions Tests/AccessibilityIdentifierTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ - (void)testWaitingForAbscenceOfViewWithAccessibilityIdentifier
- (void)testLongPressingViewWithAccessibilityIdentifier
{
[tester tapViewWithAccessibilityIdentifier:@"idGreeting"];
[tester longPressViewWithAccessibilityIdentifier:@"idGreeting" duration:2];
[tester longPressViewWithAccessibilityIdentifier:@"idGreeting" duration:1];
[tester tapViewWithAccessibilityLabel:@"Select All"];
}

- (void)testEnteringTextIntoViewWithAccessibilityIdentifier
{
[tester tapViewWithAccessibilityIdentifier:@"idGreeting"];
[tester longPressViewWithAccessibilityIdentifier:@"idGreeting" duration:2];
[tester longPressViewWithAccessibilityIdentifier:@"idGreeting" duration:1];
[tester waitForAnimationsToFinish];
[tester tapViewWithAccessibilityLabel:@"Select All"];
[tester tapViewWithAccessibilityLabel:@"Cut"];
Expand All @@ -77,7 +77,7 @@ - (void)testClearingAndEnteringTextIntoViewWithAccessibilityLabel
- (void)testSettingTextIntoViewWithAccessibilityIdentifier
{
UIView *greetingView = [tester waitForViewWithAccessibilityIdentifier:@"idGreeting"];
[tester longPressViewWithAccessibilityIdentifier:@"idGreeting" duration:2];
[tester longPressViewWithAccessibilityIdentifier:@"idGreeting" duration:1];
[tester setText:@"Yo" intoViewWithAccessibilityIdentifier:@"idGreeting"];
[tester expectView:greetingView toContainText:@"Yo"];
[tester setText:@"Hello" intoViewWithAccessibilityIdentifier:@"idGreeting"];
Expand Down
4 changes: 2 additions & 2 deletions Tests/AccessibilityIdentifierTests_ViewTestActor.m
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ - (void)testWaitingForAbscenceOfViewWithAccessibilityIdentifier
- (void)testLongPressingViewWithAccessibilityIdentifier
{
[[viewTester usingIdentifier:@"idGreeting"] tap];
[[viewTester usingIdentifier:@"idGreeting"] longPressWithDuration:2];
[[viewTester usingIdentifier:@"idGreeting"] longPressWithDuration:1];
[[viewTester usingLabel:@"Select All"] tap];
}

- (void)testEnteringTextIntoViewWithAccessibilityIdentifier
{
[[viewTester usingIdentifier:@"idGreeting"] tap];
[[viewTester usingIdentifier:@"idGreeting"] longPressWithDuration:2];
[[viewTester usingIdentifier:@"idGreeting"] longPressWithDuration:1];
[[viewTester usingLabel:@"Select All"] tap];
[[viewTester usingLabel:@"Cut"] tap];
[[viewTester usingIdentifier:@"idGreeting"] enterText:@"Yo"];
Expand Down
6 changes: 3 additions & 3 deletions Tests/LongPressTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,21 @@ - (void)afterEach
- (void)testLongPressingViewWithAccessibilityLabel
{
[tester tapViewWithAccessibilityLabel:@"Greeting"];
[tester longPressViewWithAccessibilityLabel:@"Greeting" duration:2];
[tester longPressViewWithAccessibilityLabel:@"Greeting" duration:1];
[tester tapViewWithAccessibilityLabel:@"Select All"];
}

- (void)testLongPressingViewViewWithTraits
{
[tester tapViewWithAccessibilityLabel:@"Greeting"];
[tester longPressViewWithAccessibilityLabel:@"Greeting" value:@"Hello" duration:2];
[tester longPressViewWithAccessibilityLabel:@"Greeting" value:@"Hello" duration:1];
[tester tapViewWithAccessibilityLabel:@"Select All"];
}

- (void)testLongPressingViewViewWithValue
{
[tester tapViewWithAccessibilityLabel:@"Greeting"];
[tester longPressViewWithAccessibilityLabel:@"Greeting" value:@"Hello" traits:UIAccessibilityTraitUpdatesFrequently duration:2];
[tester longPressViewWithAccessibilityLabel:@"Greeting" value:@"Hello" traits:UIAccessibilityTraitUpdatesFrequently duration:1];
[tester tapViewWithAccessibilityLabel:@"Select All"];
}

Expand Down
6 changes: 3 additions & 3 deletions Tests/LongPressTests_ViewTestActor.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,21 @@ - (void)afterEach
- (void)testLongPressingViewWithAccessibilityLabel
{
[[viewTester usingLabel:@"Greeting"] tap];
[[viewTester usingLabel:@"Greeting"] longPressWithDuration:2];
[[viewTester usingLabel:@"Greeting"] longPressWithDuration:1];
[[viewTester usingLabel:@"Select All"] tap];
}

- (void)testLongPressingViewViewWithTraits
{
[[viewTester usingLabel:@"Greeting"] tap];
[[[viewTester usingLabel:@"Greeting"] usingValue:@"Hello"] longPressWithDuration:2];
[[[viewTester usingLabel:@"Greeting"] usingValue:@"Hello"] longPressWithDuration:1];
[[viewTester usingLabel:@"Select All"] tap];
}

- (void)testLongPressingViewViewWithValue
{
[[viewTester usingLabel:@"Greeting"] tap];
[[[[viewTester usingLabel:@"Greeting"] usingValue:@"Hello"] usingTraits:UIAccessibilityTraitUpdatesFrequently] longPressWithDuration:2];
[[[[viewTester usingLabel:@"Greeting"] usingValue:@"Hello"] usingTraits:UIAccessibilityTraitUpdatesFrequently] longPressWithDuration:1];
[[viewTester usingLabel:@"Select All"] tap];
}

Expand Down
6 changes: 3 additions & 3 deletions Tests/TypingTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ - (void)testMissingFirstResponder
- (void)testEnteringTextIntoFirstResponder
{
[tester tapViewWithAccessibilityLabel:@"Greeting"];
[tester longPressViewWithAccessibilityLabel:@"Greeting" value:@"Hello" duration:2];
[tester longPressViewWithAccessibilityLabel:@"Greeting" value:@"Hello" duration:1];
[tester tapViewWithAccessibilityLabel:@"Select All"];
[tester enterTextIntoCurrentFirstResponder:@"Yo"];
[tester waitForViewWithAccessibilityLabel:@"Greeting" value:@"Yo" traits:UIAccessibilityTraitNone];
Expand All @@ -53,7 +53,7 @@ - (void)testFailingToEnterTextIntoFirstResponder
- (void)testEnteringTextIntoViewWithAccessibilityLabel
{
[tester tapViewWithAccessibilityLabel:@"Greeting"];
[tester longPressViewWithAccessibilityLabel:@"Greeting" value:@"Hello" duration:2];
[tester longPressViewWithAccessibilityLabel:@"Greeting" value:@"Hello" duration:1];
[tester tapViewWithAccessibilityLabel:@"Select All"];
[tester tapViewWithAccessibilityLabel:@"Cut"];
[tester enterText:@"Yo" intoViewWithAccessibilityLabel:@"Greeting"];
Expand Down Expand Up @@ -110,7 +110,7 @@ - (void)testClearingALongTextField
- (void)testSettingTextIntoViewWithAccessibilityLabel
{
UIView *greetingView = [tester waitForViewWithAccessibilityLabel:@"Greeting"];
[tester longPressViewWithAccessibilityLabel:@"Greeting" duration:2];
[tester longPressViewWithAccessibilityLabel:@"Greeting" duration:1];
[tester setText:@"Yo" intoViewWithAccessibilityLabel:@"Greeting"];
[tester expectView:greetingView toContainText:@"Yo"];
[tester setText:@"Hello" intoViewWithAccessibilityLabel:@"Greeting"];
Expand Down
4 changes: 2 additions & 2 deletions Tests/TypingTests_ViewTestActor.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ - (void)testMissingFirstResponder
- (void)testEnteringTextIntoFirstResponder
{
[tester tapViewWithAccessibilityLabel:@"Greeting"];
[[[viewTester usingLabel:@"Greeting"] usingValue:@"Hello"] longPressWithDuration:2];
[[[viewTester usingLabel:@"Greeting"] usingValue:@"Hello"] longPressWithDuration:1];
[[viewTester usingLabel:@"Select All"] tap];
[[viewTester usingFirstResponder] enterText:@"Yo"];
[[[viewTester usingLabel:@"Greeting"] usingValue:@"Yo"] waitForView];
Expand All @@ -54,7 +54,7 @@ - (void)testFailingToEnterTextIntoFirstResponder
- (void)testEnteringTextIntoViewWithAccessibilityLabel
{
[tester tapViewWithAccessibilityLabel:@"Greeting"];
[[[viewTester usingLabel:@"Greeting"] usingValue:@"Hello"] longPressWithDuration:2];
[[[viewTester usingLabel:@"Greeting"] usingValue:@"Hello"] longPressWithDuration:1];
[[viewTester usingLabel:@"Select All"] tap];
[[viewTester usingLabel:@"Cut"] tap];
[[viewTester usingLabel:@"Greeting"] enterText:@"Yo"];
Expand Down