Last active
August 29, 2015 14:14
-
-
Save wanbok/99a25c6480056f4db15c to your computer and use it in GitHub Desktop.
모달뷰 띄우고 내리는 테스트 케이스: TestCase for presenting and dismissing (Modal)ViewController
This file contains 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
- (void)setUp { | |
[super setUp]; | |
[RKTestFactory setUp]; | |
[RKManagedObjectStore setDefaultStore:[RKTestFactory managedObjectStore]]; | |
appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; | |
storeCollectionViewController = [(UINavigationController *)appDelegate.window.rootViewController viewControllers][0]; | |
createStoreViewController = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"CreateStoreViewController"]; | |
} | |
- (void)tearDown { | |
if (storeCollectionViewController.presentedViewController) [createStoreViewController removeFromParentViewController]; | |
[RKTestFactory tearDown]; | |
[super tearDown]; | |
} | |
- (void)testCancelButton { | |
__block XCTestExpectation *presentVCExpection = [self expectationWithDescription:@"CreateStoreViewController가 떠야함"]; | |
[storeCollectionViewController presentViewController:createStoreViewController animated:NO completion:^{ | |
XCTAssertFalse(createStoreViewController.isBeingPresented, @"present 끝나야함"); | |
[presentVCExpection fulfill]; | |
}]; | |
XCTAssertTrue(createStoreViewController.isBeingPresented, @"present 중"); | |
[self waitForExpectationsWithTimeout:10 handler:^(NSError *error) { | |
XCTAssertNil(error, @"error"); | |
}]; | |
__block XCTestExpectation *dismissVCExpection = [self expectationWithDescription:@"CreateStoreViewController가 사라져야함"]; | |
[createStoreViewController dismissViewControllerAnimated:NO completion:^{ | |
XCTAssertFalse(createStoreViewController.isBeingDismissed, @"dismiss 끝나야함"); | |
[dismissVCExpection fulfill]; | |
}]; | |
XCTAssertTrue(createStoreViewController.isBeingDismissed, @"dismiss 중"); | |
[self waitForExpectationsWithTimeout:10 handler:^(NSError *error) { | |
XCTAssertNil(error, @"error"); | |
}]; | |
XCTAssertNil(storeCollectionViewController.presentedViewController, @"CreateStoreViewcontroller가 내려감"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment