Created
November 26, 2015 18:17
-
-
Save catehstn/fc9a16e6e9017d106f49 to your computer and use it in GitHub Desktop.
KIF tests for V1 UI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "ProcessImageTest.h" | |
#import "SHAStrings.h" | |
@interface ProcessImageTest () | |
// Dismiss the gallery once it has been opened. | |
- (void)cancelGallery; | |
// Sequence that results in two pictures in the results view. | |
- (void)choosePictureAndProcessSequence; | |
// Sequence that results in a picture in the edit view. | |
- (void)choosePictureSequence; | |
// Open the gallery. | |
- (void)openGallery; | |
// Rotate to the given orientation. | |
- (void)rotateToOrientation:(UIInterfaceOrientation)orientation; | |
// Choose a picture and trigger the edit view. | |
- (void)selectPicture; | |
// Swipe to the given view. | |
- (void)swipe:(KIFSwipeDirection)direction toView:(NSString *)view; | |
// Go back. | |
- (void)tapBackButtonTimes:(NSInteger)times; | |
// Wait for the home page. | |
- (void)waitForHomePage; | |
@end | |
@implementation ProcessImageTest | |
- (void)testRotateHomeScreen { | |
[self waitForHomePage]; | |
[self rotateToOrientation:UIInterfaceOrientationLandscapeLeft]; | |
[self waitForHomePage]; | |
[self rotateToOrientation:UIInterfaceOrientationPortraitUpsideDown]; | |
[self waitForHomePage]; | |
[self rotateToOrientation:UIInterfaceOrientationLandscapeRight]; | |
[self waitForHomePage]; | |
[self rotateToOrientation:UIInterfaceOrientationPortrait]; | |
[self waitForHomePage]; | |
} | |
- (void)testOpenInspireView { | |
[tester tapViewWithAccessibilityLabel:[SHAStrings inspireButtonTitleString]]; | |
[tester waitForViewWithAccessibilityLabel:@"Back"]; | |
[self tapBackButtonTimes:1]; | |
[self waitForHomePage]; | |
} | |
- (void)testOpenGalleryAndCancel { | |
[self openGallery]; | |
[self cancelGallery]; | |
[self waitForHomePage]; | |
} | |
- (void)testChooseImageAndGoBack { | |
[self choosePictureSequence]; | |
[self tapBackButtonTimes:1]; | |
[self waitForHomePage]; | |
} | |
- (void)testChooseImageAndRotate { | |
[self choosePictureSequence]; | |
[tester waitForViewWithAccessibilityLabel:[SHAStrings accuracyButtonTitleString]]; | |
[self rotateToOrientation:UIInterfaceOrientationLandscapeLeft]; | |
[tester waitForTappableViewWithAccessibilityLabel:[SHAStrings imageEditingImageA11yLabel]]; | |
[self rotateToOrientation:UIInterfaceOrientationPortraitUpsideDown]; | |
[tester waitForViewWithAccessibilityLabel:[SHAStrings accuracyButtonTitleString]]; | |
[self rotateToOrientation:UIInterfaceOrientationLandscapeRight]; | |
[tester waitForTappableViewWithAccessibilityLabel:[SHAStrings imageEditingImageA11yLabel]]; | |
[self rotateToOrientation:UIInterfaceOrientationPortrait]; | |
[tester waitForViewWithAccessibilityLabel:[SHAStrings accuracyButtonTitleString]]; | |
[self tapBackButtonTimes:1]; | |
[self waitForHomePage]; | |
} | |
- (void)testAccuracySliderAppears { | |
[self choosePictureSequence]; | |
[tester tapViewWithAccessibilityLabel:[SHAStrings accuracyButtonTitleString]]; | |
[tester waitForViewWithAccessibilityLabel:[SHAStrings accuracySliderA11yLabel]]; | |
[self tapBackButtonTimes:1]; | |
[self waitForHomePage]; | |
} | |
- (void)testToleranceSliderAppears { | |
[self choosePictureSequence]; | |
[tester tapViewWithAccessibilityLabel:[SHAStrings toleranceButtonTitleString]]; | |
[tester waitForViewWithAccessibilityLabel:[SHAStrings toleranceSliderA11yLabel]]; | |
[self tapBackButtonTimes:1]; | |
[self waitForHomePage]; | |
} | |
- (void)testChangeImageFromEditPage { | |
[self choosePictureSequence]; | |
[tester tapViewWithAccessibilityLabel:[SHAStrings galleryButtonA11yLabel]]; | |
[self selectPicture]; | |
[tester waitForViewWithAccessibilityLabel:[SHAStrings imageEditingViewControllerTitle]]; | |
[self tapBackButtonTimes:1]; | |
[self waitForHomePage]; | |
} | |
- (void)testProcessImage { | |
[self choosePictureAndProcessSequence]; | |
[self tapBackButtonTimes:2]; | |
[self waitForHomePage]; | |
} | |
- (void)testProcessImageAndRotate { | |
[self choosePictureAndProcessSequence]; | |
[tester waitForViewWithAccessibilityLabel:[SHAStrings showingDominantColorString]]; | |
[self rotateToOrientation:UIInterfaceOrientationLandscapeLeft]; | |
[tester waitForViewWithAccessibilityLabel:[SHAStrings showingDominantColorString]]; | |
[self rotateToOrientation:UIInterfaceOrientationPortraitUpsideDown]; | |
[tester waitForViewWithAccessibilityLabel:[SHAStrings showingDominantColorString]]; | |
[self rotateToOrientation:UIInterfaceOrientationLandscapeRight]; | |
[tester waitForViewWithAccessibilityLabel:[SHAStrings showingDominantColorString]]; | |
[self rotateToOrientation:UIInterfaceOrientationPortrait]; | |
[tester waitForViewWithAccessibilityLabel:[SHAStrings showingDominantColorString]]; | |
[self tapBackButtonTimes:2]; | |
[self waitForHomePage]; | |
} | |
- (void)testProcessImageAndSwipe { | |
[self choosePictureAndProcessSequence]; | |
[tester waitForViewWithAccessibilityLabel:[SHAStrings showingDominantColorString]]; | |
[self swipe:KIFSwipeDirectionRight toView:[SHAStrings hidingDominantColorString]]; | |
[self swipe:KIFSwipeDirectionRight toView:[SHAStrings showingDominantColorString]]; | |
[self swipe:KIFSwipeDirectionRight toView:[SHAStrings hidingDominantColorString]]; | |
[self swipe:KIFSwipeDirectionLeft toView:[SHAStrings showingDominantColorString]]; | |
[self swipe:KIFSwipeDirectionLeft toView:[SHAStrings hidingDominantColorString]]; | |
[self tapBackButtonTimes:2]; | |
[self waitForHomePage]; | |
} | |
- (void)testProcessImageGoBackRunAgain { | |
[self choosePictureAndProcessSequence]; | |
[self tapBackButtonTimes:1]; | |
[tester waitForViewWithAccessibilityLabel:[SHAStrings imageEditingViewControllerTitle]]; | |
[tester tapViewWithAccessibilityLabel:[SHAStrings applyButtonText]]; | |
[tester waitForViewWithAccessibilityLabel:[SHAStrings processedImageViewControllerTitle]]; | |
[self tapBackButtonTimes:2]; | |
[self waitForHomePage]; | |
} | |
- (void)testProcessImageAndShare { | |
[self choosePictureAndProcessSequence]; | |
[tester tapViewWithAccessibilityLabel:@"Share"]; | |
[tester waitForViewWithAccessibilityLabel:@"Mail"]; | |
[tester tapViewWithAccessibilityLabel:@"Cancel"]; | |
[self tapBackButtonTimes:2]; | |
[self waitForHomePage]; | |
} | |
#pragma mark helpers | |
- (void)cancelGallery { | |
[tester tapViewWithAccessibilityLabel:@"Cancel"]; | |
} | |
- (void)choosePictureAndProcessSequence { | |
[self choosePictureSequence]; | |
[tester waitForViewWithAccessibilityLabel:[SHAStrings imageEditingViewControllerTitle]]; | |
[tester tapViewWithAccessibilityLabel:[SHAStrings applyButtonText]]; | |
[tester waitForViewWithAccessibilityLabel:[SHAStrings processedImageViewControllerTitle]]; | |
} | |
- (void)choosePictureSequence { | |
[self openGallery]; | |
[self selectPicture]; | |
[tester waitForViewWithAccessibilityLabel:[SHAStrings imageEditingViewControllerTitle]]; | |
} | |
- (void)openGallery { | |
[tester tapViewWithAccessibilityLabel:[SHAStrings galleryButtonTitleString]]; | |
} | |
- (void)rotateToOrientation:(UIInterfaceOrientation)orientation { | |
[[UIDevice currentDevice] setValue:[NSNumber numberWithInt:orientation] forKey:@"orientation"]; | |
} | |
- (void)selectPicture { | |
// Should use [tester choosePhotoInAlbum:@"Moments" atRow:1 column:0] but not working. | |
[tester tapViewWithAccessibilityLabel:@"Camera Roll"]; | |
[tester waitForTimeInterval:1]; | |
[tester tapScreenAtPoint:CGPointMake(47, 150)]; | |
} | |
- (void)swipe:(KIFSwipeDirection)direction toView:(NSString *)view { | |
[tester swipeViewWithAccessibilityLabel:[SHAStrings processedImageA11yLabel] | |
inDirection:direction]; | |
[tester waitForViewWithAccessibilityLabel:view]; | |
} | |
- (void)tapBackButtonTimes:(NSInteger)times { | |
for (NSInteger i = 0; i < times; i++) { | |
[tester tapViewWithAccessibilityLabel:@"Back"]; | |
} | |
} | |
- (void)waitForHomePage { | |
[tester waitForViewWithAccessibilityLabel:[SHAStrings galleryButtonTitleString]]; | |
[tester waitForViewWithAccessibilityLabel:[SHAStrings inspireButtonTitleString]]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment