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

Side by Side Diff: ios/chrome/browser/payments/payment_request_error_coordinator_unittest.mm

Issue 2701923003: [Payment Request] Error message screen (Closed)
Patch Set: rebase 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #import "ios/chrome/browser/payments/payment_request_error_coordinator.h"
6
7 #include "base/mac/foundation_util.h"
8 #include "base/test/ios/wait_util.h"
9 #import "ios/chrome/browser/payments/payment_request_error_view_controller.h"
10 #import "ios/chrome/test/scoped_key_window.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12 #include "testing/platform_test.h"
13 #include "third_party/ocmock/OCMock/OCMock.h"
14 #include "third_party/ocmock/gtest_support.h"
15
16 typedef PlatformTest PaymentRequestErrorCoordinatorTest;
17
18 // Tests that invoking start and stop on the coordinator presents and dismisses
19 // the payment request error view controller, respectively.
20 TEST(PaymentRequestErrorCoordinatorTest, StartAndStop) {
21 UIViewController* base_view_controller = [[UIViewController alloc] init];
22 ScopedKeyWindow scoped_key_window_;
23 [scoped_key_window_.Get() setRootViewController:base_view_controller];
24
25 PaymentRequestErrorCoordinator* coordinator =
26 [[PaymentRequestErrorCoordinator alloc]
27 initWithBaseViewController:base_view_controller];
28
29 [coordinator start];
30 // Short delay to allow animation to complete.
31 base::test::ios::SpinRunLoopWithMaxDelay(base::TimeDelta::FromSecondsD(1.0));
32 id presented_view_controller =
33 [coordinator baseViewController].presentedViewController;
34 EXPECT_TRUE([presented_view_controller
35 isMemberOfClass:[PaymentRequestErrorViewController class]]);
36
37 [coordinator stop];
38 // Delay to allow animation to complete.
39 base::test::ios::SpinRunLoopWithMinDelay(base::TimeDelta::FromSecondsD(2));
40 EXPECT_EQ(nil, [coordinator baseViewController].presentedViewController);
41 }
42
43 // Tests that calling the view controller delegate method which notifies the
44 // coordinator that the user has dismissed the error invokes the corresponding
45 // coordinator delegate method.
46 TEST(PaymentRequestErrorCoordinatorTest, DidDismiss) {
47 UIViewController* base_view_controller = [[UIViewController alloc] init];
48 ScopedKeyWindow scoped_key_window_;
49 [scoped_key_window_.Get() setRootViewController:base_view_controller];
50
51 PaymentRequestErrorCoordinator* coordinator =
52 [[PaymentRequestErrorCoordinator alloc]
53 initWithBaseViewController:base_view_controller];
54
55 // Mock the coordinator delegate.
56 id delegate = [OCMockObject
57 mockForProtocol:@protocol(PaymentRequestErrorCoordinatorDelegate)];
58 [[delegate expect] paymentRequestErrorCoordinatorDidDismiss:coordinator];
59 [coordinator setDelegate:delegate];
60
61 [coordinator start];
62 // Short delay to allow animation to complete.
63 base::test::ios::SpinRunLoopWithMaxDelay(base::TimeDelta::FromSecondsD(1.0));
64
65 // Call the controller delegate method.
66 id presented_view_controller =
67 [coordinator baseViewController].presentedViewController;
68 PaymentRequestErrorViewController* view_controller =
69 base::mac::ObjCCastStrict<PaymentRequestErrorViewController>(
70 presented_view_controller);
71 [coordinator paymentRequestErrorViewControllerDidDismiss:view_controller];
72
73 EXPECT_OCMOCK_VERIFY(delegate);
74 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698