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_INTERACTIVE_UITEST_BASE
_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_INTERACTIVE_UITEST_BASE
_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_INTERACTIVE_UITEST_BASE
_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_INTERACTIVE_UITEST_BASE
_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
13 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
14 #include "chrome/browser/ui/views/payments/payment_request_dialog_view.h" | 14 #include "chrome/browser/ui/views/payments/payment_request_dialog_view.h" |
15 #include "chrome/browser/ui/views/payments/test_chrome_payment_request_delegate.
h" | 15 #include "chrome/browser/ui/views/payments/test_chrome_payment_request_delegate.
h" |
16 #include "chrome/test/base/in_process_browser_test.h" | 16 #include "chrome/test/base/in_process_browser_test.h" |
17 #include "components/autofill/core/browser/field_types.h" | 17 #include "components/autofill/core/browser/field_types.h" |
| 18 #include "components/autofill/core/browser/personal_data_manager_observer.h" |
18 #include "components/payments/payment_request.mojom.h" | 19 #include "components/payments/payment_request.mojom.h" |
19 #include "net/test/embedded_test_server/embedded_test_server.h" | 20 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 21 #include "testing/gmock/include/gmock/gmock.h" |
20 #include "ui/views/widget/widget_observer.h" | 22 #include "ui/views/widget/widget_observer.h" |
21 | 23 |
22 namespace content { | 24 namespace content { |
23 class WebContents; | 25 class WebContents; |
24 } // namespace content | 26 } // namespace content |
25 | 27 |
26 namespace views { | 28 namespace views { |
27 class Widget; | 29 class Widget; |
28 } | 30 } |
29 | 31 |
30 namespace payments { | 32 namespace payments { |
31 | 33 |
32 enum class DialogViewID; | 34 enum class DialogViewID; |
33 class PaymentRequest; | 35 class PaymentRequest; |
34 | 36 |
| 37 namespace { |
| 38 |
| 39 ACTION_P(QuitMessageLoop, loop) { |
| 40 loop->Quit(); |
| 41 } |
| 42 |
| 43 } // namespace |
| 44 |
| 45 class PersonalDataLoadedObserverMock |
| 46 : public autofill::PersonalDataManagerObserver { |
| 47 public: |
| 48 PersonalDataLoadedObserverMock(); |
| 49 ~PersonalDataLoadedObserverMock() override; |
| 50 |
| 51 MOCK_METHOD0(OnPersonalDataChanged, void()); |
| 52 }; |
| 53 |
35 // Base class for any interactive PaymentRequest test that will need to open | 54 // Base class for any interactive PaymentRequest test that will need to open |
36 // the UI and interact with it. | 55 // the UI and interact with it. |
37 class PaymentRequestInteractiveTestBase | 56 class PaymentRequestInteractiveTestBase |
38 : public InProcessBrowserTest, | 57 : public InProcessBrowserTest, |
39 public PaymentRequestDialogView::ObserverForTest, | 58 public PaymentRequestDialogView::ObserverForTest, |
40 public views::WidgetObserver { | 59 public views::WidgetObserver { |
41 protected: | 60 protected: |
42 // Test will open a browser window to |test_file_path| (relative to | 61 // Test will open a browser window to |test_file_path| (relative to |
43 // chrome/test/data/payments). | 62 // chrome/test/data/payments). |
44 explicit PaymentRequestInteractiveTestBase(const std::string& test_file_path); | 63 explicit PaymentRequestInteractiveTestBase(const std::string& test_file_path); |
(...skipping 16 matching lines...) Expand all Loading... |
61 // Will call JavaScript to invoke the PaymentRequest dialog and verify that | 80 // Will call JavaScript to invoke the PaymentRequest dialog and verify that |
62 // it's open. | 81 // it's open. |
63 void InvokePaymentRequestUI(); | 82 void InvokePaymentRequestUI(); |
64 | 83 |
65 // Utility functions that will click on Dialog views and wait for the | 84 // Utility functions that will click on Dialog views and wait for the |
66 // associated action to happen. | 85 // associated action to happen. |
67 void OpenOrderSummaryScreen(); | 86 void OpenOrderSummaryScreen(); |
68 void OpenPaymentMethodScreen(); | 87 void OpenPaymentMethodScreen(); |
69 void OpenCreditCardEditorScreen(); | 88 void OpenCreditCardEditorScreen(); |
70 | 89 |
| 90 content::WebContents* GetActiveWebContents(); |
| 91 |
71 // Convenience method to get a list of PaymentRequest associated with | 92 // Convenience method to get a list of PaymentRequest associated with |
72 // |web_contents|. | 93 // |web_contents|. |
73 const std::vector<PaymentRequest*> GetPaymentRequests( | 94 const std::vector<PaymentRequest*> GetPaymentRequests( |
74 content::WebContents* web_contents); | 95 content::WebContents* web_contents); |
75 | 96 |
76 content::WebContents* GetActiveWebContents(); | 97 autofill::PersonalDataManager* GetDataManager(); |
77 | 98 |
78 void CreatePaymentRequestForTest( | 99 void CreatePaymentRequestForTest( |
79 content::WebContents* web_contents, | 100 content::WebContents* web_contents, |
80 mojo::InterfaceRequest<payments::mojom::PaymentRequest> request); | 101 mojo::InterfaceRequest<payments::mojom::PaymentRequest> request); |
81 | 102 |
82 // Click on a view from within the dialog and waits for an observed event | 103 // Click on a view from within the dialog and waits for an observed event |
83 // to be observed. | 104 // to be observed. |
84 void ClickOnDialogViewAndWait(DialogViewID view_id); | 105 void ClickOnDialogViewAndWait(DialogViewID view_id); |
| 106 void ClickOnDialogViewAndWait(views::View* view); |
85 | 107 |
86 // Setting the |value| in the textfield of a given |type|. | 108 // Setting the |value| in the textfield of a given |type|. |
87 void SetEditorTextfieldValue(const base::string16& value, | 109 void SetEditorTextfieldValue(const base::string16& value, |
88 autofill::ServerFieldType type); | 110 autofill::ServerFieldType type); |
89 // Setting the |value| in the combobox of a given |type|. | 111 // Setting the |value| in the combobox of a given |type|. |
90 void SetComboboxValue(const base::string16& value, | 112 void SetComboboxValue(const base::string16& value, |
91 autofill::ServerFieldType type); | 113 autofill::ServerFieldType type); |
92 | 114 |
93 // Whether the editor textfield/combobox for the given |type| is currently in | 115 // Whether the editor textfield/combobox for the given |type| is currently in |
94 // an invalid state. | 116 // an invalid state. |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 std::unique_ptr<net::EmbeddedTestServer> https_server_; | 182 std::unique_ptr<net::EmbeddedTestServer> https_server_; |
161 // Weak, owned by the PaymentRequest object. | 183 // Weak, owned by the PaymentRequest object. |
162 TestChromePaymentRequestDelegate* delegate_; | 184 TestChromePaymentRequestDelegate* delegate_; |
163 | 185 |
164 DISALLOW_COPY_AND_ASSIGN(PaymentRequestInteractiveTestBase); | 186 DISALLOW_COPY_AND_ASSIGN(PaymentRequestInteractiveTestBase); |
165 }; | 187 }; |
166 | 188 |
167 } // namespace payments | 189 } // namespace payments |
168 | 190 |
169 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_INTERACTIVE_UITEST_B
ASE_H_ | 191 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_INTERACTIVE_UITEST_B
ASE_H_ |
OLD | NEW |