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 #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 <algorithm> | 7 #include <algorithm> |
8 #include <iostream> | 8 #include <iostream> |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
11 #include <utility> | 11 #include <utility> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/bind.h" | 14 #include "base/bind.h" |
15 #include "base/bind_helpers.h" | 15 #include "base/bind_helpers.h" |
16 #include "base/command_line.h" | 16 #include "base/command_line.h" |
17 #include "base/memory/ptr_util.h" | 17 #include "base/memory/ptr_util.h" |
18 #include "base/run_loop.h" | 18 #include "base/run_loop.h" |
19 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
20 #include "chrome/browser/autofill/personal_data_manager_factory.h" | 20 #include "chrome/browser/autofill/personal_data_manager_factory.h" |
21 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
22 #include "chrome/browser/ui/browser.h" | 22 #include "chrome/browser/ui/browser.h" |
23 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 23 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 24 #include "chrome/browser/ui/views/payments/editor_view_controller.h" |
24 #include "chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h" | 25 #include "chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h" |
25 #include "chrome/browser/ui/views/payments/validating_combobox.h" | 26 #include "chrome/browser/ui/views/payments/validating_combobox.h" |
26 #include "chrome/browser/ui/views/payments/validating_textfield.h" | 27 #include "chrome/browser/ui/views/payments/validating_textfield.h" |
27 #include "chrome/browser/ui/views/payments/view_stack.h" | 28 #include "chrome/browser/ui/views/payments/view_stack.h" |
28 #include "chrome/test/base/ui_test_utils.h" | 29 #include "chrome/test/base/ui_test_utils.h" |
29 #include "components/autofill/core/browser/address_combobox_model.h" | 30 #include "components/autofill/core/browser/address_combobox_model.h" |
30 #include "components/autofill/core/browser/autofill_profile.h" | 31 #include "components/autofill/core/browser/autofill_profile.h" |
31 #include "components/autofill/core/browser/credit_card.h" | 32 #include "components/autofill/core/browser/credit_card.h" |
32 #include "components/autofill/core/browser/personal_data_manager.h" | 33 #include "components/autofill/core/browser/personal_data_manager.h" |
33 #include "components/payments/content/payment_request.h" | 34 #include "components/payments/content/payment_request.h" |
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
544 void PaymentRequestBrowserTestBase::PayWithCreditCardAndWait( | 545 void PaymentRequestBrowserTestBase::PayWithCreditCardAndWait( |
545 const base::string16& cvc) { | 546 const base::string16& cvc) { |
546 OpenCVCPromptWithCVC(cvc); | 547 OpenCVCPromptWithCVC(cvc); |
547 | 548 |
548 ResetEventObserver(DialogEvent::DIALOG_CLOSED); | 549 ResetEventObserver(DialogEvent::DIALOG_CLOSED); |
549 ClickOnDialogViewAndWait(DialogViewID::CVC_PROMPT_CONFIRM_BUTTON); | 550 ClickOnDialogViewAndWait(DialogViewID::CVC_PROMPT_CONFIRM_BUTTON); |
550 } | 551 } |
551 | 552 |
552 base::string16 PaymentRequestBrowserTestBase::GetEditorTextfieldValue( | 553 base::string16 PaymentRequestBrowserTestBase::GetEditorTextfieldValue( |
553 autofill::ServerFieldType type) { | 554 autofill::ServerFieldType type) { |
554 ValidatingTextfield* textfield = static_cast<ValidatingTextfield*>( | 555 ValidatingTextfield* textfield = |
555 delegate_->dialog_view()->GetViewByID(static_cast<int>(type))); | 556 static_cast<ValidatingTextfield*>(delegate_->dialog_view()->GetViewByID( |
| 557 EditorViewController::GetInputFieldViewId(type))); |
556 DCHECK(textfield); | 558 DCHECK(textfield); |
557 return textfield->text(); | 559 return textfield->text(); |
558 } | 560 } |
559 | 561 |
560 void PaymentRequestBrowserTestBase::SetEditorTextfieldValue( | 562 void PaymentRequestBrowserTestBase::SetEditorTextfieldValue( |
561 const base::string16& value, | 563 const base::string16& value, |
562 autofill::ServerFieldType type) { | 564 autofill::ServerFieldType type) { |
563 ValidatingTextfield* textfield = static_cast<ValidatingTextfield*>( | 565 ValidatingTextfield* textfield = |
564 delegate_->dialog_view()->GetViewByID(static_cast<int>(type))); | 566 static_cast<ValidatingTextfield*>(delegate_->dialog_view()->GetViewByID( |
| 567 EditorViewController::GetInputFieldViewId(type))); |
565 DCHECK(textfield); | 568 DCHECK(textfield); |
566 textfield->SetText(value); | 569 textfield->SetText(value); |
567 textfield->OnContentsChanged(); | 570 textfield->OnContentsChanged(); |
568 textfield->OnBlur(); | 571 textfield->OnBlur(); |
569 } | 572 } |
570 | 573 |
571 base::string16 PaymentRequestBrowserTestBase::GetComboboxValue( | 574 base::string16 PaymentRequestBrowserTestBase::GetComboboxValue( |
572 autofill::ServerFieldType type) { | 575 autofill::ServerFieldType type) { |
573 ValidatingCombobox* combobox = static_cast<ValidatingCombobox*>( | 576 ValidatingCombobox* combobox = |
574 delegate_->dialog_view()->GetViewByID(static_cast<int>(type))); | 577 static_cast<ValidatingCombobox*>(delegate_->dialog_view()->GetViewByID( |
| 578 EditorViewController::GetInputFieldViewId(type))); |
575 DCHECK(combobox); | 579 DCHECK(combobox); |
576 return combobox->model()->GetItemAt(combobox->selected_index()); | 580 return combobox->model()->GetItemAt(combobox->selected_index()); |
577 } | 581 } |
578 | 582 |
579 void PaymentRequestBrowserTestBase::SetComboboxValue( | 583 void PaymentRequestBrowserTestBase::SetComboboxValue( |
580 const base::string16& value, | 584 const base::string16& value, |
581 autofill::ServerFieldType type) { | 585 autofill::ServerFieldType type) { |
582 ValidatingCombobox* combobox = static_cast<ValidatingCombobox*>( | 586 ValidatingCombobox* combobox = |
583 delegate_->dialog_view()->GetViewByID(static_cast<int>(type))); | 587 static_cast<ValidatingCombobox*>(delegate_->dialog_view()->GetViewByID( |
| 588 EditorViewController::GetInputFieldViewId(type))); |
584 DCHECK(combobox); | 589 DCHECK(combobox); |
585 combobox->SelectValue(value); | 590 combobox->SelectValue(value); |
586 combobox->OnContentsChanged(); | 591 combobox->OnContentsChanged(); |
587 combobox->OnBlur(); | 592 combobox->OnBlur(); |
588 } | 593 } |
589 | 594 |
590 void PaymentRequestBrowserTestBase::SelectBillingAddress( | 595 void PaymentRequestBrowserTestBase::SelectBillingAddress( |
591 const std::string& billing_address_id) { | 596 const std::string& billing_address_id) { |
592 views::Combobox* address_combobox(static_cast<views::Combobox*>( | 597 views::Combobox* address_combobox( |
593 dialog_view()->GetViewByID(static_cast<int>(kBillingAddressType)))); | 598 static_cast<views::Combobox*>(dialog_view()->GetViewByID( |
| 599 EditorViewController::GetInputFieldViewId(kBillingAddressType)))); |
594 ASSERT_NE(address_combobox, nullptr); | 600 ASSERT_NE(address_combobox, nullptr); |
595 autofill::AddressComboboxModel* address_combobox_model( | 601 autofill::AddressComboboxModel* address_combobox_model( |
596 static_cast<autofill::AddressComboboxModel*>(address_combobox->model())); | 602 static_cast<autofill::AddressComboboxModel*>(address_combobox->model())); |
597 address_combobox->SetSelectedRow( | 603 address_combobox->SetSelectedRow( |
598 address_combobox_model->GetIndexOfIdentifier(billing_address_id)); | 604 address_combobox_model->GetIndexOfIdentifier(billing_address_id)); |
599 address_combobox->OnBlur(); | 605 address_combobox->OnBlur(); |
600 } | 606 } |
601 | 607 |
602 bool PaymentRequestBrowserTestBase::IsEditorTextfieldInvalid( | 608 bool PaymentRequestBrowserTestBase::IsEditorTextfieldInvalid( |
603 autofill::ServerFieldType type) { | 609 autofill::ServerFieldType type) { |
604 ValidatingTextfield* textfield = static_cast<ValidatingTextfield*>( | 610 ValidatingTextfield* textfield = |
605 delegate_->dialog_view()->GetViewByID(static_cast<int>(type))); | 611 static_cast<ValidatingTextfield*>(delegate_->dialog_view()->GetViewByID( |
| 612 EditorViewController::GetInputFieldViewId(type))); |
606 DCHECK(textfield); | 613 DCHECK(textfield); |
607 return textfield->invalid(); | 614 return textfield->invalid(); |
608 } | 615 } |
609 | 616 |
610 bool PaymentRequestBrowserTestBase::IsEditorComboboxInvalid( | 617 bool PaymentRequestBrowserTestBase::IsEditorComboboxInvalid( |
611 autofill::ServerFieldType type) { | 618 autofill::ServerFieldType type) { |
612 ValidatingCombobox* combobox = static_cast<ValidatingCombobox*>( | 619 ValidatingCombobox* combobox = |
613 delegate_->dialog_view()->GetViewByID(static_cast<int>(type))); | 620 static_cast<ValidatingCombobox*>(delegate_->dialog_view()->GetViewByID( |
| 621 EditorViewController::GetInputFieldViewId(type))); |
614 DCHECK(combobox); | 622 DCHECK(combobox); |
615 return combobox->invalid(); | 623 return combobox->invalid(); |
616 } | 624 } |
617 | 625 |
618 bool PaymentRequestBrowserTestBase::IsPayButtonEnabled() { | 626 bool PaymentRequestBrowserTestBase::IsPayButtonEnabled() { |
619 views::Button* button = | 627 views::Button* button = |
620 static_cast<views::Button*>(delegate_->dialog_view()->GetViewByID( | 628 static_cast<views::Button*>(delegate_->dialog_view()->GetViewByID( |
621 static_cast<int>(DialogViewID::PAY_BUTTON))); | 629 static_cast<int>(DialogViewID::PAY_BUTTON))); |
622 DCHECK(button); | 630 DCHECK(button); |
623 return button->enabled(); | 631 return button->enabled(); |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
762 break; | 770 break; |
763 case DialogEvent::NOT_SUPPORTED_ERROR: | 771 case DialogEvent::NOT_SUPPORTED_ERROR: |
764 out << "NOT_SUPPORTED_ERROR"; | 772 out << "NOT_SUPPORTED_ERROR"; |
765 break; | 773 break; |
766 case DialogEvent::ABORT_CALLED: | 774 case DialogEvent::ABORT_CALLED: |
767 out << "ABORT_CALLED"; | 775 out << "ABORT_CALLED"; |
768 break; | 776 break; |
769 } | 777 } |
770 return out; | 778 return out; |
771 } | 779 } |
OLD | NEW |