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

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

Issue 2656823006: [Payments] PR: Basic test for the order summary section. (Closed)
Patch Set: Rebase Created 3 years, 11 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_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 "chrome/browser/ui/views/payments/payment_request_dialog_view.h" 13 #include "chrome/browser/ui/views/payments/payment_request_dialog_view.h"
14 #include "chrome/browser/ui/views/payments/test_chrome_payment_request_delegate. h"
14 #include "chrome/test/base/in_process_browser_test.h" 15 #include "chrome/test/base/in_process_browser_test.h"
15 #include "components/payments/payment_request.mojom.h" 16 #include "components/payments/payment_request.mojom.h"
16 #include "net/test/embedded_test_server/embedded_test_server.h" 17 #include "net/test/embedded_test_server/embedded_test_server.h"
17 #include "ui/views/widget/widget_observer.h" 18 #include "ui/views/widget/widget_observer.h"
18 19
19 namespace content { 20 namespace content {
20 class WebContents; 21 class WebContents;
21 } // namespace content 22 } // namespace content
22 23
23 namespace views { 24 namespace views {
24 class Widget; 25 class Widget;
25 } 26 }
26 27
27 namespace payments { 28 namespace payments {
28 29
30 enum class DialogViewID;
29 class PaymentRequest; 31 class PaymentRequest;
30 32
31 // Base class for any interactive PaymentRequest test that will need to open 33 // Base class for any interactive PaymentRequest test that will need to open
32 // the UI and interact with it. 34 // the UI and interact with it.
33 class PaymentRequestInteractiveTestBase 35 class PaymentRequestInteractiveTestBase
34 : public InProcessBrowserTest, 36 : public InProcessBrowserTest,
35 public PaymentRequestDialogView::ObserverForTest, 37 public PaymentRequestDialogView::ObserverForTest,
36 public views::WidgetObserver { 38 public views::WidgetObserver {
37 protected: 39 protected:
38 // Test will open a browser window to |test_file_path| (relative to 40 // Test will open a browser window to |test_file_path| (relative to
39 // chrome/test/data/payments). 41 // chrome/test/data/payments).
40 explicit PaymentRequestInteractiveTestBase(const std::string& test_file_path); 42 explicit PaymentRequestInteractiveTestBase(const std::string& test_file_path);
41 ~PaymentRequestInteractiveTestBase() override; 43 ~PaymentRequestInteractiveTestBase() override;
42 44
43 void SetUpCommandLine(base::CommandLine* command_line) override; 45 void SetUpCommandLine(base::CommandLine* command_line) override;
44 void SetUpOnMainThread() override; 46 void SetUpOnMainThread() override;
45 47
46 // PaymentRequestDialogView::ObserverForTest 48 // PaymentRequestDialogView::ObserverForTest
47 void OnDialogOpened() override; 49 void OnDialogOpened() override;
50 void OnOrderSummaryOpened() override;
48 51
49 // views::WidgetObserver 52 // views::WidgetObserver
50 // Effective way to be warned of all dialog closures. 53 // Effective way to be warned of all dialog closures.
51 void OnWidgetDestroyed(views::Widget* widget) override; 54 void OnWidgetDestroyed(views::Widget* widget) override;
52 55
53 // Will call JavaScript to invoke the PaymentRequest dialog and verify that 56 // Will call JavaScript to invoke the PaymentRequest dialog and verify that
54 // it's open. 57 // it's open.
55 void InvokePaymentRequestUI(); 58 void InvokePaymentRequestUI();
56 59
60 void OpenOrderSummaryScreen();
61
57 // Convenience method to get a list of PaymentRequest associated with 62 // Convenience method to get a list of PaymentRequest associated with
58 // |web_contents|. 63 // |web_contents|.
59 const std::vector<PaymentRequest*> GetPaymentRequests( 64 const std::vector<PaymentRequest*> GetPaymentRequests(
60 content::WebContents* web_contents); 65 content::WebContents* web_contents);
61 66
62 content::WebContents* GetActiveWebContents(); 67 content::WebContents* GetActiveWebContents();
63 68
64 void CreatePaymentRequestForTest( 69 void CreatePaymentRequestForTest(
65 content::WebContents* web_contents, 70 content::WebContents* web_contents,
66 mojo::InterfaceRequest<payments::mojom::PaymentRequest> request); 71 mojo::InterfaceRequest<payments::mojom::PaymentRequest> request);
67 72
73 // Click on a view from within the dialog.
74 void ClickOnDialogView(DialogViewID view_id);
75
76 // Returns the text of the StyledLabel with the specific |view_id| that is a
77 // child of the Payment Request dialog view.
78 const base::string16& GetStyledLabelText(DialogViewID view_id);
79
68 net::EmbeddedTestServer* https_server() { return https_server_.get(); } 80 net::EmbeddedTestServer* https_server() { return https_server_.get(); }
69 81
82 PaymentRequestDialogView* dialog_view() { return delegate_->dialog_view(); }
83
70 // Various events that can be waited on by the DialogEventObserver. 84 // Various events that can be waited on by the DialogEventObserver.
71 enum DialogEvent { 85 enum DialogEvent {
72 DIALOG_OPENED, 86 DIALOG_OPENED,
73 DIALOG_CLOSED, 87 DIALOG_CLOSED,
88 ORDER_SUMMARY_OPENED,
74 }; 89 };
75 90
76 // DialogEventObserver is used to wait on specific events that may have 91 // DialogEventObserver is used to wait on specific events that may have
77 // occured before the call to Wait(), or after, in which case a RunLoop is 92 // occured before the call to Wait(), or after, in which case a RunLoop is
78 // used. 93 // used.
79 // 94 //
80 // Usage: 95 // Usage:
81 // observer_.reset(new DialogEventObserver([DialogEvent])); 96 // observer_.reset(new DialogEventObserver([DialogEvent]));
82 // 97 //
83 // Do stuff, which (a)synchronously calls observer_->Observe([DialogEvent]). 98 // Do stuff, which (a)synchronously calls observer_->Observe([DialogEvent]).
(...skipping 22 matching lines...) Expand all
106 121
107 // Resets the event observer for a given |event|. 122 // Resets the event observer for a given |event|.
108 void ResetEventObserver(DialogEvent event); 123 void ResetEventObserver(DialogEvent event);
109 // Wait for the event passed to ResetEventObserver() to occur. 124 // Wait for the event passed to ResetEventObserver() to occur.
110 void WaitForObservedEvent(); 125 void WaitForObservedEvent();
111 126
112 private: 127 private:
113 std::unique_ptr<DialogEventObserver> event_observer_; 128 std::unique_ptr<DialogEventObserver> event_observer_;
114 const std::string test_file_path_; 129 const std::string test_file_path_;
115 std::unique_ptr<net::EmbeddedTestServer> https_server_; 130 std::unique_ptr<net::EmbeddedTestServer> https_server_;
131 // Weak, owned by the PaymentRequest object.
132 TestChromePaymentRequestDelegate* delegate_;
116 133
117 DISALLOW_COPY_AND_ASSIGN(PaymentRequestInteractiveTestBase); 134 DISALLOW_COPY_AND_ASSIGN(PaymentRequestInteractiveTestBase);
118 }; 135 };
119 136
120 } // namespace payments 137 } // namespace payments
121 138
122 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_INTERACTIVE_UITEST_B ASE_H_ 139 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_PAYMENT_REQUEST_INTERACTIVE_UITEST_B ASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698