| 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> |
| 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 Loading... |
| 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; |
| 78 void OnCreditCardEditorOpened() override; | 76 void OnCreditCardEditorOpened() override; |
| 77 void OnShippingAddressEditorOpened() override; |
| 79 void OnBackNavigation() override; | 78 void OnBackNavigation() override; |
| 80 void OnContactInfoOpened() override; | 79 void OnContactInfoOpened() override; |
| 81 | 80 |
| 82 // views::WidgetObserver | 81 // views::WidgetObserver |
| 83 // Effective way to be warned of all dialog closures. | 82 // Effective way to be warned of all dialog closures. |
| 84 void OnWidgetDestroyed(views::Widget* widget) override; | 83 void OnWidgetDestroyed(views::Widget* widget) override; |
| 85 | 84 |
| 86 // Will call JavaScript to invoke the PaymentRequest dialog and verify that | 85 // Will call JavaScript to invoke the PaymentRequest dialog and verify that |
| 87 // it's open. | 86 // it's open. |
| 88 void InvokePaymentRequestUI(); | 87 void InvokePaymentRequestUI(); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 | 147 |
| 149 PaymentRequestDialogView* dialog_view() { return delegate_->dialog_view(); } | 148 PaymentRequestDialogView* dialog_view() { return delegate_->dialog_view(); } |
| 150 | 149 |
| 151 // Various events that can be waited on by the DialogEventObserver. | 150 // Various events that can be waited on by the DialogEventObserver. |
| 152 enum DialogEvent : int { | 151 enum DialogEvent : int { |
| 153 DIALOG_OPENED, | 152 DIALOG_OPENED, |
| 154 DIALOG_CLOSED, | 153 DIALOG_CLOSED, |
| 155 ORDER_SUMMARY_OPENED, | 154 ORDER_SUMMARY_OPENED, |
| 156 PAYMENT_METHOD_OPENED, | 155 PAYMENT_METHOD_OPENED, |
| 157 CREDIT_CARD_EDITOR_OPENED, | 156 CREDIT_CARD_EDITOR_OPENED, |
| 157 SHIPPING_ADDRESS_EDITOR_OPENED, |
| 158 BACK_NAVIGATION, | 158 BACK_NAVIGATION, |
| 159 CONTACT_INFO_OPENED, | 159 CONTACT_INFO_OPENED, |
| 160 }; | 160 }; |
| 161 | 161 |
| 162 // DialogEventObserver is used to wait on specific events that may have | 162 // 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 | 163 // occured before the call to Wait(), or after, in which case a RunLoop is |
| 164 // used. | 164 // used. |
| 165 // | 165 // |
| 166 // Usage: | 166 // Usage: |
| 167 // observer_.reset(new DialogEventObserver([DialogEvent])); | 167 // observer_.reset(new DialogEventObserver([DialogEvent])); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 std::unique_ptr<net::EmbeddedTestServer> https_server_; | 201 std::unique_ptr<net::EmbeddedTestServer> https_server_; |
| 202 // Weak, owned by the PaymentRequest object. | 202 // Weak, owned by the PaymentRequest object. |
| 203 TestChromePaymentRequestDelegate* delegate_; | 203 TestChromePaymentRequestDelegate* delegate_; |
| 204 | 204 |
| 205 DISALLOW_COPY_AND_ASSIGN(PaymentRequestBrowserTestBase); | 205 DISALLOW_COPY_AND_ASSIGN(PaymentRequestBrowserTestBase); |
| 206 }; | 206 }; |
| 207 | 207 |
| 208 } // namespace payments | 208 } // namespace payments |
| 209 | 209 |
| 210 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_BROWSERTEST_BASE_H_ | 210 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_BROWSERTEST_BASE_H_ |
| OLD | NEW |