From da29424c5eeddf6591da3d8438b38789b892dbfb Mon Sep 17 00:00:00 2001 From: Ben Guo Date: Fri, 15 Dec 2017 15:03:01 -0500 Subject: [PATCH] restore FBSnapshot helper method --- Tests/Tests/FBSnapshotTestCase+STPViewControllerLoading.h | 6 ++++++ Tests/Tests/FBSnapshotTestCase+STPViewControllerLoading.m | 5 +++++ Tests/Tests/STPAddCardViewControllerLocalizationTests.m | 3 +-- .../STPPaymentMethodsViewControllerLocalizationTests.m | 3 +-- .../STPShippingAddressViewControllerLocalizationTests.m | 3 +-- .../STPShippingMethodsViewControllerLocalizationTests.m | 3 +-- 6 files changed, 15 insertions(+), 8 deletions(-) diff --git a/Tests/Tests/FBSnapshotTestCase+STPViewControllerLoading.h b/Tests/Tests/FBSnapshotTestCase+STPViewControllerLoading.h index 67ec9ba2e59..6778ac162a6 100644 --- a/Tests/Tests/FBSnapshotTestCase+STPViewControllerLoading.h +++ b/Tests/Tests/FBSnapshotTestCase+STPViewControllerLoading.h @@ -10,6 +10,12 @@ @interface FBSnapshotTestCase (STPViewControllerLoading) +/** + Embeds the given controller in a navigation controller, prepares it for + snapshot testing and returns the view controller's view. + */ +- (UIView *)stp_preparedAndSizedViewForSnapshotTestFromViewController:(UIViewController *viewController)viewController; + /** Returns a navigation controller initialized with the given root view controller and prepares it for snapshot testing (adding it to a UIWindow and loading views) diff --git a/Tests/Tests/FBSnapshotTestCase+STPViewControllerLoading.m b/Tests/Tests/FBSnapshotTestCase+STPViewControllerLoading.m index 2a5d7031ad5..cf37bab1528 100644 --- a/Tests/Tests/FBSnapshotTestCase+STPViewControllerLoading.m +++ b/Tests/Tests/FBSnapshotTestCase+STPViewControllerLoading.m @@ -11,6 +11,11 @@ @implementation FBSnapshotTestCase (STPViewControllerLoading) +- (UIView *)stp_preparedAndSizedViewForSnapshotTestFromViewController:(UIViewController *)viewController { + UINavigationController *navController = [self stp_navigationControllerForSnapshotTestWithRootVC:viewController]; + return [self stp_preparedAndSizedViewForSnapshotTestFromNavigationController:navController]; +} + - (UINavigationController *)stp_navigationControllerForSnapshotTestWithRootVC:(UIViewController *)viewController { UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:viewController]; UIWindow *testWindow = [[UIWindow alloc] initWithFrame:CGRectMake(0, 0, 320, 480)]; diff --git a/Tests/Tests/STPAddCardViewControllerLocalizationTests.m b/Tests/Tests/STPAddCardViewControllerLocalizationTests.m index 4f27fd164a4..19ce816c129 100644 --- a/Tests/Tests/STPAddCardViewControllerLocalizationTests.m +++ b/Tests/Tests/STPAddCardViewControllerLocalizationTests.m @@ -54,8 +54,7 @@ - (void)performSnapshotTestForLanguage:(NSString *)language delivery:(BOOL)deliv addCardVC.shippingAddress = [STPAddress new]; addCardVC.shippingAddress.line1 = @"1"; // trigger "use shipping address" button - UINavigationController *navController = [self stp_navigationControllerForSnapshotTestWithRootVC:addCardVC]; - UIView *viewToTest = [self stp_preparedAndSizedViewForSnapshotTestFromNavigationController:navController]; + UIView *viewToTest = [self stp_preparedAndSizedViewForSnapshotTestFromViewController:addCardVC]; if (delivery) { addCardVC.addressViewModel.addressFieldTableViewCountryCode = @"INVALID"; diff --git a/Tests/Tests/STPPaymentMethodsViewControllerLocalizationTests.m b/Tests/Tests/STPPaymentMethodsViewControllerLocalizationTests.m index b9e552c063c..3e681b286f9 100644 --- a/Tests/Tests/STPPaymentMethodsViewControllerLocalizationTests.m +++ b/Tests/Tests/STPPaymentMethodsViewControllerLocalizationTests.m @@ -40,8 +40,7 @@ - (void)performSnapshotTestForLanguage:(NSString *)language { delegate:delegate]; - UINavigationController *navController = [self stp_navigationControllerForSnapshotTestWithRootVC:paymentMethodsVC]; - UIView *viewToTest = [self stp_preparedAndSizedViewForSnapshotTestFromNavigationController:navController]; + UIView *viewToTest = [self stp_preparedAndSizedViewForSnapshotTestFromViewController:paymentMethodsVC]; FBSnapshotVerifyView(viewToTest, nil); [STPLocalizationUtils overrideLanguageTo:nil]; diff --git a/Tests/Tests/STPShippingAddressViewControllerLocalizationTests.m b/Tests/Tests/STPShippingAddressViewControllerLocalizationTests.m index 3179ddfbdde..ff0615175d4 100644 --- a/Tests/Tests/STPShippingAddressViewControllerLocalizationTests.m +++ b/Tests/Tests/STPShippingAddressViewControllerLocalizationTests.m @@ -68,8 +68,7 @@ - (void)performSnapshotTestForLanguage:(NSString *)language shippingType:(STPShi */ shippingVC.addressViewModel.addressFieldTableViewCountryCode = @"INVALID"; - UINavigationController *navController = [self stp_navigationControllerForSnapshotTestWithRootVC:shippingVC]; - UIView *viewToTest = [self stp_preparedAndSizedViewForSnapshotTestFromNavigationController:navController]; + UIView *viewToTest = [self stp_preparedAndSizedViewForSnapshotTestFromViewController:shippingVC]; FBSnapshotVerifyView(viewToTest, identifier); diff --git a/Tests/Tests/STPShippingMethodsViewControllerLocalizationTests.m b/Tests/Tests/STPShippingMethodsViewControllerLocalizationTests.m index e1c47dd9f78..79ad912a456 100644 --- a/Tests/Tests/STPShippingMethodsViewControllerLocalizationTests.m +++ b/Tests/Tests/STPShippingMethodsViewControllerLocalizationTests.m @@ -49,8 +49,7 @@ - (void)performSnapshotTestForLanguage:(NSString *)language { method2.identifier = @"fedex"; STPShippingMethodsViewController *shippingVC = [[STPShippingMethodsViewController alloc] initWithShippingMethods:@[method1, method2] selectedShippingMethod:method1 currency:@"usd" theme:[STPTheme defaultTheme]]; - UINavigationController *navController = [self stp_navigationControllerForSnapshotTestWithRootVC:shippingVC]; - UIView *viewToTest = [self stp_preparedAndSizedViewForSnapshotTestFromNavigationController:navController]; + UIView *viewToTest = [self stp_preparedAndSizedViewForSnapshotTestFromViewController:shippingVC]; FBSnapshotVerifyView(viewToTest, nil); [STPLocalizationUtils overrideLanguageTo:nil]; }