| 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" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 // chrome/test/data/payments). | 41 // chrome/test/data/payments). |
| 42 explicit PaymentRequestInteractiveTestBase(const std::string& test_file_path); | 42 explicit PaymentRequestInteractiveTestBase(const std::string& test_file_path); |
| 43 ~PaymentRequestInteractiveTestBase() override; | 43 ~PaymentRequestInteractiveTestBase() override; |
| 44 | 44 |
| 45 void SetUpCommandLine(base::CommandLine* command_line) override; | 45 void SetUpCommandLine(base::CommandLine* command_line) override; |
| 46 void SetUpOnMainThread() override; | 46 void SetUpOnMainThread() override; |
| 47 | 47 |
| 48 // PaymentRequestDialogView::ObserverForTest | 48 // PaymentRequestDialogView::ObserverForTest |
| 49 void OnDialogOpened() override; | 49 void OnDialogOpened() override; |
| 50 void OnOrderSummaryOpened() override; | 50 void OnOrderSummaryOpened() override; |
| 51 void OnPaymentMethodOpened() override; |
| 52 void OnCreditCardEditorOpened() override; |
| 53 void OnBackNavigation() override; |
| 51 | 54 |
| 52 // views::WidgetObserver | 55 // views::WidgetObserver |
| 53 // Effective way to be warned of all dialog closures. | 56 // Effective way to be warned of all dialog closures. |
| 54 void OnWidgetDestroyed(views::Widget* widget) override; | 57 void OnWidgetDestroyed(views::Widget* widget) override; |
| 55 | 58 |
| 56 // Will call JavaScript to invoke the PaymentRequest dialog and verify that | 59 // Will call JavaScript to invoke the PaymentRequest dialog and verify that |
| 57 // it's open. | 60 // it's open. |
| 58 void InvokePaymentRequestUI(); | 61 void InvokePaymentRequestUI(); |
| 59 | 62 |
| 63 // Utility functions that will click on Dialog views and wait for the |
| 64 // associated action to happen. |
| 60 void OpenOrderSummaryScreen(); | 65 void OpenOrderSummaryScreen(); |
| 66 void OpenPaymentMethodScreen(); |
| 67 void OpenCreditCardEditorScreen(); |
| 61 | 68 |
| 62 // Convenience method to get a list of PaymentRequest associated with | 69 // Convenience method to get a list of PaymentRequest associated with |
| 63 // |web_contents|. | 70 // |web_contents|. |
| 64 const std::vector<PaymentRequest*> GetPaymentRequests( | 71 const std::vector<PaymentRequest*> GetPaymentRequests( |
| 65 content::WebContents* web_contents); | 72 content::WebContents* web_contents); |
| 66 | 73 |
| 67 content::WebContents* GetActiveWebContents(); | 74 content::WebContents* GetActiveWebContents(); |
| 68 | 75 |
| 69 void CreatePaymentRequestForTest( | 76 void CreatePaymentRequestForTest( |
| 70 content::WebContents* web_contents, | 77 content::WebContents* web_contents, |
| 71 mojo::InterfaceRequest<payments::mojom::PaymentRequest> request); | 78 mojo::InterfaceRequest<payments::mojom::PaymentRequest> request); |
| 72 | 79 |
| 73 // Click on a view from within the dialog. | 80 // Click on a view from within the dialog and waits for an observed event |
| 74 void ClickOnDialogView(DialogViewID view_id); | 81 // to be observed. |
| 82 void ClickOnDialogViewAndWait(DialogViewID view_id); |
| 83 |
| 84 // Sets proper animation delegates and waits for animation to finish. |
| 85 void WaitForAnimation(); |
| 75 | 86 |
| 76 // Returns the text of the StyledLabel with the specific |view_id| that is a | 87 // Returns the text of the StyledLabel with the specific |view_id| that is a |
| 77 // child of the Payment Request dialog view. | 88 // child of the Payment Request dialog view. |
| 78 const base::string16& GetStyledLabelText(DialogViewID view_id); | 89 const base::string16& GetStyledLabelText(DialogViewID view_id); |
| 79 | 90 |
| 80 net::EmbeddedTestServer* https_server() { return https_server_.get(); } | 91 net::EmbeddedTestServer* https_server() { return https_server_.get(); } |
| 81 | 92 |
| 82 PaymentRequestDialogView* dialog_view() { return delegate_->dialog_view(); } | 93 PaymentRequestDialogView* dialog_view() { return delegate_->dialog_view(); } |
| 83 | 94 |
| 84 // Various events that can be waited on by the DialogEventObserver. | 95 // Various events that can be waited on by the DialogEventObserver. |
| 85 enum DialogEvent { | 96 enum DialogEvent : int { |
| 86 DIALOG_OPENED, | 97 DIALOG_OPENED, |
| 87 DIALOG_CLOSED, | 98 DIALOG_CLOSED, |
| 88 ORDER_SUMMARY_OPENED, | 99 ORDER_SUMMARY_OPENED, |
| 100 PAYMENT_METHOD_OPENED, |
| 101 CREDIT_CARD_EDITOR_OPENED, |
| 102 BACK_NAVIGATION, |
| 89 }; | 103 }; |
| 90 | 104 |
| 91 // DialogEventObserver is used to wait on specific events that may have | 105 // DialogEventObserver is used to wait on specific events that may have |
| 92 // occured before the call to Wait(), or after, in which case a RunLoop is | 106 // occured before the call to Wait(), or after, in which case a RunLoop is |
| 93 // used. | 107 // used. |
| 94 // | 108 // |
| 95 // Usage: | 109 // Usage: |
| 96 // observer_.reset(new DialogEventObserver([DialogEvent])); | 110 // observer_.reset(new DialogEventObserver([DialogEvent])); |
| 97 // | 111 // |
| 98 // Do stuff, which (a)synchronously calls observer_->Observe([DialogEvent]). | 112 // Do stuff, which (a)synchronously calls observer_->Observe([DialogEvent]). |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 std::unique_ptr<net::EmbeddedTestServer> https_server_; | 144 std::unique_ptr<net::EmbeddedTestServer> https_server_; |
| 131 // Weak, owned by the PaymentRequest object. | 145 // Weak, owned by the PaymentRequest object. |
| 132 TestChromePaymentRequestDelegate* delegate_; | 146 TestChromePaymentRequestDelegate* delegate_; |
| 133 | 147 |
| 134 DISALLOW_COPY_AND_ASSIGN(PaymentRequestInteractiveTestBase); | 148 DISALLOW_COPY_AND_ASSIGN(PaymentRequestInteractiveTestBase); |
| 135 }; | 149 }; |
| 136 | 150 |
| 137 } // namespace payments | 151 } // namespace payments |
| 138 | 152 |
| 139 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_INTERACTIVE_UITEST_B
ASE_H_ | 153 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_INTERACTIVE_UITEST_B
ASE_H_ |
| OLD | NEW |