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

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 + rebase 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 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 PaymentRequest* request = GetPaymentRequests(GetActiveWebContents()).front(); 500 PaymentRequest* request = GetPaymentRequests(GetActiveWebContents()).front();
499 EXPECT_EQ(1U, request->state()->available_instruments().size()); 501 EXPECT_EQ(1U, request->state()->available_instruments().size());
500 EXPECT_EQ(nullptr, request->state()->selected_instrument()); 502 EXPECT_EQ(nullptr, request->state()->selected_instrument());
501 503
502 OpenPaymentMethodScreen(); 504 OpenPaymentMethodScreen();
503 505
504 ResetEventObserver(DialogEvent::CREDIT_CARD_EDITOR_OPENED); 506 ResetEventObserver(DialogEvent::CREDIT_CARD_EDITOR_OPENED);
505 ClickOnChildInListViewAndWait(/*child_index=*/0, /*num_children=*/1, 507 ClickOnChildInListViewAndWait(/*child_index=*/0, /*num_children=*/1,
506 DialogViewID::PAYMENT_METHOD_SHEET_LIST_VIEW); 508 DialogViewID::PAYMENT_METHOD_SHEET_LIST_VIEW);
507 // Billing address combobox must be disabled since there are no saved address. 509 // Billing address combobox must be disabled since there are no saved address.
508 views::View* billing_address_combobox = dialog_view()->GetViewByID( 510 views::View* billing_address_combobox =
509 static_cast<int>(autofill::ADDRESS_BILLING_LINE1)); 511 dialog_view()->GetViewByID(EditorViewController::GetInputFieldViewId(
512 autofill::ADDRESS_BILLING_LINE1));
510 ASSERT_NE(nullptr, billing_address_combobox); 513 ASSERT_NE(nullptr, billing_address_combobox);
511 EXPECT_FALSE(billing_address_combobox->enabled()); 514 EXPECT_FALSE(billing_address_combobox->enabled());
512 515
513 // Click to open the address editor 516 // Click to open the address editor
514 ResetEventObserver(DialogEvent::SHIPPING_ADDRESS_EDITOR_OPENED); 517 ResetEventObserver(DialogEvent::SHIPPING_ADDRESS_EDITOR_OPENED);
515 ClickOnDialogViewAndWait(DialogViewID::ADD_BILLING_ADDRESS_BUTTON); 518 ClickOnDialogViewAndWait(DialogViewID::ADD_BILLING_ADDRESS_BUTTON);
516 519
517 // Set valid address values. 520 // Set valid address values.
518 SetEditorTextfieldValue(base::ASCIIToUTF16("Bob"), autofill::NAME_FULL); 521 SetEditorTextfieldValue(base::ASCIIToUTF16("Bob"), autofill::NAME_FULL);
519 SetEditorTextfieldValue(base::ASCIIToUTF16("42 BobStreet"), 522 SetEditorTextfieldValue(base::ASCIIToUTF16("42 BobStreet"),
520 autofill::ADDRESS_HOME_STREET_ADDRESS); 523 autofill::ADDRESS_HOME_STREET_ADDRESS);
521 SetEditorTextfieldValue(base::ASCIIToUTF16("BobCity"), 524 SetEditorTextfieldValue(base::ASCIIToUTF16("BobCity"),
522 autofill::ADDRESS_HOME_CITY); 525 autofill::ADDRESS_HOME_CITY);
523 SetEditorTextfieldValue(base::ASCIIToUTF16("BobZip"), 526 SetEditorTextfieldValue(base::ASCIIToUTF16("BobZip"),
524 autofill::ADDRESS_HOME_ZIP); 527 autofill::ADDRESS_HOME_ZIP);
525 SetEditorTextfieldValue(base::ASCIIToUTF16("5755555555"), 528 SetEditorTextfieldValue(base::ASCIIToUTF16("5755555555"),
526 autofill::PHONE_HOME_WHOLE_NUMBER); 529 autofill::PHONE_HOME_WHOLE_NUMBER);
527 530
528 // Come back to credit card editor. 531 // Come back to credit card editor.
529 ResetEventObserver(DialogEvent::BACK_NAVIGATION); 532 ResetEventObserver(DialogEvent::BACK_NAVIGATION);
530 ClickOnDialogViewAndWait(DialogViewID::SAVE_ADDRESS_BUTTON); 533 ClickOnDialogViewAndWait(DialogViewID::SAVE_ADDRESS_BUTTON);
531 534
532 // The billing address must be properly selected and valid. 535 // The billing address must be properly selected and valid.
533 views::Combobox* billing_combobox = static_cast<views::Combobox*>( 536 views::Combobox* billing_combobox = static_cast<views::Combobox*>(
534 dialog_view()->GetViewByID(autofill::ADDRESS_BILLING_LINE1)); 537 dialog_view()->GetViewByID(EditorViewController::GetInputFieldViewId(
538 autofill::ADDRESS_BILLING_LINE1)));
535 ASSERT_NE(nullptr, billing_combobox); 539 ASSERT_NE(nullptr, billing_combobox);
536 EXPECT_FALSE(billing_combobox->invalid()); 540 EXPECT_FALSE(billing_combobox->invalid());
537 541
538 // And then save credit card state and come back to payment sheet. 542 // And then save credit card state and come back to payment sheet.
539 ResetEventObserver(DialogEvent::BACK_TO_PAYMENT_SHEET_NAVIGATION); 543 ResetEventObserver(DialogEvent::BACK_TO_PAYMENT_SHEET_NAVIGATION);
540 544
541 // Verifying the data is in the DB. 545 // Verifying the data is in the DB.
542 autofill::PersonalDataManager* personal_data_manager = GetDataManager(); 546 autofill::PersonalDataManager* personal_data_manager = GetDataManager();
543 personal_data_manager->AddObserver(&personal_data_observer_); 547 personal_data_manager->AddObserver(&personal_data_observer_);
544 548
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 IN_PROC_BROWSER_TEST_F(PaymentRequestCreditCardEditorTest, EnteringEmptyData) { 596 IN_PROC_BROWSER_TEST_F(PaymentRequestCreditCardEditorTest, EnteringEmptyData) {
593 InvokePaymentRequestUI(); 597 InvokePaymentRequestUI();
594 598
595 OpenCreditCardEditorScreen(); 599 OpenCreditCardEditorScreen();
596 600
597 // Setting empty data and unfocusing a required textfield will make it 601 // Setting empty data and unfocusing a required textfield will make it
598 // invalid. 602 // invalid.
599 SetEditorTextfieldValue(base::ASCIIToUTF16(""), 603 SetEditorTextfieldValue(base::ASCIIToUTF16(""),
600 autofill::CREDIT_CARD_NAME_FULL); 604 autofill::CREDIT_CARD_NAME_FULL);
601 605
602 ValidatingTextfield* textfield = 606 ValidatingTextfield* textfield = static_cast<ValidatingTextfield*>(
603 static_cast<ValidatingTextfield*>(dialog_view()->GetViewByID( 607 dialog_view()->GetViewByID(EditorViewController::GetInputFieldViewId(
604 static_cast<int>(autofill::CREDIT_CARD_NAME_FULL))); 608 autofill::CREDIT_CARD_NAME_FULL)));
605 EXPECT_TRUE(textfield); 609 EXPECT_TRUE(textfield);
606 EXPECT_FALSE(textfield->IsValid()); 610 EXPECT_FALSE(textfield->IsValid());
607 } 611 }
608 612
609 } // namespace payments 613 } // namespace payments
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698