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

Merge from main master branch #20

Merged
merged 20 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
61a4715
Bump ios minimum deployment target to 11.0
danielob May 1, 2023
3eb917b
Fixing tests to compile with iOS11
danielob May 7, 2023
cc6b0fa
bump iOS platform in podspec to iOS11
danielob May 7, 2023
7d85058
bump version in Package.swift
danielob May 7, 2023
29b6746
Add support for swiping from the specified edge of the screen
Fitzmaz Apr 4, 2023
ebf5a0a
Fix Gestures scene layout
Fitzmaz Jun 30, 2023
f582ccd
Add tests for verifying that dragFromPoint doesn't trigger
Fitzmaz Jun 30, 2023
26b1a96
Add dragFromEdge
Fitzmaz Jun 30, 2023
d07657e
Address review comments
Fitzmaz Jul 11, 2023
10352c9
Merge pull request #1286 from Fitzmaz/add-swipeFromEdge
dostrander Jul 12, 2023
325a24d
PullToRefreshTests can exit before the greetingView is finished anima…
Jul 13, 2023
d185c5d
Merge pull request #1288 from justinseanmartin/jmartin/fix-flaky-kif-…
Jul 13, 2023
a9821a4
Fix occasional CI failures on the iPhone simulator
Fitzmaz Jul 12, 2023
7a06351
Merge pull request #1287 from Fitzmaz/fix-ci-failures
Jul 14, 2023
62fcb38
fix iOS 17 black screenshot due to calling keyboard window drawViewHi…
banjun Sep 20, 2023
da732b5
suppress rendering keyboard on screenshot only if runtime is iOS 17+
banjun Oct 4, 2023
c18a19b
Merge pull request #1289 from banjun/fix-ios17-black-screenshot-due-t…
Oct 11, 2023
ac6468a
Merge pull request #1292 from adamsousa/bump-ios-minimum-deployment-t…
Mar 18, 2024
ad6972a
Bump the podspec to 3.8.10
May 10, 2024
0176e75
Use 3.9.0 instead of 3.8.10
May 13, 2024
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: 5 additions & 0 deletions KIF Tests/AccessibilityIdentifierPullToRefreshTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,9 @@ -(void) testPullToRefreshByAccessibilityIdentifierWithDuration
[tester waitForAbsenceOfViewWithAccessibilityLabel:@"Bingo!"];
}

- (void)afterEach
{
[tester waitForAnimationsToFinish];
}

@end
1 change: 1 addition & 0 deletions KIF Tests/AccessibilityIdentifierTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ @implementation AccessibilityIdentifierTests

- (void)beforeEach
{
UIPasteboard.generalPasteboard.string = nil;
[tester tapViewWithAccessibilityLabel:@"Tapping"];
}

Expand Down
1 change: 1 addition & 0 deletions KIF Tests/AccessibilityIdentifierTests_ViewTestActor.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ @implementation AccessibilityIdentifierTests_ViewTestActor

- (void)beforeEach
{
UIPasteboard.generalPasteboard.string = nil;
[[viewTester usingLabel:@"Tapping"] tap];
}

Expand Down
28 changes: 28 additions & 0 deletions KIF Tests/GestureTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,34 @@ - (void)testSwipingDownWithIdentifier
[tester waitForViewWithAccessibilityLabel:@"Down"];
}

- (void)testSwipingFromScreenEdgeLeft
{
UIView *view = [tester waitForViewWithAccessibilityIdentifier:@"gestures.swipeMe"];
CGSize windowSize = view.window.bounds.size;
CGPoint point = CGPointMake(0.5, 200);
point = [view convertPoint:point fromView:view.window];
KIFDisplacement displacement = CGPointMake(windowSize.width * 0.5, 5);
[view dragFromPoint:point displacement:displacement steps:20];
[tester waitForAbsenceOfViewWithAccessibilityLabel:@"LeftEdge"];

[tester swipeFromEdge:UIRectEdgeLeft];
[tester waitForViewWithAccessibilityLabel:@"LeftEdge"];
}

- (void)testSwipingFromScreenEdgeRight
{
UIView *view = [tester waitForViewWithAccessibilityIdentifier:@"gestures.swipeMe"];
CGSize windowSize = view.window.bounds.size;
CGPoint point = CGPointMake(windowSize.width - 0.5, 200);
point = [view convertPoint:point fromView:view.window];
KIFDisplacement displacement = CGPointMake(-windowSize.width * 0.5, 5);
[view dragFromPoint:point displacement:displacement steps:20];
[tester waitForAbsenceOfViewWithAccessibilityLabel:@"RightEdge"];

[tester swipeFromEdge:UIRectEdgeRight];
[tester waitForViewWithAccessibilityLabel:@"RightEdge"];
}

- (void)testScrolling
{
// Needs to be offset from the edge to prevent the navigation controller's interactivePopGestureRecognizer from triggering
Expand Down
12 changes: 12 additions & 0 deletions KIF Tests/GestureTests_ViewTestActor.m
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,16 @@ - (void)testMissingScrollableElement
KIFExpectFailure([[[viewTester usingTimeout:0.25] usingIdentifier:@"Unknown"] scrollByFractionOfSizeHorizontal:0.5 vertical:0.5]);
}

- (void)testSwipingFromScreenEdgeLeft
{
[viewTester swipeFromEdge:UIRectEdgeLeft];
[[viewTester usingLabel:@"LeftEdge"] waitForView];
}

- (void)testSwipingFromScreenEdgeRight
{
[viewTester swipeFromEdge:UIRectEdgeRight];
[[viewTester usingLabel:@"RightEdge"] waitForView];
}

@end
1 change: 1 addition & 0 deletions KIF Tests/LongPressTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ @implementation LongPressTests

- (void)beforeEach
{
UIPasteboard.generalPasteboard.string = nil;
[tester tapViewWithAccessibilityLabel:@"Tapping"];
}

Expand Down
1 change: 1 addition & 0 deletions KIF Tests/LongPressTests_ViewTestActor.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ @implementation LongPressTests_ViewTestActor

- (void)beforeEach
{
UIPasteboard.generalPasteboard.string = nil;
[[viewTester usingLabel:@"Tapping"] tap];
}

Expand Down
4 changes: 2 additions & 2 deletions KIF Tests/ModalViewTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ - (void)testInteractionWithAnAlertView

