| 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/memory/ptr_util.h" | 16 #include "base/memory/ptr_util.h" |
| 17 #include "base/run_loop.h" | 17 #include "base/run_loop.h" |
| 18 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
| 19 #include "chrome/browser/autofill/personal_data_manager_factory.h" | 19 #include "chrome/browser/autofill/personal_data_manager_factory.h" |
| 20 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
| 21 #include "chrome/browser/ui/browser.h" | 21 #include "chrome/browser/ui/browser.h" |
| 22 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 22 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 23 #include "chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h" | 23 #include "chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h" |
| 24 #include "chrome/browser/ui/views/payments/validating_combobox.h" | 24 #include "chrome/browser/ui/views/payments/validating_combobox.h" |
| 25 #include "chrome/browser/ui/views/payments/validating_textfield.h" | 25 #include "chrome/browser/ui/views/payments/validating_textfield.h" |
| 26 #include "chrome/browser/ui/views/payments/view_stack.h" | 26 #include "chrome/browser/ui/views/payments/view_stack.h" |
| 27 #include "chrome/test/base/ui_test_utils.h" | 27 #include "chrome/test/base/ui_test_utils.h" |
| 28 #include "components/autofill/core/browser/address_combobox_model.h" |
| 28 #include "components/autofill/core/browser/autofill_profile.h" | 29 #include "components/autofill/core/browser/autofill_profile.h" |
| 29 #include "components/autofill/core/browser/credit_card.h" | 30 #include "components/autofill/core/browser/credit_card.h" |
| 30 #include "components/autofill/core/browser/personal_data_manager.h" | 31 #include "components/autofill/core/browser/personal_data_manager.h" |
| 31 #include "components/payments/content/payment_request.h" | 32 #include "components/payments/content/payment_request.h" |
| 32 #include "components/payments/content/payment_request_web_contents_manager.h" | 33 #include "components/payments/content/payment_request_web_contents_manager.h" |
| 33 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 34 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
| 34 #include "content/public/browser/render_frame_host.h" | 35 #include "content/public/browser/render_frame_host.h" |
| 35 #include "content/public/browser/web_contents.h" | 36 #include "content/public/browser/web_contents.h" |
| 36 #include "content/public/test/browser_test_utils.h" | 37 #include "content/public/test/browser_test_utils.h" |
| 37 #include "services/service_manager/public/cpp/bind_source_info.h" | 38 #include "services/service_manager/public/cpp/bind_source_info.h" |
| 38 #include "services/service_manager/public/cpp/binder_registry.h" | 39 #include "services/service_manager/public/cpp/binder_registry.h" |
| 39 #include "testing/gtest/include/gtest/gtest.h" | 40 #include "testing/gtest/include/gtest/gtest.h" |
| 40 #include "ui/base/test/ui_controls.h" | 41 #include "ui/base/test/ui_controls.h" |
| 41 #include "ui/events/base_event_utils.h" | 42 #include "ui/events/base_event_utils.h" |
| 42 #include "ui/events/event.h" | 43 #include "ui/events/event.h" |
| 43 #include "ui/gfx/animation/test_animation_delegate.h" | 44 #include "ui/gfx/animation/test_animation_delegate.h" |
| 44 #include "ui/gfx/geometry/point.h" | 45 #include "ui/gfx/geometry/point.h" |
| 45 #include "ui/views/controls/button/button.h" | 46 #include "ui/views/controls/button/button.h" |
| 46 #include "ui/views/controls/label.h" | 47 #include "ui/views/controls/label.h" |
| 47 #include "ui/views/controls/styled_label.h" | 48 #include "ui/views/controls/styled_label.h" |
| 48 | 49 |
| 49 namespace payments { | 50 namespace payments { |
| 50 | 51 |
| 52 namespace { |
| 53 const auto kBillingAddressType = autofill::ADDRESS_BILLING_LINE1; |
| 54 } // namespace |
| 55 |
| 51 PersonalDataLoadedObserverMock::PersonalDataLoadedObserverMock() {} | 56 PersonalDataLoadedObserverMock::PersonalDataLoadedObserverMock() {} |
| 52 PersonalDataLoadedObserverMock::~PersonalDataLoadedObserverMock() {} | 57 PersonalDataLoadedObserverMock::~PersonalDataLoadedObserverMock() {} |
| 53 | 58 |
| 54 PaymentRequestBrowserTestBase::PaymentRequestBrowserTestBase( | 59 PaymentRequestBrowserTestBase::PaymentRequestBrowserTestBase( |
| 55 const std::string& test_file_path) | 60 const std::string& test_file_path) |
| 56 : test_file_path_(test_file_path), | 61 : test_file_path_(test_file_path), |
| 57 delegate_(nullptr), | 62 delegate_(nullptr), |
| 58 is_incognito_(false), | 63 is_incognito_(false), |
| 59 is_valid_ssl_(true) {} | 64 is_valid_ssl_(true) {} |
| 60 PaymentRequestBrowserTestBase::~PaymentRequestBrowserTestBase() {} | 65 PaymentRequestBrowserTestBase::~PaymentRequestBrowserTestBase() {} |
| (...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 554 const base::string16& value, | 559 const base::string16& value, |
| 555 autofill::ServerFieldType type) { | 560 autofill::ServerFieldType type) { |
| 556 ValidatingCombobox* combobox = static_cast<ValidatingCombobox*>( | 561 ValidatingCombobox* combobox = static_cast<ValidatingCombobox*>( |
| 557 delegate_->dialog_view()->GetViewByID(static_cast<int>(type))); | 562 delegate_->dialog_view()->GetViewByID(static_cast<int>(type))); |
| 558 DCHECK(combobox); | 563 DCHECK(combobox); |
| 559 combobox->SelectValue(value); | 564 combobox->SelectValue(value); |
| 560 combobox->OnContentsChanged(); | 565 combobox->OnContentsChanged(); |
| 561 combobox->OnBlur(); | 566 combobox->OnBlur(); |
| 562 } | 567 } |
| 563 | 568 |
| 569 void PaymentRequestBrowserTestBase::SelectBillingAddress( |
| 570 const std::string& billing_address_id) { |
| 571 views::Combobox* address_combobox(static_cast<views::Combobox*>( |
| 572 dialog_view()->GetViewByID(static_cast<int>(kBillingAddressType)))); |
| 573 ASSERT_NE(address_combobox, nullptr); |
| 574 autofill::AddressComboboxModel* address_combobox_model( |
| 575 static_cast<autofill::AddressComboboxModel*>(address_combobox->model())); |
| 576 address_combobox->SetSelectedIndex( |
| 577 address_combobox_model->GetIndexOfIdentifier(billing_address_id)); |
| 578 } |
| 579 |
| 564 bool PaymentRequestBrowserTestBase::IsEditorTextfieldInvalid( | 580 bool PaymentRequestBrowserTestBase::IsEditorTextfieldInvalid( |
| 565 autofill::ServerFieldType type) { | 581 autofill::ServerFieldType type) { |
| 566 ValidatingTextfield* textfield = static_cast<ValidatingTextfield*>( | 582 ValidatingTextfield* textfield = static_cast<ValidatingTextfield*>( |
| 567 delegate_->dialog_view()->GetViewByID(static_cast<int>(type))); | 583 delegate_->dialog_view()->GetViewByID(static_cast<int>(type))); |
| 568 DCHECK(textfield); | 584 DCHECK(textfield); |
| 569 return textfield->invalid(); | 585 return textfield->invalid(); |
| 570 } | 586 } |
| 571 | 587 |
| 572 bool PaymentRequestBrowserTestBase::IsEditorComboboxInvalid( | 588 bool PaymentRequestBrowserTestBase::IsEditorComboboxInvalid( |
| 573 autofill::ServerFieldType type) { | 589 autofill::ServerFieldType type) { |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 721 break; | 737 break; |
| 722 case DialogEvent::CVC_PROMPT_SHOWN: | 738 case DialogEvent::CVC_PROMPT_SHOWN: |
| 723 out << "CVC_PROMPT_SHOWN"; | 739 out << "CVC_PROMPT_SHOWN"; |
| 724 break; | 740 break; |
| 725 case DialogEvent::NOT_SUPPORTED_ERROR: | 741 case DialogEvent::NOT_SUPPORTED_ERROR: |
| 726 out << "NOT_SUPPORTED_ERROR"; | 742 out << "NOT_SUPPORTED_ERROR"; |
| 727 break; | 743 break; |
| 728 } | 744 } |
| 729 return out; | 745 return out; |
| 730 } | 746 } |
| OLD | NEW |