Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Side by Side Diff: chrome/browser/ui/views/payments/payment_request_browsertest_base.cc

Issue 2905733002: [WebPayments] Disabling done button when form invalid (Closed)
Patch Set: nits Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/views/payments/editor_view_controller.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 SelectComboboxRowForValue(views::Combobox* combobox,
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(i);
70 }
71
58 } // namespace 72 } // namespace
59 73
60 PersonalDataLoadedObserverMock::PersonalDataLoadedObserverMock() {} 74 PersonalDataLoadedObserverMock::PersonalDataLoadedObserverMock() {}
61 PersonalDataLoadedObserverMock::~PersonalDataLoadedObserverMock() {} 75 PersonalDataLoadedObserverMock::~PersonalDataLoadedObserverMock() {}
62 76
63 PaymentRequestBrowserTestBase::PaymentRequestBrowserTestBase( 77 PaymentRequestBrowserTestBase::PaymentRequestBrowserTestBase(
64 const std::string& test_file_path) 78 const std::string& test_file_path)
65 : test_file_path_(test_file_path), 79 : test_file_path_(test_file_path),
66 delegate_(nullptr), 80 delegate_(nullptr),
67 is_incognito_(false), 81 is_incognito_(false),
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 return textfield->text(); 578 return textfield->text();
565 } 579 }
566 580
567 void PaymentRequestBrowserTestBase::SetEditorTextfieldValue( 581 void PaymentRequestBrowserTestBase::SetEditorTextfieldValue(
568 const base::string16& value, 582 const base::string16& value,
569 autofill::ServerFieldType type) { 583 autofill::ServerFieldType type) {
570 ValidatingTextfield* textfield = 584 ValidatingTextfield* textfield =
571 static_cast<ValidatingTextfield*>(delegate_->dialog_view()->GetViewByID( 585 static_cast<ValidatingTextfield*>(delegate_->dialog_view()->GetViewByID(
572 EditorViewController::GetInputFieldViewId(type))); 586 EditorViewController::GetInputFieldViewId(type)));
573 DCHECK(textfield); 587 DCHECK(textfield);
574 textfield->SetText(value); 588 textfield->SetText(base::string16());
575 textfield->OnContentsChanged(); 589 textfield->InsertText(value);
576 textfield->OnBlur(); 590 textfield->OnBlur();
577 } 591 }
578 592
579 base::string16 PaymentRequestBrowserTestBase::GetComboboxValue( 593 base::string16 PaymentRequestBrowserTestBase::GetComboboxValue(
580 autofill::ServerFieldType type) { 594 autofill::ServerFieldType type) {
581 ValidatingCombobox* combobox = 595 ValidatingCombobox* combobox =
582 static_cast<ValidatingCombobox*>(delegate_->dialog_view()->GetViewByID( 596 static_cast<ValidatingCombobox*>(delegate_->dialog_view()->GetViewByID(
583 EditorViewController::GetInputFieldViewId(type))); 597 EditorViewController::GetInputFieldViewId(type)));
584 DCHECK(combobox); 598 DCHECK(combobox);
585 return combobox->model()->GetItemAt(combobox->selected_index()); 599 return combobox->model()->GetItemAt(combobox->selected_index());
586 } 600 }
587 601
588 void PaymentRequestBrowserTestBase::SetComboboxValue( 602 void PaymentRequestBrowserTestBase::SetComboboxValue(
589 const base::string16& value, 603 const base::string16& value,
590 autofill::ServerFieldType type) { 604 autofill::ServerFieldType type) {
591 ValidatingCombobox* combobox = 605 ValidatingCombobox* combobox =
592 static_cast<ValidatingCombobox*>(delegate_->dialog_view()->GetViewByID( 606 static_cast<ValidatingCombobox*>(delegate_->dialog_view()->GetViewByID(
593 EditorViewController::GetInputFieldViewId(type))); 607 EditorViewController::GetInputFieldViewId(type)));
594 DCHECK(combobox); 608 DCHECK(combobox);
595 combobox->SelectValue(value); 609 SelectComboboxRowForValue(combobox, value);
596 combobox->OnContentsChanged();
597 combobox->OnBlur(); 610 combobox->OnBlur();
598 } 611 }
599 612
600 void PaymentRequestBrowserTestBase::SelectBillingAddress( 613 void PaymentRequestBrowserTestBase::SelectBillingAddress(
601 const std::string& billing_address_id) { 614 const std::string& billing_address_id) {
602 views::Combobox* address_combobox( 615 views::Combobox* address_combobox(
603 static_cast<views::Combobox*>(dialog_view()->GetViewByID( 616 static_cast<views::Combobox*>(dialog_view()->GetViewByID(
604 EditorViewController::GetInputFieldViewId(kBillingAddressType)))); 617 EditorViewController::GetInputFieldViewId(kBillingAddressType))));
605 ASSERT_NE(address_combobox, nullptr); 618 ASSERT_NE(address_combobox, nullptr);
606 autofill::AddressComboboxModel* address_combobox_model( 619 autofill::AddressComboboxModel* address_combobox_model(
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 break; 788 break;
776 case DialogEvent::NOT_SUPPORTED_ERROR: 789 case DialogEvent::NOT_SUPPORTED_ERROR:
777 out << "NOT_SUPPORTED_ERROR"; 790 out << "NOT_SUPPORTED_ERROR";
778 break; 791 break;
779 case DialogEvent::ABORT_CALLED: 792 case DialogEvent::ABORT_CALLED:
780 out << "ABORT_CALLED"; 793 out << "ABORT_CALLED";
781 break; 794 break;
782 } 795 }
783 return out; 796 return out;
784 } 797 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/payments/editor_view_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698