Chromium Code Reviews| 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> |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 48 #include "ui/gfx/animation/test_animation_delegate.h" | 48 #include "ui/gfx/animation/test_animation_delegate.h" |
| 49 #include "ui/gfx/geometry/point.h" | 49 #include "ui/gfx/geometry/point.h" |
| 50 #include "ui/views/controls/button/button.h" | 50 #include "ui/views/controls/button/button.h" |
| 51 #include "ui/views/controls/label.h" | 51 #include "ui/views/controls/label.h" |
| 52 #include "ui/views/controls/styled_label.h" | 52 #include "ui/views/controls/styled_label.h" |
| 53 | 53 |
| 54 namespace payments { | 54 namespace payments { |
| 55 | 55 |
| 56 namespace { | 56 namespace { |
| 57 const auto kBillingAddressType = autofill::ADDRESS_BILLING_LINE1; | 57 const auto kBillingAddressType = autofill::ADDRESS_BILLING_LINE1; |
| 58 | |
| 59 // This is preferred to SelectValue, since only SetSelectedRow fires the events | |
| 60 // as if done by a user. | |
| 61 void SetComboboxRowForValue(views::Combobox* combobox, | |
|
Mathieu
2017/05/29 16:45:36
nit: *SelectComboboxRowForValue?
tmartino
2017/05/29 21:06:58
Done
| |
| 62 const base::string16& text) { | |
| 63 int i; | |
| 64 for (i = 0; i < combobox->GetRowCount(); i++) { | |
| 65 if (combobox->GetTextForRow(i) == text) | |
| 66 break; | |
| 67 } | |
| 68 DCHECK(i < combobox->GetRowCount()) << "Combobox does not contain " << text; | |
| 69 combobox->SetSelectedRow(0); | |
|
Mathieu
2017/05/29 16:45:36
The SelectBillingAddress code seems to get away wi
tmartino
2017/05/29 21:06:58
Yup, done.
| |
| 70 combobox->SetSelectedRow(i); | |
| 71 | |
| 72 // Hit enter twice to trigger events. | |
|
Mathieu
2017/05/29 16:45:36
Are we doing this to make sure OnBlur is called on
tmartino
2017/05/29 21:06:58
n/a anymore
| |
| 73 ui::KeyEvent enter_event(ui::ET_KEY_PRESSED, ui::VKEY_RETURN, 0); | |
| 74 LOG(ERROR) << "Pressing enter..."; | |
|
Mathieu
2017/05/29 16:45:36
plz remove :)
tmartino
2017/05/29 21:06:58
n/a
| |
| 75 combobox->OnKeyPressed(enter_event); | |
| 76 LOG(ERROR) << "Pressing enter..."; | |
| 77 combobox->OnKeyPressed(enter_event); | |
| 78 LOG(ERROR) << "Done pressing enter..."; | |
| 79 } | |
| 80 | |
| 58 } // namespace | 81 } // namespace |
| 59 | 82 |
| 60 PersonalDataLoadedObserverMock::PersonalDataLoadedObserverMock() {} | 83 PersonalDataLoadedObserverMock::PersonalDataLoadedObserverMock() {} |
| 61 PersonalDataLoadedObserverMock::~PersonalDataLoadedObserverMock() {} | 84 PersonalDataLoadedObserverMock::~PersonalDataLoadedObserverMock() {} |
| 62 | 85 |
| 63 PaymentRequestBrowserTestBase::PaymentRequestBrowserTestBase( | 86 PaymentRequestBrowserTestBase::PaymentRequestBrowserTestBase( |
| 64 const std::string& test_file_path) | 87 const std::string& test_file_path) |
| 65 : test_file_path_(test_file_path), | 88 : test_file_path_(test_file_path), |
| 66 delegate_(nullptr), | 89 delegate_(nullptr), |
| 67 is_incognito_(false), | 90 is_incognito_(false), |
| (...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 564 return textfield->text(); | 587 return textfield->text(); |
| 565 } | 588 } |
| 566 | 589 |
| 567 void PaymentRequestBrowserTestBase::SetEditorTextfieldValue( | 590 void PaymentRequestBrowserTestBase::SetEditorTextfieldValue( |
| 568 const base::string16& value, | 591 const base::string16& value, |
| 569 autofill::ServerFieldType type) { | 592 autofill::ServerFieldType type) { |
| 570 ValidatingTextfield* textfield = | 593 ValidatingTextfield* textfield = |
| 571 static_cast<ValidatingTextfield*>(delegate_->dialog_view()->GetViewByID( | 594 static_cast<ValidatingTextfield*>(delegate_->dialog_view()->GetViewByID( |
| 572 EditorViewController::GetInputFieldViewId(type))); | 595 EditorViewController::GetInputFieldViewId(type))); |
| 573 DCHECK(textfield); | 596 DCHECK(textfield); |
| 574 textfield->SetText(value); | 597 textfield->SetText(base::string16()); |
| 575 textfield->OnContentsChanged(); | 598 textfield->InsertText(value); |
| 576 textfield->OnBlur(); | 599 textfield->OnBlur(); |
| 577 } | 600 } |
| 578 | 601 |
| 579 base::string16 PaymentRequestBrowserTestBase::GetComboboxValue( | 602 base::string16 PaymentRequestBrowserTestBase::GetComboboxValue( |
| 580 autofill::ServerFieldType type) { | 603 autofill::ServerFieldType type) { |
| 581 ValidatingCombobox* combobox = | 604 ValidatingCombobox* combobox = |
| 582 static_cast<ValidatingCombobox*>(delegate_->dialog_view()->GetViewByID( | 605 static_cast<ValidatingCombobox*>(delegate_->dialog_view()->GetViewByID( |
| 583 EditorViewController::GetInputFieldViewId(type))); | 606 EditorViewController::GetInputFieldViewId(type))); |
| 584 DCHECK(combobox); | 607 DCHECK(combobox); |
| 585 return combobox->model()->GetItemAt(combobox->selected_index()); | 608 return combobox->model()->GetItemAt(combobox->selected_index()); |
| 586 } | 609 } |
| 587 | 610 |
| 588 void PaymentRequestBrowserTestBase::SetComboboxValue( | 611 void PaymentRequestBrowserTestBase::SetComboboxValue( |
| 589 const base::string16& value, | 612 const base::string16& value, |
| 590 autofill::ServerFieldType type) { | 613 autofill::ServerFieldType type) { |
| 591 ValidatingCombobox* combobox = | 614 ValidatingCombobox* combobox = |
| 592 static_cast<ValidatingCombobox*>(delegate_->dialog_view()->GetViewByID( | 615 static_cast<ValidatingCombobox*>(delegate_->dialog_view()->GetViewByID( |
| 593 EditorViewController::GetInputFieldViewId(type))); | 616 EditorViewController::GetInputFieldViewId(type))); |
| 594 DCHECK(combobox); | 617 DCHECK(combobox); |
| 595 combobox->SelectValue(value); | 618 SetComboboxRowForValue(combobox, value); |
| 596 combobox->OnContentsChanged(); | |
| 597 combobox->OnBlur(); | 619 combobox->OnBlur(); |
| 598 } | 620 } |
| 599 | 621 |
| 600 void PaymentRequestBrowserTestBase::SelectBillingAddress( | 622 void PaymentRequestBrowserTestBase::SelectBillingAddress( |
| 601 const std::string& billing_address_id) { | 623 const std::string& billing_address_id) { |
| 624 LOG(ERROR) << "Setting billing address"; | |
|
Mathieu
2017/05/29 16:45:36
please fix
tmartino
2017/05/29 21:06:58
Done
| |
| 602 views::Combobox* address_combobox( | 625 views::Combobox* address_combobox( |
| 603 static_cast<views::Combobox*>(dialog_view()->GetViewByID( | 626 static_cast<views::Combobox*>(dialog_view()->GetViewByID( |
| 604 EditorViewController::GetInputFieldViewId(kBillingAddressType)))); | 627 EditorViewController::GetInputFieldViewId(kBillingAddressType)))); |
| 605 ASSERT_NE(address_combobox, nullptr); | 628 ASSERT_NE(address_combobox, nullptr); |
| 606 autofill::AddressComboboxModel* address_combobox_model( | 629 autofill::AddressComboboxModel* address_combobox_model( |
| 607 static_cast<autofill::AddressComboboxModel*>(address_combobox->model())); | 630 static_cast<autofill::AddressComboboxModel*>(address_combobox->model())); |
| 608 address_combobox->SetSelectedRow( | 631 address_combobox->SetSelectedRow( |
| 609 address_combobox_model->GetIndexOfIdentifier(billing_address_id)); | 632 address_combobox_model->GetIndexOfIdentifier(billing_address_id)); |
| 610 address_combobox->OnBlur(); | 633 address_combobox->OnBlur(); |
| 611 } | 634 } |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 775 break; | 798 break; |
| 776 case DialogEvent::NOT_SUPPORTED_ERROR: | 799 case DialogEvent::NOT_SUPPORTED_ERROR: |
| 777 out << "NOT_SUPPORTED_ERROR"; | 800 out << "NOT_SUPPORTED_ERROR"; |
| 778 break; | 801 break; |
| 779 case DialogEvent::ABORT_CALLED: | 802 case DialogEvent::ABORT_CALLED: |
| 780 out << "ABORT_CALLED"; | 803 out << "ABORT_CALLED"; |
| 781 break; | 804 break; |
| 782 } | 805 } |
| 783 return out; | 806 return out; |
| 784 } | 807 } |
| OLD | NEW |