- (void)testInteractionWithAnActionSheet
{
[tester tapViewWithAccessibilityLabel:@"UIActionSheet"];
[tester waitForViewWithAccessibilityLabel:@"Action Sheet"];
[tester tapViewWithAccessibilityLabel:@"UIAlertController"];
[tester waitForViewWithAccessibilityLabel:@"Alert Controller"];
[tester waitForTappableViewWithAccessibilityLabel:@"Destroy"];
[tester waitForTappableViewWithAccessibilityLabel:@"A"];
[tester waitForTappableViewWithAccessibilityLabel:@"B"];
Expand Down
4 changes: 2 additions & 2 deletions KIF Tests/ModalViewTests_ViewTestActor.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ - (void)testInteractionWithAnAlertView

- (void)testInteractionWithAnActionSheet
{
[[viewTester usingLabel:@"UIActionSheet"] tap];
[[viewTester usingLabel:@"Action Sheet"] waitForView];
[[viewTester usingLabel:@"UIAlertController"] tap];
[[viewTester usingLabel:@"Alert Controller"] waitForView];
[[viewTester usingLabel:@"Destroy"] waitForTappableView];
[[viewTester usingLabel:@"A"] waitForTappableView];
[[viewTester usingLabel:@"B"] waitForTappableView];
Expand Down
43 changes: 0 additions & 43 deletions KIF Tests/SystemTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -63,48 +63,6 @@ - (void)testMemoryWarningSimulator
}

- (void)testMockingOpenURL
{
__block BOOL openURLReturnValue;
__block BOOL canOpenURLReturnValue;
[system waitForApplicationToOpenURL:@"test123://" whileExecutingBlock:^{
NSURL *uninstalledAppURL = [NSURL URLWithString:@"test123://"];
canOpenURLReturnValue = [[UIApplication sharedApplication] canOpenURL:uninstalledAppURL];
openURLReturnValue = [[UIApplication sharedApplication] openURL:uninstalledAppURL];
} returning:NO];
KIFAssertEqual(NO, openURLReturnValue, @"openURL: should have returned NO");
KIFAssertEqual(NO, canOpenURLReturnValue, @"canOpenURL: should have returned NO");

[system waitForApplicationToOpenURL:@"test123://" whileExecutingBlock:^{
NSURL *installedAppURL = [NSURL URLWithString:@"test123://"];
canOpenURLReturnValue = [[UIApplication sharedApplication] canOpenURL:installedAppURL];
openURLReturnValue = [[UIApplication sharedApplication] openURL:installedAppURL];
} returning:YES];
KIFAssertEqual(YES, openURLReturnValue, @"openURL: should have returned YES");
KIFAssertEqual(YES, canOpenURLReturnValue, @"canOpenURL: should have returned YES");

[system waitForApplicationToOpenURLWithScheme:@"test123" whileExecutingBlock:^{
NSURL *installedAppURL = [NSURL URLWithString:@"test123://some/path?query"];
canOpenURLReturnValue = [[UIApplication sharedApplication] canOpenURL:installedAppURL];
openURLReturnValue = [[UIApplication sharedApplication] openURL:installedAppURL];
} returning:YES];
KIFAssertEqual(YES, openURLReturnValue, @"openURL: should have returned YES");
KIFAssertEqual(YES, canOpenURLReturnValue, @"canOpenURL: should have returned YES");

[system waitForApplicationToOpenAnyURLWhileExecutingBlock:^{
NSURL *someURL = [NSURL URLWithString:@"423543523454://"];
canOpenURLReturnValue = [[UIApplication sharedApplication] canOpenURL:someURL];
openURLReturnValue = [[UIApplication sharedApplication] openURL:someURL];
} returning:YES];
KIFAssertEqual(YES, openURLReturnValue, @"openURL: should have returned YES");
KIFAssertEqual(YES, canOpenURLReturnValue, @"canOpenURL: should have returned YES");

NSURL *fakeURL = [NSURL URLWithString:@"this-is-a-fake-url://"];
KIFAssertFalse([[UIApplication sharedApplication] canOpenURL:fakeURL], @"Should no longer be mocking, reject bad URL.");
KIFAssertFalse([[UIApplication sharedApplication] openURL:fakeURL], @"Should no longer be mocking, reject bad URL.");
}

#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 100000
- (void)testMockingOpenURLiOS10xAndUp
{
__block BOOL canOpenURLReturnValue;
[system waitForApplicationToOpenURL:@"test123://" whileExecutingBlock:^{
Expand Down Expand Up @@ -138,6 +96,5 @@ - (void)testMockingOpenURLiOS10xAndUp
NSURL *fakeURL = [NSURL URLWithString:@"this-is-a-fake-url://"];
KIFAssertFalse([[UIApplication sharedApplication] canOpenURL:fakeURL], @"Should no longer be mocking, reject bad URL.");
}
#endif

@end
1 change: 1 addition & 0 deletions KIF Tests/TypingTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ @implementation TypingTests

- (void)beforeEach
{
UIPasteboard.generalPasteboard.string = nil;
[tester tapViewWithAccessibilityLabel:@"Tapping"];
}

Expand Down
1 change: 1 addition & 0 deletions KIF Tests/TypingTests_ViewTestActor.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ @implementation TypingTests_ViewTestActor

- (void)beforeEach
{
UIPasteboard.generalPasteboard.string = nil;
[[viewTester usingLabel:@"Tapping"] tap];
}

Expand Down
4 changes: 2 additions & 2 deletions KIF.podspec
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Pod::Spec.new do |s|
s.name = "KIF"
s.version = "3.8.9"
s.version = "3.9.0"
s.summary = "Keep It Functional - iOS UI acceptance testing in an XCUnit harness."
s.homepage = "https://github.com/kif-framework/KIF/"
s.license = 'Apache 2.0'
s.authors = 'Michael Thole', 'Eric Firestone', 'Jim Puls', 'Brian Nickel'
s.source = { :git => "https://github.com/kif-framework/KIF.git", :tag => "v#{ s.version.to_s }" }
s.platform = :ios, '10.0'
s.platform = :ios, '11.0'
s.frameworks = 'CoreGraphics', 'QuartzCore', 'IOKit', 'WebKit', 'XCTest'
s.default_subspec = 'Core'
s.requires_arc = true
Expand Down
6 changes: 3 additions & 3 deletions KIF.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1789,7 +1789,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
ONLY_ACTIVE_ARCH = YES;
PUBLIC_HEADERS_FOLDER_PATH = "include/$(PRODUCT_NAME)";
SDKROOT = iphoneos;
Expand Down Expand Up @@ -1834,7 +1834,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
PUBLIC_HEADERS_FOLDER_PATH = "include/$(PRODUCT_NAME)";
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
Expand Down Expand Up @@ -2097,7 +2097,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
PUBLIC_HEADERS_FOLDER_PATH = "include/$(PRODUCT_NAME)";
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import PackageDescription
let package = Package(
name: "KIF",
platforms: [
.iOS(.v9)
.iOS(.v11)
],
products: [
.library(
Expand Down
10 changes: 9 additions & 1 deletion Sources/KIF/Additions/UIApplication-KIFAdditions.m
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,22 @@ - (BOOL)writeScreenshotForLine:(NSUInteger)lineNumber inFile:(NSString *)filenam
}
return NO;
}


UIWindow *keyboardWindow = [self keyboardWindow];

UIGraphicsBeginImageContextWithOptions([[windows objectAtIndex:0] bounds].size, YES, 0);
for (UIWindow *window in windows) {
//avoid https://github.com/kif-framework/KIF/issues/679
if (window.hidden) {
continue;
}

if (@available(iOS 17.0, *)) {
if (window == keyboardWindow) {
continue;
}
}

if ([window respondsToSelector:@selector(drawViewHierarchyInRect:afterScreenUpdates:)]) {
[window drawViewHierarchyInRect:window.bounds afterScreenUpdates:YES];
} else {
Expand Down
1 change: 1 addition & 0 deletions Sources/KIF/Additions/UITouch-KIFAdditions.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@

- (void)setLocationInWindow:(CGPoint)location;
- (void)setPhaseAndUpdateTimestamp:(UITouchPhase)phase;
- (void)setIsFromEdge:(BOOL)isFromEdge;

@end
7 changes: 7 additions & 0 deletions Sources/KIF/Additions/UITouch-KIFAdditions.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ - (void)_setIsFirstTouchForView:(BOOL)firstTouchForView;
- (void)_setIsTapToClick:(BOOL)tapToClick;

- (void)_setHidEvent:(IOHIDEventRef)event;
- (void)_setEdgeType:(NSInteger)edgeType;

@end

Expand Down Expand Up @@ -117,6 +118,12 @@ - (void)setPhaseAndUpdateTimestamp:(UITouchPhase)phase
[self setPhase:phase];
}

- (void)setIsFromEdge:(BOOL)isFromEdge
{
NSInteger edgeType = isFromEdge ? 4 : 0;
[self _setEdgeType:edgeType];
}

- (void)kif_setHidEvent {
IOHIDEventRef event = kif_IOHIDEventWithTouches(@[self]);
[self _setHidEvent:event];
Expand Down
1 change: 1 addition & 0 deletions Sources/KIF/Additions/UIView-KIFAdditions.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ typedef CGPoint KIFDisplacement;
- (void)dragFromPoint:(CGPoint)startPoint toPoint:(CGPoint)endPoint;
- (void)dragFromPoint:(CGPoint)startPoint toPoint:(CGPoint)endPoint steps:(NSUInteger)stepCount;
- (void)dragFromPoint:(CGPoint)startPoint displacement:(KIFDisplacement)displacement steps:(NSUInteger)stepCount;
- (void)dragFromEdge:(UIRectEdge)startEdge toEdge:(UIRectEdge)endEdge;
- (void)dragAlongPathWithPoints:(CGPoint *)points count:(NSInteger)count;
- (void)twoFingerPanFromPoint:(CGPoint)startPoint toPoint:(CGPoint)toPoint steps:(NSUInteger)stepCount;
- (void)pinchAtPoint:(CGPoint)centerPoint distance:(CGFloat)distance steps:(NSUInteger)stepCount;
Expand Down
26 changes: 26 additions & 0 deletions Sources/KIF/Additions/UIView-KIFAdditions.m
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,27 @@ - (void)dragFromPoint:(CGPoint)startPoint displacement:(KIFDisplacement)displace
[self dragPointsAlongPaths:@[path]];
}

- (void)dragFromEdge:(UIRectEdge)startEdge toEdge:(UIRectEdge)endEdge
{
CGFloat width = self.bounds.size.width;
CGFloat height = self.bounds.size.height;
CGFloat edgeInset = 0.5;
NSDictionary *edgeToPoint = @{
@(UIRectEdgeTop): @(CGPointMake(width / 2, edgeInset)),
@(UIRectEdgeLeft): @(CGPointMake(edgeInset, height / 2)),
@(UIRectEdgeBottom): @(CGPointMake(width / 2, height - edgeInset)),
@(UIRectEdgeRight): @(CGPointMake(width - edgeInset, height / 2)),
};
CGPoint startPoint = [edgeToPoint[@(startEdge)] CGPointValue];
CGPoint endPoint = [edgeToPoint[@(endEdge)] CGPointValue];

CGPoint screenPoint = [self convertPoint:startPoint toView:self.window];
BOOL isFromScreenEdge = (screenPoint.x < 1 || screenPoint.x > self.window.bounds.size.width - 1);

NSArray<NSValue *> *path = [self pointsFromStartPoint:startPoint toPoint:endPoint steps:20];
[self dragPointsAlongPaths:@[path] isFromEdge:isFromScreenEdge];
}

- (void)dragAlongPathWithPoints:(CGPoint *)points count:(NSInteger)count;
{
// convert point array into NSArray with NSValue
Expand All @@ -648,6 +669,10 @@ - (void)dragAlongPathWithPoints:(CGPoint *)points count:(NSInteger)count;
}

- (void)dragPointsAlongPaths:(NSArray<NSArray<NSValue *> *> *)arrayOfPaths {
[self dragPointsAlongPaths:arrayOfPaths isFromEdge:NO];
}

- (void)dragPointsAlongPaths:(NSArray<NSArray<NSValue *> *> *)arrayOfPaths isFromEdge:(BOOL)isFromEdge {
// There must be at least one path with at least one point
if (arrayOfPaths.count == 0 || arrayOfPaths.firstObject.count == 0)
{
Expand Down Expand Up @@ -692,6 +717,7 @@ - (void)dragPointsAlongPaths:(NSArray<NSArray<NSValue *> *> *)arrayOfPaths {
point = [self convertPoint:point fromView:self.window];
UITouch *touch = [[UITouch alloc] initAtPoint:point inView:self];
[touch setPhaseAndUpdateTimestamp:UITouchPhaseBegan];
[touch setIsFromEdge:isFromEdge];
[touches addObject:touch];
}
UIEvent *eventDown = [self eventWithTouches:[NSArray arrayWithArray:touches]];
Expand Down
6 changes: 6 additions & 0 deletions Sources/KIF/Classes/KIFUITestActor.h
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,12 @@ typedef NS_ENUM(NSUInteger, KIFPullToRefreshTiming) {
*/
- (void)tapScreenAtPoint:(CGPoint)screenPoint;

/*!
@abstract Performs a swipe gesture starting from the specified edge of the screen.
@param edge The edge from which the swipe gesture should start.
*/
- (void)swipeFromEdge:(UIRectEdge)edge;

/*!
@abstract Performs a long press on a particular view in the view hierarchy.
@discussion The view or accessibility element with the given label is searched for in the view hierarchy. If the element isn't found or isn't currently tappable, then the step will attempt to wait until it is. Once the view is present and tappable, touch events are simulated in the center of the view or element.
Expand Down
Loading
Loading