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

Side by Side Diff: chrome/browser/ui/views/payments/payment_request_browsertest_base.cc

Issue 2775193004: [Payments] Have an observer for canMakePayment, for testing. (Closed)
Patch Set: addressed comments Created 3 years, 8 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 #include "chrome/browser/ui/views/payments/payment_request_browsertest_base.h" 5 #include "chrome/browser/ui/views/payments/payment_request_browsertest_base.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 registry->RemoveInterface(payments::mojom::PaymentRequest::Name_); 84 registry->RemoveInterface(payments::mojom::PaymentRequest::Name_);
85 registry->AddInterface( 85 registry->AddInterface(
86 base::Bind(&PaymentRequestBrowserTestBase::CreatePaymentRequestForTest, 86 base::Bind(&PaymentRequestBrowserTestBase::CreatePaymentRequestForTest,
87 base::Unretained(this), web_contents)); 87 base::Unretained(this), web_contents));
88 } 88 }
89 89
90 void PaymentRequestBrowserTestBase::SetIncognitoForTesting() { 90 void PaymentRequestBrowserTestBase::SetIncognitoForTesting() {
91 incognito_for_testing_ = true; 91 incognito_for_testing_ = true;
92 } 92 }
93 93
94 void PaymentRequestBrowserTestBase::OnCanMakePaymentCalled() {
95 if (event_observer_)
96 event_observer_->Observe(DialogEvent::CAN_MAKE_PAYMENT_CALLED);
97 }
98
94 void PaymentRequestBrowserTestBase::OnDialogOpened() { 99 void PaymentRequestBrowserTestBase::OnDialogOpened() {
95 if (event_observer_) 100 if (event_observer_)
96 event_observer_->Observe(DialogEvent::DIALOG_OPENED); 101 event_observer_->Observe(DialogEvent::DIALOG_OPENED);
97 } 102 }
98 103
99 void PaymentRequestBrowserTestBase::OnOrderSummaryOpened() { 104 void PaymentRequestBrowserTestBase::OnOrderSummaryOpened() {
100 if (event_observer_) 105 if (event_observer_)
101 event_observer_->Observe(DialogEvent::ORDER_SUMMARY_OPENED); 106 event_observer_->Observe(DialogEvent::ORDER_SUMMARY_OPENED);
102 } 107 }
103 108
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 content::WebContents* web_contents, 270 content::WebContents* web_contents,
266 mojo::InterfaceRequest<payments::mojom::PaymentRequest> request) { 271 mojo::InterfaceRequest<payments::mojom::PaymentRequest> request) {
267 DCHECK(web_contents); 272 DCHECK(web_contents);
268 std::unique_ptr<TestChromePaymentRequestDelegate> delegate = 273 std::unique_ptr<TestChromePaymentRequestDelegate> delegate =
269 base::MakeUnique<TestChromePaymentRequestDelegate>( 274 base::MakeUnique<TestChromePaymentRequestDelegate>(
270 web_contents, this /* observer */, this /* widget_observer */, 275 web_contents, this /* observer */, this /* widget_observer */,
271 incognito_for_testing_); 276 incognito_for_testing_);
272 delegate_ = delegate.get(); 277 delegate_ = delegate.get();
273 PaymentRequestWebContentsManager::GetOrCreateForWebContents(web_contents) 278 PaymentRequestWebContentsManager::GetOrCreateForWebContents(web_contents)
274 ->CreatePaymentRequest(web_contents, std::move(delegate), 279 ->CreatePaymentRequest(web_contents, std::move(delegate),
275 std::move(request)); 280 std::move(request), this);
276 } 281 }
277 282
278 void PaymentRequestBrowserTestBase::ClickOnDialogViewAndWait( 283 void PaymentRequestBrowserTestBase::ClickOnDialogViewAndWait(
279 DialogViewID view_id) { 284 DialogViewID view_id) {
280 views::View* view = 285 views::View* view =
281 delegate_->dialog_view()->GetViewByID(static_cast<int>(view_id)); 286 delegate_->dialog_view()->GetViewByID(static_cast<int>(view_id));
282 DCHECK(view); 287 DCHECK(view);
283 ClickOnDialogViewAndWait(view); 288 ClickOnDialogViewAndWait(view);
284 } 289 }
285 290
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 409
405 void PaymentRequestBrowserTestBase::ResetEventObserver(DialogEvent event) { 410 void PaymentRequestBrowserTestBase::ResetEventObserver(DialogEvent event) {
406 event_observer_ = base::MakeUnique<DialogEventObserver>(event); 411 event_observer_ = base::MakeUnique<DialogEventObserver>(event);
407 } 412 }
408 413
409 void PaymentRequestBrowserTestBase::WaitForObservedEvent() { 414 void PaymentRequestBrowserTestBase::WaitForObservedEvent() {
410 event_observer_->Wait(); 415 event_observer_->Wait();
411 } 416 }
412 417
413 } // namespace payments 418 } // namespace payments
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698