Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(156)

Unified Diff: ios/chrome/browser/payments/payment_request_error_coordinator_unittest.mm

Issue 2701923003: [Payment Request] Error message screen (Closed)
Patch Set: Addressed comments Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ios/chrome/browser/payments/payment_request_error_coordinator_unittest.mm
diff --git a/ios/chrome/browser/payments/payment_request_error_coordinator_unittest.mm b/ios/chrome/browser/payments/payment_request_error_coordinator_unittest.mm
new file mode 100644
index 0000000000000000000000000000000000000000..1cad60d53a9fb368d5739bbe61f66db40f6d39e4
--- /dev/null
+++ b/ios/chrome/browser/payments/payment_request_error_coordinator_unittest.mm
@@ -0,0 +1,76 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import "ios/chrome/browser/payments/payment_request_error_coordinator.h"
+
+#include "base/mac/foundation_util.h"
+#include "base/test/ios/wait_util.h"
+#import "ios/chrome/browser/payments/payment_request_error_view_controller.h"
+#import "ios/chrome/test/scoped_key_window.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "testing/platform_test.h"
+#include "third_party/ocmock/OCMock/OCMock.h"
+#include "third_party/ocmock/gtest_support.h"
+
+typedef PlatformTest PaymentRequestErrorCoordinatorTest;
+
+// Tests that invoking start and stop on the coordinator presents and dismisses
+// the payment request error view controller, respectively.
+TEST(PaymentRequestErrorCoordinatorTest, StartAndStop) {
+ UIViewController* base_view_controller =
+ [[[UIViewController alloc] init] autorelease];
+ ScopedKeyWindow scoped_key_window_;
+ [scoped_key_window_.Get() setRootViewController:base_view_controller];
+
+ PaymentRequestErrorCoordinator* coordinator =
+ [[[PaymentRequestErrorCoordinator alloc]
+ initWithBaseViewController:base_view_controller] autorelease];
+
+ [coordinator start];
+ // Short delay to allow animation to complete.
+ base::test::ios::SpinRunLoopWithMaxDelay(base::TimeDelta::FromSecondsD(1.0));
+ id persented_view_controller =
lpromero 2017/02/21 16:51:07 *presented
Moe 2017/02/21 22:56:15 Done.
+ [coordinator baseViewController].presentedViewController;
+ EXPECT_TRUE([persented_view_controller
+ isMemberOfClass:[PaymentRequestErrorViewController class]]);
+
+ [coordinator stop];
+ // Delay to allow animation to complete.
+ base::test::ios::SpinRunLoopWithMinDelay(base::TimeDelta::FromSecondsD(2));
+ EXPECT_EQ(nil, [coordinator baseViewController].presentedViewController);
+}
+
+// Tests that calling the view controller delegate method which notifies the
+// coordinator that the user has dismissed the error invokes the corresponding
+// coordinator delegate method.
+TEST(PaymentRequestErrorCoordinatorTest, DidDismiss) {
+ UIViewController* base_view_controller =
+ [[[UIViewController alloc] init] autorelease];
+ ScopedKeyWindow scoped_key_window_;
+ [scoped_key_window_.Get() setRootViewController:base_view_controller];
+
+ PaymentRequestErrorCoordinator* coordinator =
+ [[[PaymentRequestErrorCoordinator alloc]
+ initWithBaseViewController:base_view_controller] autorelease];
+
+ // Mock the coordinator delegate.
+ id delegate = [OCMockObject
+ mockForProtocol:@protocol(PaymentRequestErrorCoordinatorDelegate)];
+ [[delegate expect] paymentRequestErrorCoordinatorDidDismiss:coordinator];
+ [coordinator setDelegate:delegate];
+
+ [coordinator start];
+ // Short delay to allow animation to complete.
+ base::test::ios::SpinRunLoopWithMaxDelay(base::TimeDelta::FromSecondsD(1.0));
+
+ // Call the controller delegate method.
+ id persented_view_controller =
+ [coordinator baseViewController].presentedViewController;
+ PaymentRequestErrorViewController* view_controller =
+ base::mac::ObjCCastStrict<PaymentRequestErrorViewController>(
+ persented_view_controller);
+ [coordinator paymentRequestErrorViewControllerDidDismiss:view_controller];
+
+ EXPECT_OCMOCK_VERIFY(delegate);
+}

Powered by Google App Engine
This is Rietveld 408576698