| 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 <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/bind.h" | 13 #include "base/bind.h" |
| 14 #include "base/bind_helpers.h" | 14 #include "base/bind_helpers.h" |
| 15 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
| 16 #include "base/run_loop.h" | 16 #include "base/run_loop.h" |
| 17 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
| 18 #include "chrome/browser/autofill/personal_data_manager_factory.h" | 18 #include "chrome/browser/autofill/personal_data_manager_factory.h" |
| 19 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
| 20 #include "chrome/browser/ui/browser.h" | 20 #include "chrome/browser/ui/browser.h" |
| 21 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 21 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 22 #include "chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h" | 22 #include "chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h" |
| 23 #include "chrome/browser/ui/views/payments/validating_combobox.h" | 23 #include "chrome/browser/ui/views/payments/validating_combobox.h" |
| 24 #include "chrome/browser/ui/views/payments/validating_textfield.h" | 24 #include "chrome/browser/ui/views/payments/validating_textfield.h" |
| 25 #include "chrome/browser/ui/views/payments/view_stack.h" | 25 #include "chrome/browser/ui/views/payments/view_stack.h" |
| 26 #include "chrome/test/base/ui_test_utils.h" | 26 #include "chrome/test/base/ui_test_utils.h" |
| 27 #include "components/autofill/core/browser/address_combobox_model.h" |
| 27 #include "components/autofill/core/browser/autofill_profile.h" | 28 #include "components/autofill/core/browser/autofill_profile.h" |
| 28 #include "components/autofill/core/browser/credit_card.h" | 29 #include "components/autofill/core/browser/credit_card.h" |
| 29 #include "components/autofill/core/browser/personal_data_manager.h" | 30 #include "components/autofill/core/browser/personal_data_manager.h" |
| 30 #include "components/payments/content/payment_request.h" | 31 #include "components/payments/content/payment_request.h" |
| 31 #include "components/payments/content/payment_request_web_contents_manager.h" | 32 #include "components/payments/content/payment_request_web_contents_manager.h" |
| 32 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 33 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
| 33 #include "content/public/browser/render_frame_host.h" | 34 #include "content/public/browser/render_frame_host.h" |
| 34 #include "content/public/browser/web_contents.h" | 35 #include "content/public/browser/web_contents.h" |
| 35 #include "content/public/test/browser_test_utils.h" | 36 #include "content/public/test/browser_test_utils.h" |
| 36 #include "services/service_manager/public/cpp/bind_source_info.h" | 37 #include "services/service_manager/public/cpp/bind_source_info.h" |
| 37 #include "services/service_manager/public/cpp/binder_registry.h" | 38 #include "services/service_manager/public/cpp/binder_registry.h" |
| 38 #include "testing/gtest/include/gtest/gtest.h" | 39 #include "testing/gtest/include/gtest/gtest.h" |
| 39 #include "ui/base/test/ui_controls.h" | 40 #include "ui/base/test/ui_controls.h" |
| 40 #include "ui/events/base_event_utils.h" | 41 #include "ui/events/base_event_utils.h" |
| 41 #include "ui/events/event.h" | 42 #include "ui/events/event.h" |
| 42 #include "ui/gfx/animation/test_animation_delegate.h" | 43 #include "ui/gfx/animation/test_animation_delegate.h" |
| 43 #include "ui/gfx/geometry/point.h" | 44 #include "ui/gfx/geometry/point.h" |
| 44 #include "ui/views/controls/button/button.h" | 45 #include "ui/views/controls/button/button.h" |
| 45 #include "ui/views/controls/label.h" | 46 #include "ui/views/controls/label.h" |
| 46 #include "ui/views/controls/styled_label.h" | 47 #include "ui/views/controls/styled_label.h" |
| 47 | 48 |
| 48 namespace payments { | 49 namespace payments { |
| 49 | 50 |
| 51 namespace { |
| 52 const auto kBillingAddressType = autofill::ADDRESS_BILLING_LINE1; |
| 53 } // namespace |
| 54 |
| 50 PersonalDataLoadedObserverMock::PersonalDataLoadedObserverMock() {} | 55 PersonalDataLoadedObserverMock::PersonalDataLoadedObserverMock() {} |
| 51 PersonalDataLoadedObserverMock::~PersonalDataLoadedObserverMock() {} | 56 PersonalDataLoadedObserverMock::~PersonalDataLoadedObserverMock() {} |
| 52 | 57 |
| 53 PaymentRequestBrowserTestBase::PaymentRequestBrowserTestBase( | 58 PaymentRequestBrowserTestBase::PaymentRequestBrowserTestBase( |
| 54 const std::string& test_file_path) | 59 const std::string& test_file_path) |
| 55 : test_file_path_(test_file_path), | 60 : test_file_path_(test_file_path), |
| 56 delegate_(nullptr), | 61 delegate_(nullptr), |
| 57 is_incognito_(false), | 62 is_incognito_(false), |
| 58 is_valid_ssl_(true) {} | 63 is_valid_ssl_(true) {} |
| 59 PaymentRequestBrowserTestBase::~PaymentRequestBrowserTestBase() {} | 64 PaymentRequestBrowserTestBase::~PaymentRequestBrowserTestBase() {} |
| (...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 const base::string16& value, | 555 const base::string16& value, |
| 551 autofill::ServerFieldType type) { | 556 autofill::ServerFieldType type) { |
| 552 ValidatingCombobox* combobox = static_cast<ValidatingCombobox*>( | 557 ValidatingCombobox* combobox = static_cast<ValidatingCombobox*>( |
| 553 delegate_->dialog_view()->GetViewByID(static_cast<int>(type))); | 558 delegate_->dialog_view()->GetViewByID(static_cast<int>(type))); |
| 554 DCHECK(combobox); | 559 DCHECK(combobox); |
| 555 combobox->SelectValue(value); | 560 combobox->SelectValue(value); |
| 556 combobox->OnContentsChanged(); | 561 combobox->OnContentsChanged(); |
| 557 combobox->OnBlur(); | 562 combobox->OnBlur(); |
| 558 } | 563 } |
| 559 | 564 |
| 565 void PaymentRequestBrowserTestBase::SelectBillingAddress( |
| 566 const std::string& billing_address_id) { |
| 567 views::Combobox* address_combobox(static_cast<views::Combobox*>( |
| 568 dialog_view()->GetViewByID(static_cast<int>(kBillingAddressType)))); |
| 569 ASSERT_NE(address_combobox, nullptr); |
| 570 autofill::AddressComboboxModel* address_combobox_model( |
| 571 static_cast<autofill::AddressComboboxModel*>(address_combobox->model())); |
| 572 address_combobox->SetSelectedIndex( |
| 573 address_combobox_model->GetIndexOfIdentifier(billing_address_id)); |
| 574 } |
| 575 |
| 560 bool PaymentRequestBrowserTestBase::IsEditorTextfieldInvalid( | 576 bool PaymentRequestBrowserTestBase::IsEditorTextfieldInvalid( |
| 561 autofill::ServerFieldType type) { | 577 autofill::ServerFieldType type) { |
| 562 ValidatingTextfield* textfield = static_cast<ValidatingTextfield*>( | 578 ValidatingTextfield* textfield = static_cast<ValidatingTextfield*>( |
| 563 delegate_->dialog_view()->GetViewByID(static_cast<int>(type))); | 579 delegate_->dialog_view()->GetViewByID(static_cast<int>(type))); |
| 564 DCHECK(textfield); | 580 DCHECK(textfield); |
| 565 return textfield->invalid(); | 581 return textfield->invalid(); |
| 566 } | 582 } |
| 567 | 583 |
| 568 bool PaymentRequestBrowserTestBase::IsEditorComboboxInvalid( | 584 bool PaymentRequestBrowserTestBase::IsEditorComboboxInvalid( |
| 569 autofill::ServerFieldType type) { | 585 autofill::ServerFieldType type) { |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 654 std::list<DialogEvent> event_sequence) { | 670 std::list<DialogEvent> event_sequence) { |
| 655 event_observer_ = | 671 event_observer_ = |
| 656 base::MakeUnique<DialogEventObserver>(std::move(event_sequence)); | 672 base::MakeUnique<DialogEventObserver>(std::move(event_sequence)); |
| 657 } | 673 } |
| 658 | 674 |
| 659 void PaymentRequestBrowserTestBase::WaitForObservedEvent() { | 675 void PaymentRequestBrowserTestBase::WaitForObservedEvent() { |
| 660 event_observer_->Wait(); | 676 event_observer_->Wait(); |
| 661 } | 677 } |
| 662 | 678 |
| 663 } // namespace payments | 679 } // namespace payments |
| OLD | NEW |