| OLD | NEW |
| 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> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
| 15 #include "base/strings/string16.h" | 15 #include "base/strings/string16.h" |
| 16 #include "chrome/browser/ui/views/payments/payment_request_dialog_view.h" | 16 #include "chrome/browser/ui/views/payments/payment_request_dialog_view.h" |
| 17 #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" |
| 18 #include "chrome/test/base/in_process_browser_test.h" | 18 #include "chrome/test/base/in_process_browser_test.h" |
| 19 #include "components/autofill/core/browser/field_types.h" | 19 #include "components/autofill/core/browser/field_types.h" |
| 20 #include "components/autofill/core/browser/personal_data_manager_observer.h" | 20 #include "components/autofill/core/browser/personal_data_manager_observer.h" |
| 21 #include "components/payments/content/payment_request.h" |
| 21 #include "components/payments/content/payment_request.mojom.h" | 22 #include "components/payments/content/payment_request.mojom.h" |
| 22 #include "net/test/embedded_test_server/embedded_test_server.h" | 23 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 23 #include "testing/gmock/include/gmock/gmock.h" | 24 #include "testing/gmock/include/gmock/gmock.h" |
| 24 #include "ui/views/widget/widget_observer.h" | 25 #include "ui/views/widget/widget_observer.h" |
| 25 | 26 |
| 26 namespace autofill { | 27 namespace autofill { |
| 27 class AutofillProfile; | 28 class AutofillProfile; |
| 28 class CreditCard; | 29 class CreditCard; |
| 29 } | 30 } |
| 30 | 31 |
| 31 namespace content { | 32 namespace content { |
| 32 class WebContents; | 33 class WebContents; |
| 33 } // namespace content | 34 } // namespace content |
| 34 | 35 |
| 35 namespace views { | 36 namespace views { |
| 36 class Widget; | 37 class Widget; |
| 37 } | 38 } |
| 38 | 39 |
| 39 namespace payments { | 40 namespace payments { |
| 40 | 41 |
| 41 enum class DialogViewID; | 42 enum class DialogViewID; |
| 42 class PaymentRequest; | |
| 43 | 43 |
| 44 ACTION_P(QuitMessageLoop, loop) { | 44 ACTION_P(QuitMessageLoop, loop) { |
| 45 loop->Quit(); | 45 loop->Quit(); |
| 46 } | 46 } |
| 47 | 47 |
| 48 class PersonalDataLoadedObserverMock | 48 class PersonalDataLoadedObserverMock |
| 49 : public autofill::PersonalDataManagerObserver { | 49 : public autofill::PersonalDataManagerObserver { |
| 50 public: | 50 public: |
| 51 PersonalDataLoadedObserverMock(); | 51 PersonalDataLoadedObserverMock(); |
| 52 ~PersonalDataLoadedObserverMock() override; | 52 ~PersonalDataLoadedObserverMock() override; |
| 53 | 53 |
| 54 MOCK_METHOD0(OnPersonalDataChanged, void()); | 54 MOCK_METHOD0(OnPersonalDataChanged, void()); |
| 55 }; | 55 }; |
| 56 | 56 |
| 57 // 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 |
| 58 // the UI and interact with it. | 58 // the UI and interact with it. |
| 59 class PaymentRequestBrowserTestBase | 59 class PaymentRequestBrowserTestBase |
| 60 : public InProcessBrowserTest, | 60 : public InProcessBrowserTest, |
| 61 public PaymentRequest::ObserverForTest, |
| 61 public PaymentRequestDialogView::ObserverForTest, | 62 public PaymentRequestDialogView::ObserverForTest, |
| 62 public views::WidgetObserver { | 63 public views::WidgetObserver { |
| 63 protected: | 64 protected: |
| 64 // Test will open a browser window to |test_file_path| (relative to | 65 // Test will open a browser window to |test_file_path| (relative to |
| 65 // chrome/test/data/payments). | 66 // chrome/test/data/payments). |
| 66 explicit PaymentRequestBrowserTestBase(const std::string& test_file_path); | 67 explicit PaymentRequestBrowserTestBase(const std::string& test_file_path); |
| 67 ~PaymentRequestBrowserTestBase() override; | 68 ~PaymentRequestBrowserTestBase() override; |
| 68 | 69 |
| 69 void SetUpCommandLine(base::CommandLine* command_line) override; | 70 void SetUpCommandLine(base::CommandLine* command_line) override; |
| 70 void SetUpOnMainThread() override; | 71 void SetUpOnMainThread() override; |
| 71 | 72 |
| 72 void SetIncognitoForTesting(); | 73 void SetIncognitoForTesting(); |
| 73 | 74 |
| 74 // PaymentRequestDialogView::ObserverForTest | 75 // PaymentRequest::ObserverForTest: |
| 76 void OnCanMakePaymentCalled() override; |
| 77 |
| 78 // PaymentRequestDialogView::ObserverForTest: |
| 75 void OnDialogOpened() override; | 79 void OnDialogOpened() override; |
| 76 void OnOrderSummaryOpened() override; | 80 void OnOrderSummaryOpened() override; |
| 77 void OnPaymentMethodOpened() override; | 81 void OnPaymentMethodOpened() override; |
| 78 void OnShippingSectionOpened() override; | 82 void OnShippingSectionOpened() override; |
| 79 void OnCreditCardEditorOpened() override; | 83 void OnCreditCardEditorOpened() override; |
| 80 void OnShippingAddressEditorOpened() override; | 84 void OnShippingAddressEditorOpened() override; |
| 81 void OnBackNavigation() override; | 85 void OnBackNavigation() override; |
| 82 void OnContactInfoOpened() override; | 86 void OnContactInfoOpened() override; |
| 83 void OnEditorViewUpdated() override; | 87 void OnEditorViewUpdated() override; |
| 84 | 88 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 DIALOG_OPENED, | 162 DIALOG_OPENED, |
| 159 DIALOG_CLOSED, | 163 DIALOG_CLOSED, |
| 160 ORDER_SUMMARY_OPENED, | 164 ORDER_SUMMARY_OPENED, |
| 161 PAYMENT_METHOD_OPENED, | 165 PAYMENT_METHOD_OPENED, |
| 162 SHIPPING_SECTION_OPENED, | 166 SHIPPING_SECTION_OPENED, |
| 163 CREDIT_CARD_EDITOR_OPENED, | 167 CREDIT_CARD_EDITOR_OPENED, |
| 164 SHIPPING_ADDRESS_EDITOR_OPENED, | 168 SHIPPING_ADDRESS_EDITOR_OPENED, |
| 165 BACK_NAVIGATION, | 169 BACK_NAVIGATION, |
| 166 CONTACT_INFO_OPENED, | 170 CONTACT_INFO_OPENED, |
| 167 EDITOR_VIEW_UPDATED, | 171 EDITOR_VIEW_UPDATED, |
| 172 CAN_MAKE_PAYMENT_CALLED, |
| 168 }; | 173 }; |
| 169 | 174 |
| 170 // DialogEventObserver is used to wait on specific events that may have | 175 // DialogEventObserver is used to wait on specific events that may have |
| 171 // occured before the call to Wait(), or after, in which case a RunLoop is | 176 // occured before the call to Wait(), or after, in which case a RunLoop is |
| 172 // used. | 177 // used. |
| 173 // | 178 // |
| 174 // Usage: | 179 // Usage: |
| 175 // observer_.reset(new DialogEventObserver([DialogEvent])); | 180 // observer_.reset(new DialogEventObserver([DialogEvent])); |
| 176 // | 181 // |
| 177 // Do stuff, which (a)synchronously calls observer_->Observe([DialogEvent]). | 182 // Do stuff, which (a)synchronously calls observer_->Observe([DialogEvent]). |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 // Weak, owned by the PaymentRequest object. | 215 // Weak, owned by the PaymentRequest object. |
| 211 TestChromePaymentRequestDelegate* delegate_; | 216 TestChromePaymentRequestDelegate* delegate_; |
| 212 bool incognito_for_testing_; | 217 bool incognito_for_testing_; |
| 213 | 218 |
| 214 DISALLOW_COPY_AND_ASSIGN(PaymentRequestBrowserTestBase); | 219 DISALLOW_COPY_AND_ASSIGN(PaymentRequestBrowserTestBase); |
| 215 }; | 220 }; |
| 216 | 221 |
| 217 } // namespace payments | 222 } // namespace payments |
| 218 | 223 |
| 219 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_BROWSERTEST_BASE_H_ | 224 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_BROWSERTEST_BASE_H_ |
| OLD | NEW |