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

Side by Side Diff: chrome/browser/ui/views/payments/payment_request_browsertest.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
1 // Copyright 2017 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <vector> 5 #include <vector>
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/ui/browser_commands.h" 9 #include "chrome/browser/ui/browser_commands.h"
10 #include "chrome/browser/ui/views/payments/payment_request_browsertest_base.h"
10 #include "chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h" 11 #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" 12 #include "chrome/test/base/ui_test_utils.h"
13 #include "components/payments/content/payment_request.h" 13 #include "components/payments/content/payment_request.h"
14 #include "components/payments/content/payment_request_web_contents_manager.h" 14 #include "components/payments/content/payment_request_web_contents_manager.h"
15 #include "components/web_modal/web_contents_modal_dialog_manager.h" 15 #include "components/web_modal/web_contents_modal_dialog_manager.h"
16 #include "content/public/test/browser_test_utils.h" 16 #include "content/public/test/browser_test_utils.h"
17 17
18 namespace payments { 18 namespace payments {
19 19
20 class PaymentRequestWebContentsManagerTest 20 class PaymentRequestWebContentsManagerTest
21 : public PaymentRequestInteractiveTestBase { 21 : public PaymentRequestBrowserTestBase {
22 protected: 22 protected:
23 PaymentRequestWebContentsManagerTest() 23 PaymentRequestWebContentsManagerTest()
24 : PaymentRequestInteractiveTestBase( 24 : PaymentRequestBrowserTestBase(
25 "/payment_request_multiple_requests.html") {} 25 "/payment_request_multiple_requests.html") {}
26 26
27 private: 27 private:
28 DISALLOW_COPY_AND_ASSIGN(PaymentRequestWebContentsManagerTest); 28 DISALLOW_COPY_AND_ASSIGN(PaymentRequestWebContentsManagerTest);
29 }; 29 };
30 30
31 // If the page creates multiple PaymentRequest objects, it should not crash. 31 // If the page creates multiple PaymentRequest objects, it should not crash.
32 IN_PROC_BROWSER_TEST_F(PaymentRequestWebContentsManagerTest, MultipleRequests) { 32 IN_PROC_BROWSER_TEST_F(PaymentRequestWebContentsManagerTest, MultipleRequests) {
33 const std::vector<PaymentRequest*> payment_requests = 33 const std::vector<PaymentRequest*> payment_requests =
34 GetPaymentRequests(GetActiveWebContents()); 34 GetPaymentRequests(GetActiveWebContents());
35 EXPECT_EQ(5U, payment_requests.size()); 35 EXPECT_EQ(5U, payment_requests.size());
36 } 36 }
37 37
38 class PaymentRequestNoShippingTest : public PaymentRequestInteractiveTestBase { 38 class PaymentRequestNoShippingTest : public PaymentRequestBrowserTestBase {
39 protected: 39 protected:
40 PaymentRequestNoShippingTest() 40 PaymentRequestNoShippingTest()
41 : PaymentRequestInteractiveTestBase( 41 : PaymentRequestBrowserTestBase(
42 "/payment_request_no_shipping_test.html") {} 42 "/payment_request_no_shipping_test.html") {}
43 43
44 private: 44 private:
45 DISALLOW_COPY_AND_ASSIGN(PaymentRequestNoShippingTest); 45 DISALLOW_COPY_AND_ASSIGN(PaymentRequestNoShippingTest);
46 }; 46 };
47 47
48 IN_PROC_BROWSER_TEST_F(PaymentRequestNoShippingTest, 48 IN_PROC_BROWSER_TEST_F(PaymentRequestNoShippingTest,
49 OpenAndNavigateToOrderSummary) { 49 OpenAndNavigateToOrderSummary) {
50 InvokePaymentRequestUI(); 50 InvokePaymentRequestUI();
51 51
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 IN_PROC_BROWSER_TEST_F(PaymentRequestNoShippingTest, OpenAndReload) { 86 IN_PROC_BROWSER_TEST_F(PaymentRequestNoShippingTest, OpenAndReload) {
87 InvokePaymentRequestUI(); 87 InvokePaymentRequestUI();
88 88
89 ResetEventObserver(DialogEvent::DIALOG_CLOSED); 89 ResetEventObserver(DialogEvent::DIALOG_CLOSED);
90 90
91 chrome::Reload(browser(), WindowOpenDisposition::CURRENT_TAB); 91 chrome::Reload(browser(), WindowOpenDisposition::CURRENT_TAB);
92 92
93 WaitForObservedEvent(); 93 WaitForObservedEvent();
94 } 94 }
95 95
96 class PaymentRequestAbortTest : public PaymentRequestInteractiveTestBase { 96 class PaymentRequestAbortTest : public PaymentRequestBrowserTestBase {
97 protected: 97 protected:
98 PaymentRequestAbortTest() 98 PaymentRequestAbortTest()
99 : PaymentRequestInteractiveTestBase("/payment_request_abort_test.html") {} 99 : PaymentRequestBrowserTestBase("/payment_request_abort_test.html") {}
100 100
101 private: 101 private:
102 DISALLOW_COPY_AND_ASSIGN(PaymentRequestAbortTest); 102 DISALLOW_COPY_AND_ASSIGN(PaymentRequestAbortTest);
103 }; 103 };
104 104
105 // Testing the use of the abort() JS API. 105 // Testing the use of the abort() JS API.
106 IN_PROC_BROWSER_TEST_F(PaymentRequestAbortTest, OpenThenAbort) { 106 IN_PROC_BROWSER_TEST_F(PaymentRequestAbortTest, OpenThenAbort) {
107 InvokePaymentRequestUI(); 107 InvokePaymentRequestUI();
108 108
109 ResetEventObserver(DialogEvent::DIALOG_CLOSED); 109 ResetEventObserver(DialogEvent::DIALOG_CLOSED);
110 110
111 content::WebContents* web_contents = GetActiveWebContents(); 111 content::WebContents* web_contents = GetActiveWebContents();
112 const std::string click_buy_button_js = 112 const std::string click_buy_button_js =
113 "(function() { document.getElementById('abort').click(); })();"; 113 "(function() { document.getElementById('abort').click(); })();";
114 ASSERT_TRUE(content::ExecuteScript(web_contents, click_buy_button_js)); 114 ASSERT_TRUE(content::ExecuteScript(web_contents, click_buy_button_js));
115 115
116 WaitForObservedEvent(); 116 WaitForObservedEvent();
117 117
118 // The web-modal dialog should now be closed. 118 // The web-modal dialog should now be closed.
119 web_modal::WebContentsModalDialogManager* web_contents_modal_dialog_manager = 119 web_modal::WebContentsModalDialogManager* web_contents_modal_dialog_manager =
120 web_modal::WebContentsModalDialogManager::FromWebContents(web_contents); 120 web_modal::WebContentsModalDialogManager::FromWebContents(web_contents);
121 EXPECT_FALSE(web_contents_modal_dialog_manager->IsDialogActive()); 121 EXPECT_FALSE(web_contents_modal_dialog_manager->IsDialogActive());
122 } 122 }
123 123
124 } // namespace payments 124 } // namespace payments
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698