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

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

Issue 2895473005: [Payments] Have expiration date be on the same line in CC editor (Closed)
Patch Set: addressed comments Created 3 years, 7 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
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 <string> 5 #include <string>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
11 #include "chrome/browser/ui/views/payments/editor_view_controller.h"
11 #include "chrome/browser/ui/views/payments/payment_request_browsertest_base.h" 12 #include "chrome/browser/ui/views/payments/payment_request_browsertest_base.h"
12 #include "chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h" 13 #include "chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h"
13 #include "chrome/browser/ui/views/payments/validating_textfield.h" 14 #include "chrome/browser/ui/views/payments/validating_textfield.h"
14 #include "components/autofill/core/browser/autofill_test_utils.h" 15 #include "components/autofill/core/browser/autofill_test_utils.h"
15 #include "components/autofill/core/browser/field_types.h" 16 #include "components/autofill/core/browser/field_types.h"
16 #include "components/autofill/core/browser/personal_data_manager.h" 17 #include "components/autofill/core/browser/personal_data_manager.h"
17 #include "components/autofill/core/browser/test_autofill_clock.h" 18 #include "components/autofill/core/browser/test_autofill_clock.h"
18 #include "components/payments/content/payment_request.h" 19 #include "components/payments/content/payment_request.h"
19 #include "components/payments/content/payment_request_spec.h" 20 #include "components/payments/content/payment_request_spec.h"
20 #include "components/strings/grit/components_strings.h" 21 #include "components/strings/grit/components_strings.h"
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 autofill::CREDIT_CARD_NUMBER); 184 autofill::CREDIT_CARD_NUMBER);
184 // The card is expired. 185 // The card is expired.
185 SetComboboxValue(base::ASCIIToUTF16("01"), autofill::CREDIT_CARD_EXP_MONTH); 186 SetComboboxValue(base::ASCIIToUTF16("01"), autofill::CREDIT_CARD_EXP_MONTH);
186 SetComboboxValue(base::ASCIIToUTF16("2017"), 187 SetComboboxValue(base::ASCIIToUTF16("2017"),
187 autofill::CREDIT_CARD_EXP_4_DIGIT_YEAR); 188 autofill::CREDIT_CARD_EXP_4_DIGIT_YEAR);
188 189
189 ClickOnDialogViewAndWait(DialogViewID::EDITOR_SAVE_BUTTON); 190 ClickOnDialogViewAndWait(DialogViewID::EDITOR_SAVE_BUTTON);
190 191
191 EXPECT_FALSE(IsEditorTextfieldInvalid(autofill::CREDIT_CARD_NAME_FULL)); 192 EXPECT_FALSE(IsEditorTextfieldInvalid(autofill::CREDIT_CARD_NAME_FULL));
192 EXPECT_FALSE(IsEditorTextfieldInvalid(autofill::CREDIT_CARD_NUMBER)); 193 EXPECT_FALSE(IsEditorTextfieldInvalid(autofill::CREDIT_CARD_NUMBER));
193 // TODO(mathp): Both expiration fields should be marked as invalid when the 194 EXPECT_TRUE(IsEditorComboboxInvalid(autofill::CREDIT_CARD_EXP_MONTH));
194 // card is expired. 195 EXPECT_TRUE(IsEditorComboboxInvalid(autofill::CREDIT_CARD_EXP_4_DIGIT_YEAR));
195 EXPECT_FALSE(IsEditorComboboxInvalid(autofill::CREDIT_CARD_EXP_MONTH)); 196 EXPECT_EQ(l10n_util::GetStringUTF16(
196 EXPECT_FALSE(IsEditorComboboxInvalid(autofill::CREDIT_CARD_EXP_4_DIGIT_YEAR)); 197 IDS_PAYMENTS_VALIDATION_INVALID_CREDIT_CARD_EXPIRED),
198 GetErrorLabelForType(autofill::CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR));
197 199
198 autofill::PersonalDataManager* personal_data_manager = GetDataManager(); 200 autofill::PersonalDataManager* personal_data_manager = GetDataManager();
199 EXPECT_EQ(0u, personal_data_manager->GetCreditCards().size()); 201 EXPECT_EQ(0u, personal_data_manager->GetCreditCards().size());
200 } 202 }
201 203
202 IN_PROC_BROWSER_TEST_F(PaymentRequestCreditCardEditorTest, 204 IN_PROC_BROWSER_TEST_F(PaymentRequestCreditCardEditorTest,
203 EnteringNothingInARequiredField) { 205 EnteringNothingInARequiredField) {
204 autofill::TestAutofillClock test_clock; 206 autofill::TestAutofillClock test_clock;
205 test_clock.SetNow(kJune2017); 207 test_clock.SetNow(kJune2017);
206 208
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 autofill::ADDRESS_HOME_ZIP); 522 autofill::ADDRESS_HOME_ZIP);
521 SetEditorTextfieldValue(base::ASCIIToUTF16("5755555555"), 523 SetEditorTextfieldValue(base::ASCIIToUTF16("5755555555"),
522 autofill::PHONE_HOME_WHOLE_NUMBER); 524 autofill::PHONE_HOME_WHOLE_NUMBER);
523 525
524 // Come back to credit card editor. 526 // Come back to credit card editor.
525 ResetEventObserver(DialogEvent::BACK_NAVIGATION); 527 ResetEventObserver(DialogEvent::BACK_NAVIGATION);
526 ClickOnDialogViewAndWait(DialogViewID::SAVE_ADDRESS_BUTTON); 528 ClickOnDialogViewAndWait(DialogViewID::SAVE_ADDRESS_BUTTON);
527 529
528 // The billing address must be properly selected and valid. 530 // The billing address must be properly selected and valid.
529 views::Combobox* billing_combobox = static_cast<views::Combobox*>( 531 views::Combobox* billing_combobox = static_cast<views::Combobox*>(
530 dialog_view()->GetViewByID(autofill::ADDRESS_BILLING_LINE1)); 532 dialog_view()->GetViewByID(EditorViewController::GetInputFieldViewId(
533 autofill::ADDRESS_BILLING_LINE1)));
531 ASSERT_NE(nullptr, billing_combobox); 534 ASSERT_NE(nullptr, billing_combobox);
532 EXPECT_FALSE(billing_combobox->invalid()); 535 EXPECT_FALSE(billing_combobox->invalid());
533 536
534 // And then save credit card state and come back to payment sheet. 537 // And then save credit card state and come back to payment sheet.
535 ResetEventObserver(DialogEvent::BACK_TO_PAYMENT_SHEET_NAVIGATION); 538 ResetEventObserver(DialogEvent::BACK_TO_PAYMENT_SHEET_NAVIGATION);
536 539
537 // Verifying the data is in the DB. 540 // Verifying the data is in the DB.
538 autofill::PersonalDataManager* personal_data_manager = GetDataManager(); 541 autofill::PersonalDataManager* personal_data_manager = GetDataManager();
539 personal_data_manager->AddObserver(&personal_data_observer_); 542 personal_data_manager->AddObserver(&personal_data_observer_);
540 543
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 IN_PROC_BROWSER_TEST_F(PaymentRequestCreditCardEditorTest, EnteringEmptyData) { 591 IN_PROC_BROWSER_TEST_F(PaymentRequestCreditCardEditorTest, EnteringEmptyData) {
589 InvokePaymentRequestUI(); 592 InvokePaymentRequestUI();
590 593
591 OpenCreditCardEditorScreen(); 594 OpenCreditCardEditorScreen();
592 595
593 // Setting empty data and unfocusing a required textfield will make it 596 // Setting empty data and unfocusing a required textfield will make it
594 // invalid. 597 // invalid.
595 SetEditorTextfieldValue(base::ASCIIToUTF16(""), 598 SetEditorTextfieldValue(base::ASCIIToUTF16(""),
596 autofill::CREDIT_CARD_NAME_FULL); 599 autofill::CREDIT_CARD_NAME_FULL);
597 600
598 ValidatingTextfield* textfield = 601 ValidatingTextfield* textfield = static_cast<ValidatingTextfield*>(
599 static_cast<ValidatingTextfield*>(dialog_view()->GetViewByID( 602 dialog_view()->GetViewByID(EditorViewController::GetInputFieldViewId(
600 static_cast<int>(autofill::CREDIT_CARD_NAME_FULL))); 603 autofill::CREDIT_CARD_NAME_FULL)));
601 EXPECT_TRUE(textfield); 604 EXPECT_TRUE(textfield);
602 EXPECT_TRUE(textfield->invalid()); 605 EXPECT_TRUE(textfield->invalid());
603 } 606 }
604 607
605 } // namespace payments 608 } // namespace payments
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698