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

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

Issue 2768093006: [Payments] Desktop: Error message in the dialog. (Closed)
Patch Set: Test 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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 void PaymentRequestBrowserTestBase::OnContactInfoOpened() { 134 void PaymentRequestBrowserTestBase::OnContactInfoOpened() {
135 if (event_observer_) 135 if (event_observer_)
136 event_observer_->Observe(DialogEvent::CONTACT_INFO_OPENED); 136 event_observer_->Observe(DialogEvent::CONTACT_INFO_OPENED);
137 } 137 }
138 138
139 void PaymentRequestBrowserTestBase::OnEditorViewUpdated() { 139 void PaymentRequestBrowserTestBase::OnEditorViewUpdated() {
140 if (event_observer_) 140 if (event_observer_)
141 event_observer_->Observe(DialogEvent::EDITOR_VIEW_UPDATED); 141 event_observer_->Observe(DialogEvent::EDITOR_VIEW_UPDATED);
142 } 142 }
143 143
144 void PaymentRequestBrowserTestBase::OnErrorMessageShown() {
145 if (event_observer_)
146 event_observer_->Observe(DialogEvent::ERROR_MESSAGE_SHOWN);
147 }
148
144 void PaymentRequestBrowserTestBase::OnWidgetDestroyed(views::Widget* widget) { 149 void PaymentRequestBrowserTestBase::OnWidgetDestroyed(views::Widget* widget) {
145 if (event_observer_) 150 if (event_observer_)
146 event_observer_->Observe(DialogEvent::DIALOG_CLOSED); 151 event_observer_->Observe(DialogEvent::DIALOG_CLOSED);
147 } 152 }
148 153
149 void PaymentRequestBrowserTestBase::InvokePaymentRequestUI() { 154 void PaymentRequestBrowserTestBase::InvokePaymentRequestUI() {
150 ResetEventObserver(DialogEvent::DIALOG_OPENED); 155 ResetEventObserver(DialogEvent::DIALOG_OPENED);
151 156
152 content::WebContents* web_contents = GetActiveWebContents(); 157 content::WebContents* web_contents = GetActiveWebContents();
153 const std::string click_buy_button_js = 158 const std::string click_buy_button_js =
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 base::MakeUnique<TestChromePaymentRequestDelegate>( 279 base::MakeUnique<TestChromePaymentRequestDelegate>(
275 web_contents, this /* observer */, this /* widget_observer */, 280 web_contents, this /* observer */, this /* widget_observer */,
276 incognito_for_testing_); 281 incognito_for_testing_);
277 delegate_ = delegate.get(); 282 delegate_ = delegate.get();
278 PaymentRequestWebContentsManager::GetOrCreateForWebContents(web_contents) 283 PaymentRequestWebContentsManager::GetOrCreateForWebContents(web_contents)
279 ->CreatePaymentRequest(web_contents, std::move(delegate), 284 ->CreatePaymentRequest(web_contents, std::move(delegate),
280 std::move(request), this); 285 std::move(request), this);
281 } 286 }
282 287
283 void PaymentRequestBrowserTestBase::ClickOnDialogViewAndWait( 288 void PaymentRequestBrowserTestBase::ClickOnDialogViewAndWait(
284 DialogViewID view_id) { 289 DialogViewID view_id,
290 bool wait_for_animation) {
285 views::View* view = 291 views::View* view =
286 delegate_->dialog_view()->GetViewByID(static_cast<int>(view_id)); 292 delegate_->dialog_view()->GetViewByID(static_cast<int>(view_id));
287 DCHECK(view); 293 DCHECK(view);
288 ClickOnDialogViewAndWait(view); 294 ClickOnDialogViewAndWait(view, wait_for_animation);
289 } 295 }
290 296
291 void PaymentRequestBrowserTestBase::ClickOnDialogViewAndWait( 297 void PaymentRequestBrowserTestBase::ClickOnDialogViewAndWait(
292 views::View* view) { 298 views::View* view,
299 bool wait_for_animation) {
293 DCHECK(view); 300 DCHECK(view);
294 ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), 301 ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(),
295 ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, 302 ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON,
296 ui::EF_LEFT_MOUSE_BUTTON); 303 ui::EF_LEFT_MOUSE_BUTTON);
297 view->OnMousePressed(pressed); 304 view->OnMousePressed(pressed);
298 ui::MouseEvent released_event = ui::MouseEvent( 305 ui::MouseEvent released_event = ui::MouseEvent(
299 ui::ET_MOUSE_RELEASED, gfx::Point(), gfx::Point(), ui::EventTimeForNow(), 306 ui::ET_MOUSE_RELEASED, gfx::Point(), gfx::Point(), ui::EventTimeForNow(),
300 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); 307 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON);
301 view->OnMouseReleased(released_event); 308 view->OnMouseReleased(released_event);
302 309
303 WaitForAnimation(); 310 if (wait_for_animation)
311 WaitForAnimation();
304 312
305 WaitForObservedEvent(); 313 WaitForObservedEvent();
306 } 314 }
307 315
308 void PaymentRequestBrowserTestBase::SetEditorTextfieldValue( 316 void PaymentRequestBrowserTestBase::SetEditorTextfieldValue(
309 const base::string16& value, 317 const base::string16& value,
310 autofill::ServerFieldType type) { 318 autofill::ServerFieldType type) {
311 ValidatingTextfield* textfield = static_cast<ValidatingTextfield*>( 319 ValidatingTextfield* textfield = static_cast<ValidatingTextfield*>(
312 delegate_->dialog_view()->GetViewByID(static_cast<int>(type))); 320 delegate_->dialog_view()->GetViewByID(static_cast<int>(type)));
313 DCHECK(textfield); 321 DCHECK(textfield);
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 417
410 void PaymentRequestBrowserTestBase::ResetEventObserver(DialogEvent event) { 418 void PaymentRequestBrowserTestBase::ResetEventObserver(DialogEvent event) {
411 event_observer_ = base::MakeUnique<DialogEventObserver>(event); 419 event_observer_ = base::MakeUnique<DialogEventObserver>(event);
412 } 420 }
413 421
414 void PaymentRequestBrowserTestBase::WaitForObservedEvent() { 422 void PaymentRequestBrowserTestBase::WaitForObservedEvent() {
415 event_observer_->Wait(); 423 event_observer_->Wait();
416 } 424 }
417 425
418 } // namespace payments 426 } // namespace payments
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698