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

Side by Side Diff: chrome/browser/ui/views/payments/payment_request_browsertest_base.h

Issue 2709093006: Adding new shipping address editor view to payment flow. (Closed)
Patch Set: Bot failure fix 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 #ifndef CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_BROWSERTEST_BASE_H_ 5 #ifndef CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_BROWSERTEST_BASE_H_
6 #define CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_BROWSERTEST_BASE_H_ 6 #define CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_BROWSERTEST_BASE_H_
7 7
8 #include <memory>
9 #include <string>
8 #include <vector> 10 #include <vector>
9 11
10 #include "base/command_line.h" 12 #include "base/command_line.h"
11 #include "base/macros.h" 13 #include "base/macros.h"
12 #include "base/run_loop.h" 14 #include "base/run_loop.h"
13 #include "base/strings/string16.h" 15 #include "base/strings/string16.h"
14 #include "chrome/browser/ui/views/payments/payment_request_dialog_view.h" 16 #include "chrome/browser/ui/views/payments/payment_request_dialog_view.h"
15 #include "chrome/browser/ui/views/payments/test_chrome_payment_request_delegate. h" 17 #include "chrome/browser/ui/views/payments/test_chrome_payment_request_delegate. h"
16 #include "chrome/test/base/in_process_browser_test.h" 18 #include "chrome/test/base/in_process_browser_test.h"
17 #include "components/autofill/core/browser/field_types.h" 19 #include "components/autofill/core/browser/field_types.h"
(...skipping 14 matching lines...) Expand all
32 34
33 namespace views { 35 namespace views {
34 class Widget; 36 class Widget;
35 } 37 }
36 38
37 namespace payments { 39 namespace payments {
38 40
39 enum class DialogViewID; 41 enum class DialogViewID;
40 class PaymentRequest; 42 class PaymentRequest;
41 43
42 namespace {
43
44 ACTION_P(QuitMessageLoop, loop) { 44 ACTION_P(QuitMessageLoop, loop) {
45 loop->Quit(); 45 loop->Quit();
46 } 46 }
47 47
48 } // namespace
49
50 class PersonalDataLoadedObserverMock 48 class PersonalDataLoadedObserverMock
51 : public autofill::PersonalDataManagerObserver { 49 : public autofill::PersonalDataManagerObserver {
52 public: 50 public:
53 PersonalDataLoadedObserverMock(); 51 PersonalDataLoadedObserverMock();
54 ~PersonalDataLoadedObserverMock() override; 52 ~PersonalDataLoadedObserverMock() override;
55 53
56 MOCK_METHOD0(OnPersonalDataChanged, void()); 54 MOCK_METHOD0(OnPersonalDataChanged, void());
57 }; 55 };
58 56
59 // Base class for any interactive PaymentRequest test that will need to open 57 // Base class for any interactive PaymentRequest test that will need to open
60 // the UI and interact with it. 58 // the UI and interact with it.
61 class PaymentRequestBrowserTestBase 59 class PaymentRequestBrowserTestBase
62 : public InProcessBrowserTest, 60 : public InProcessBrowserTest,
63 public PaymentRequestDialogView::ObserverForTest, 61 public PaymentRequestDialogView::ObserverForTest,
64 public views::WidgetObserver { 62 public views::WidgetObserver {
65 protected: 63 protected:
66 // Test will open a browser window to |test_file_path| (relative to 64 // Test will open a browser window to |test_file_path| (relative to
67 // chrome/test/data/payments). 65 // chrome/test/data/payments).
68 explicit PaymentRequestBrowserTestBase(const std::string& test_file_path); 66 explicit PaymentRequestBrowserTestBase(const std::string& test_file_path);
69 ~PaymentRequestBrowserTestBase() override; 67 ~PaymentRequestBrowserTestBase() override;
70 68
71 void SetUpCommandLine(base::CommandLine* command_line) override; 69 void SetUpCommandLine(base::CommandLine* command_line) override;
72 void SetUpOnMainThread() override; 70 void SetUpOnMainThread() override;
73 71
74 // PaymentRequestDialogView::ObserverForTest 72 // PaymentRequestDialogView::ObserverForTest
75 void OnDialogOpened() override; 73 void OnDialogOpened() override;
76 void OnOrderSummaryOpened() override; 74 void OnOrderSummaryOpened() override;
77 void OnPaymentMethodOpened() override; 75 void OnPaymentMethodOpened() override;
76 void OnShippingSectionOpened() override;
78 void OnCreditCardEditorOpened() override; 77 void OnCreditCardEditorOpened() override;
78 void OnShippingAddressEditorOpened() override;
79 void OnBackNavigation() override; 79 void OnBackNavigation() override;
80 void OnContactInfoOpened() override; 80 void OnContactInfoOpened() override;
81 void OnEditorViewUpdated() override;
81 82
82 // views::WidgetObserver 83 // views::WidgetObserver
83 // Effective way to be warned of all dialog closures. 84 // Effective way to be warned of all dialog closures.
84 void OnWidgetDestroyed(views::Widget* widget) override; 85 void OnWidgetDestroyed(views::Widget* widget) override;
85 86
86 // Will call JavaScript to invoke the PaymentRequest dialog and verify that 87 // Will call JavaScript to invoke the PaymentRequest dialog and verify that
87 // it's open. 88 // it's open.
88 void InvokePaymentRequestUI(); 89 void InvokePaymentRequestUI();
89 90
90 // Will expect that all strings in |expected_strings| are present in output. 91 // Will expect that all strings in |expected_strings| are present in output.
91 void ExpectBodyContains(const std::vector<base::string16>& expected_strings); 92 void ExpectBodyContains(const std::vector<base::string16>& expected_strings);
92 93
93 // Utility functions that will click on Dialog views and wait for the 94 // Utility functions that will click on Dialog views and wait for the
94 // associated action to happen. 95 // associated action to happen.
95 void OpenOrderSummaryScreen(); 96 void OpenOrderSummaryScreen();
96 void OpenPaymentMethodScreen(); 97 void OpenPaymentMethodScreen();
98 void OpenShippingSectionScreen();
97 void OpenCreditCardEditorScreen(); 99 void OpenCreditCardEditorScreen();
100 void OpenShippingAddressEditorScreen();
98 101
99 content::WebContents* GetActiveWebContents(); 102 content::WebContents* GetActiveWebContents();
100 103
101 // Convenience method to get a list of PaymentRequest associated with 104 // Convenience method to get a list of PaymentRequest associated with
102 // |web_contents|. 105 // |web_contents|.
103 const std::vector<PaymentRequest*> GetPaymentRequests( 106 const std::vector<PaymentRequest*> GetPaymentRequests(
104 content::WebContents* web_contents); 107 content::WebContents* web_contents);
105 108
106 autofill::PersonalDataManager* GetDataManager(); 109 autofill::PersonalDataManager* GetDataManager();
107 // Adds the various models to the database, waiting until the personal data 110 // Adds the various models to the database, waiting until the personal data
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 net::EmbeddedTestServer* https_server() { return https_server_.get(); } 150 net::EmbeddedTestServer* https_server() { return https_server_.get(); }
148 151
149 PaymentRequestDialogView* dialog_view() { return delegate_->dialog_view(); } 152 PaymentRequestDialogView* dialog_view() { return delegate_->dialog_view(); }
150 153
151 // Various events that can be waited on by the DialogEventObserver. 154 // Various events that can be waited on by the DialogEventObserver.
152 enum DialogEvent : int { 155 enum DialogEvent : int {
153 DIALOG_OPENED, 156 DIALOG_OPENED,
154 DIALOG_CLOSED, 157 DIALOG_CLOSED,
155 ORDER_SUMMARY_OPENED, 158 ORDER_SUMMARY_OPENED,
156 PAYMENT_METHOD_OPENED, 159 PAYMENT_METHOD_OPENED,
160 SHIPPING_SECTION_OPENED,
157 CREDIT_CARD_EDITOR_OPENED, 161 CREDIT_CARD_EDITOR_OPENED,
162 SHIPPING_ADDRESS_EDITOR_OPENED,
158 BACK_NAVIGATION, 163 BACK_NAVIGATION,
159 CONTACT_INFO_OPENED, 164 CONTACT_INFO_OPENED,
165 EDITOR_VIEW_UPDATED,
160 }; 166 };
161 167
162 // DialogEventObserver is used to wait on specific events that may have 168 // DialogEventObserver is used to wait on specific events that may have
163 // occured before the call to Wait(), or after, in which case a RunLoop is 169 // occured before the call to Wait(), or after, in which case a RunLoop is
164 // used. 170 // used.
165 // 171 //
166 // Usage: 172 // Usage:
167 // observer_.reset(new DialogEventObserver([DialogEvent])); 173 // observer_.reset(new DialogEventObserver([DialogEvent]));
168 // 174 //
169 // Do stuff, which (a)synchronously calls observer_->Observe([DialogEvent]). 175 // Do stuff, which (a)synchronously calls observer_->Observe([DialogEvent]).
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 std::unique_ptr<net::EmbeddedTestServer> https_server_; 207 std::unique_ptr<net::EmbeddedTestServer> https_server_;
202 // Weak, owned by the PaymentRequest object. 208 // Weak, owned by the PaymentRequest object.
203 TestChromePaymentRequestDelegate* delegate_; 209 TestChromePaymentRequestDelegate* delegate_;
204 210
205 DISALLOW_COPY_AND_ASSIGN(PaymentRequestBrowserTestBase); 211 DISALLOW_COPY_AND_ASSIGN(PaymentRequestBrowserTestBase);
206 }; 212 };
207 213
208 } // namespace payments 214 } // namespace payments
209 215
210 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_BROWSERTEST_BASE_H_ 216 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_BROWSERTEST_BASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698