From 62ef522886b829cde50b77ab6b80d74869309c26 Mon Sep 17 00:00:00 2001 From: WenchaoD Date: Fri, 21 Apr 2017 18:15:30 +0800 Subject: [PATCH] Update UITest --- .../FSCalendarExampleUITests.m | 51 ++++++++++--------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/Example-Objc/FSCalendarExampleUITests/FSCalendarExampleUITests.m b/Example-Objc/FSCalendarExampleUITests/FSCalendarExampleUITests.m index 230ee6ad..b12b32b6 100644 --- a/Example-Objc/FSCalendarExampleUITests/FSCalendarExampleUITests.m +++ b/Example-Objc/FSCalendarExampleUITests/FSCalendarExampleUITests.m @@ -37,18 +37,7 @@ - (void)tearDown } -- (void)testExamples -{ - [self doTestDIY]; - [self doTestPrevNextButtons]; - [self doTestHidePlaceholders]; - [self doTestDelegateAppearance]; - [self doTestFullScreen]; - [self doTestScope]; - [self doTestStoryboard]; -} - -- (void)doTestDIY +- (void)testDIY { XCUIApplication *application = [[XCUIApplication alloc] init]; [[application.tables elementBoundByIndex:0].cells[@"DIY Example, Feature!"] tap]; @@ -71,7 +60,7 @@ - (void)doTestDIY [[application.buttons elementBoundByIndex:0] tap]; // Pop } -- (void)doTestPrevNextButtons +- (void)testPrevNextButtons { XCUIApplication *application = [[XCUIApplication alloc] init]; [[application.tables elementBoundByIndex:0].cells[@"Prev-Next Buttons"] tap]; @@ -89,7 +78,7 @@ - (void)doTestPrevNextButtons [[application.buttons elementBoundByIndex:0] tap]; // Pop } -- (void)doTestHidePlaceholders +- (void)testHidePlaceholders { XCUIApplication *application = [[XCUIApplication alloc] init]; [[application.tables elementBoundByIndex:0].cells[@"Hides Placeholder"] tap]; @@ -106,7 +95,7 @@ - (void)doTestHidePlaceholders [[application.buttons elementBoundByIndex:0] tap]; } -- (void)doTestDelegateAppearance +- (void)testDelegateAppearance { XCUIApplication *application = [[XCUIApplication alloc] init]; [[application.tables elementBoundByIndex:0].cells[@"Delegate Appearance"] tap]; @@ -143,7 +132,7 @@ - (void)doTestDelegateAppearance [[application.buttons elementBoundByIndex:0] tap]; } -- (void)doTestFullScreen +- (void)testFullScreen { XCUIApplication *application = [[XCUIApplication alloc] init]; [[application.tables elementBoundByIndex:0].cells[@"Full Screen Example"] tap]; @@ -160,7 +149,7 @@ - (void)doTestFullScreen [[application.buttons elementBoundByIndex:0] tap]; } -- (void)doTestScope +- (void)testScope { XCUIApplication *application = [[XCUIApplication alloc] init]; [[application.tables elementBoundByIndex:0].cells[@"FSCalendarScope Example"] tap]; @@ -190,7 +179,7 @@ - (void)doTestScope [[application.buttons elementBoundByIndex:0] tap]; } -- (void)doTestStoryboard +- (void)testStoryboard { XCUIApplication *application = [[XCUIApplication alloc] init]; [[application.tables elementBoundByIndex:0].cells[@"Storyboard Example"] tap]; @@ -252,25 +241,30 @@ - (void)doTestStoryboard [calendar swipeDown]; [calendar swipeDown]; + + XCUIElement *table = [application.tables elementBoundByIndex:0]; [NSThread sleepForTimeInterval:0.5]; [configureButton tap]; - [[application.tables elementBoundByIndex:0] swipeUp]; - [application.tables.staticTexts[@"Monday"] tap]; + XCUIElement *monday = application.tables.staticTexts[@"Monday"]; + [self swipeUpTable:table toElement:monday]; + [monday tap]; [calendar swipeUp]; [calendar swipeDown]; [NSThread sleepForTimeInterval:1]; [NSThread sleepForTimeInterval:0.5]; [configureButton tap]; - [[application.tables elementBoundByIndex:0] swipeUp]; - [application.tables.staticTexts[@"Tuesday"] tap]; + XCUIElement *tuesday = application.tables.staticTexts[@"Tuesday"]; + [self swipeUpTable:table toElement:monday]; + [tuesday tap]; [calendar swipeDown]; [calendar swipeUp]; [NSThread sleepForTimeInterval:0.5]; [configureButton tap]; - [[application.tables elementBoundByIndex:0] swipeUp]; - [application.tables.staticTexts[@"Sunday"] tap]; + XCUIElement *sunday = application.tables.staticTexts[@"Sunday"]; + [self swipeUpTable:table toElement:monday]; + [sunday tap]; [calendar swipeUp]; [calendar swipeDown]; [NSThread sleepForTimeInterval:1]; @@ -289,5 +283,14 @@ - (void)doTestStoryboard [[application.buttons elementBoundByIndex:0] tap]; } +- (void)swipeUpTable:(XCUIElement *)table toElement:(XCUIElement *)row +{ + NSInteger maxSwipe = 5; + NSInteger currentSwipe = 0; + while (currentSwipe < maxSwipe && !row.exists) { + currentSwipe++; + [table swipeUp]; + } +} @end