| 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 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 542 void PaymentRequestBrowserTestBase::PayWithCreditCardAndWait( | 543 void PaymentRequestBrowserTestBase::PayWithCreditCardAndWait( |
| 543 const base::string16& cvc) { | 544 const base::string16& cvc) { |
| 544 OpenCVCPromptWithCVC(cvc); | 545 OpenCVCPromptWithCVC(cvc); |
| 545 | 546 |
| 546 ResetEventObserver(DialogEvent::DIALOG_CLOSED); | 547 ResetEventObserver(DialogEvent::DIALOG_CLOSED); |
| 547 ClickOnDialogViewAndWait(DialogViewID::CVC_PROMPT_CONFIRM_BUTTON); | 548 ClickOnDialogViewAndWait(DialogViewID::CVC_PROMPT_CONFIRM_BUTTON); |
| 548 } | 549 } |
| 549 | 550 |
| 550 base::string16 PaymentRequestBrowserTestBase::GetEditorTextfieldValue( | 551 base::string16 PaymentRequestBrowserTestBase::GetEditorTextfieldValue( |
| 551 autofill::ServerFieldType type) { | 552 autofill::ServerFieldType type) { |
| 552 ValidatingTextfield* textfield = static_cast<ValidatingTextfield*>( | 553 ValidatingTextfield* textfield = |
| 553 delegate_->dialog_view()->GetViewByID(static_cast<int>(type))); | 554 static_cast<ValidatingTextfield*>(delegate_->dialog_view()->GetViewByID( |
| 555 EditorViewController::GetInputFieldViewId(type))); |
| 554 DCHECK(textfield); | 556 DCHECK(textfield); |
| 555 return textfield->text(); | 557 return textfield->text(); |
| 556 } | 558 } |
| 557 | 559 |
| 558 void PaymentRequestBrowserTestBase::SetEditorTextfieldValue( | 560 void PaymentRequestBrowserTestBase::SetEditorTextfieldValue( |
| 559 const base::string16& value, | 561 const base::string16& value, |
| 560 autofill::ServerFieldType type) { | 562 autofill::ServerFieldType type) { |
| 561 ValidatingTextfield* textfield = static_cast<ValidatingTextfield*>( | 563 ValidatingTextfield* textfield = |
| 562 delegate_->dialog_view()->GetViewByID(static_cast<int>(type))); | 564 static_cast<ValidatingTextfield*>(delegate_->dialog_view()->GetViewByID( |
| 565 EditorViewController::GetInputFieldViewId(type))); |
| 563 DCHECK(textfield); | 566 DCHECK(textfield); |
| 564 textfield->SetText(value); | 567 textfield->SetText(value); |
| 565 textfield->OnContentsChanged(); | 568 textfield->OnContentsChanged(); |
| 566 textfield->OnBlur(); | 569 textfield->OnBlur(); |
| 567 } | 570 } |
| 568 | 571 |
| 569 base::string16 PaymentRequestBrowserTestBase::GetComboboxValue( | 572 base::string16 PaymentRequestBrowserTestBase::GetComboboxValue( |
| 570 autofill::ServerFieldType type) { | 573 autofill::ServerFieldType type) { |
| 571 ValidatingCombobox* combobox = static_cast<ValidatingCombobox*>( | 574 ValidatingCombobox* combobox = |
| 572 delegate_->dialog_view()->GetViewByID(static_cast<int>(type))); | 575 static_cast<ValidatingCombobox*>(delegate_->dialog_view()->GetViewByID( |
| 576 EditorViewController::GetInputFieldViewId(type))); |
| 573 DCHECK(combobox); | 577 DCHECK(combobox); |
| 574 return combobox->model()->GetItemAt(combobox->selected_index()); | 578 return combobox->model()->GetItemAt(combobox->selected_index()); |
| 575 } | 579 } |
| 576 | 580 |
| 577 void PaymentRequestBrowserTestBase::SetComboboxValue( | 581 void PaymentRequestBrowserTestBase::SetComboboxValue( |
| 578 const base::string16& value, | 582 const base::string16& value, |
| 579 autofill::ServerFieldType type) { | 583 autofill::ServerFieldType type) { |
| 580 ValidatingCombobox* combobox = static_cast<ValidatingCombobox*>( | 584 ValidatingCombobox* combobox = |
| 581 delegate_->dialog_view()->GetViewByID(static_cast<int>(type))); | 585 static_cast<ValidatingCombobox*>(delegate_->dialog_view()->GetViewByID( |
| 586 EditorViewController::GetInputFieldViewId(type))); |
| 582 DCHECK(combobox); | 587 DCHECK(combobox); |
| 583 combobox->SelectValue(value); | 588 combobox->SelectValue(value); |
| 584 combobox->OnContentsChanged(); | 589 combobox->OnContentsChanged(); |
| 585 combobox->OnBlur(); | 590 combobox->OnBlur(); |
| 586 } | 591 } |
| 587 | 592 |
| 588 void PaymentRequestBrowserTestBase::SelectBillingAddress( | 593 void PaymentRequestBrowserTestBase::SelectBillingAddress( |
| 589 const std::string& billing_address_id) { | 594 const std::string& billing_address_id) { |
| 590 views::Combobox* address_combobox(static_cast<views::Combobox*>( | 595 views::Combobox* address_combobox(static_cast<views::Combobox*>( |
| 591 dialog_view()->GetViewByID(static_cast<int>(kBillingAddressType)))); | 596 dialog_view()->GetViewByID(static_cast<int>(kBillingAddressType)))); |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 759 break; | 764 break; |
| 760 case DialogEvent::NOT_SUPPORTED_ERROR: | 765 case DialogEvent::NOT_SUPPORTED_ERROR: |
| 761 out << "NOT_SUPPORTED_ERROR"; | 766 out << "NOT_SUPPORTED_ERROR"; |
| 762 break; | 767 break; |
| 763 case DialogEvent::ABORT_CALLED: | 768 case DialogEvent::ABORT_CALLED: |
| 764 out << "ABORT_CALLED"; | 769 out << "ABORT_CALLED"; |
| 765 break; | 770 break; |
| 766 } | 771 } |
| 767 return out; | 772 return out; |
| 768 } | 773 } |
| OLD | NEW |