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

Side by Side Diff: chrome/browser/ui/views/payments/payment_request_interactive_uitest.cc

Issue 2734693002: [Payments] Convert interactive tests to browsertests (Closed)
Patch Set: Initial Created 3 years, 9 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 #include <vector>
6
7 #include "base/macros.h"
8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/ui/browser_commands.h"
10 #include "chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h"
11 #include "chrome/browser/ui/views/payments/payment_request_interactive_uitest_ba se.h"
12 #include "chrome/test/base/ui_test_utils.h"
13 #include "components/payments/content/payment_request.h"
14 #include "components/payments/content/payment_request_web_contents_manager.h"
15 #include "components/web_modal/web_contents_modal_dialog_manager.h"
16 #include "content/public/test/browser_test_utils.h"
17
18 namespace payments {
19
20 class PaymentRequestWebContentsManagerTest
21 : public PaymentRequestInteractiveTestBase {
22 protected:
23 PaymentRequestWebContentsManagerTest()
24 : PaymentRequestInteractiveTestBase(
25 "/payment_request_multiple_requests.html") {}
26
27 private:
28 DISALLOW_COPY_AND_ASSIGN(PaymentRequestWebContentsManagerTest);
29 };
30
31 // If the page creates multiple PaymentRequest objects, it should not crash.
32 IN_PROC_BROWSER_TEST_F(PaymentRequestWebContentsManagerTest, MultipleRequests) {
33 const std::vector<PaymentRequest*> payment_requests =
34 GetPaymentRequests(GetActiveWebContents());
35 EXPECT_EQ(5U, payment_requests.size());
36 }
37
38 class PaymentRequestNoShippingTest : public PaymentRequestInteractiveTestBase {
39 protected:
40 PaymentRequestNoShippingTest()
41 : PaymentRequestInteractiveTestBase(
42 "/payment_request_no_shipping_test.html") {}
43
44 private:
45 DISALLOW_COPY_AND_ASSIGN(PaymentRequestNoShippingTest);
46 };
47
48 IN_PROC_BROWSER_TEST_F(PaymentRequestNoShippingTest,
49 OpenAndNavigateToOrderSummary) {
50 InvokePaymentRequestUI();
51
52 OpenOrderSummaryScreen();
53
54 // Verify the expected amounts are shown.
55 EXPECT_EQ(base::ASCIIToUTF16("USD $5.00"),
56 GetStyledLabelText(DialogViewID::ORDER_SUMMARY_TOTAL_AMOUNT_LABEL));
57 EXPECT_EQ(base::ASCIIToUTF16("$4.50"),
58 GetStyledLabelText(DialogViewID::ORDER_SUMMARY_LINE_ITEM_1));
59 EXPECT_EQ(base::ASCIIToUTF16("$0.50"),
60 GetStyledLabelText(DialogViewID::ORDER_SUMMARY_LINE_ITEM_2));
61 }
62
63 IN_PROC_BROWSER_TEST_F(PaymentRequestNoShippingTest, OpenAndNavigateTo404) {
64 InvokePaymentRequestUI();
65
66 ResetEventObserver(DialogEvent::DIALOG_CLOSED);
67
68 ui_test_utils::NavigateToURL(browser(),
69 https_server()->GetURL("/non-existent.html"));
70
71 WaitForObservedEvent();
72 }
73
74 IN_PROC_BROWSER_TEST_F(PaymentRequestNoShippingTest, OpenAndNavigateToSame) {
75 InvokePaymentRequestUI();
76
77 ResetEventObserver(DialogEvent::DIALOG_CLOSED);
78
79 ui_test_utils::NavigateToURL(
80 browser(),
81 https_server()->GetURL("/payment_request_no_shipping_test.html"));
82
83 WaitForObservedEvent();
84 }
85
86 IN_PROC_BROWSER_TEST_F(PaymentRequestNoShippingTest, OpenAndReload) {
87 InvokePaymentRequestUI();
88
89 ResetEventObserver(DialogEvent::DIALOG_CLOSED);
90
91 chrome::Reload(browser(), WindowOpenDisposition::CURRENT_TAB);
92
93 WaitForObservedEvent();
94 }
95
96 class PaymentRequestAbortTest : public PaymentRequestInteractiveTestBase {
97 protected:
98 PaymentRequestAbortTest()
99 : PaymentRequestInteractiveTestBase("/payment_request_abort_test.html") {}
100
101 private:
102 DISALLOW_COPY_AND_ASSIGN(PaymentRequestAbortTest);
103 };
104
105 // Testing the use of the abort() JS API.
106 IN_PROC_BROWSER_TEST_F(PaymentRequestAbortTest, OpenThenAbort) {
107 InvokePaymentRequestUI();
108
109 ResetEventObserver(DialogEvent::DIALOG_CLOSED);
110
111 content::WebContents* web_contents = GetActiveWebContents();
112 const std::string click_buy_button_js =
113 "(function() { document.getElementById('abort').click(); })();";
114 ASSERT_TRUE(content::ExecuteScript(web_contents, click_buy_button_js));
115
116 WaitForObservedEvent();
117
118 // The web-modal dialog should now be closed.
119 web_modal::WebContentsModalDialogManager* web_contents_modal_dialog_manager =
120 web_modal::WebContentsModalDialogManager::FromWebContents(web_contents);
121 EXPECT_FALSE(web_contents_modal_dialog_manager->IsDialogActive());
122 }
123
124 } // namespace payments
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698