| Index: chrome/browser/ui/views/payments/payment_request_credit_card_editor_interactive_uitest.cc
|
| diff --git a/chrome/browser/ui/views/payments/payment_request_credit_card_editor_interactive_uitest.cc b/chrome/browser/ui/views/payments/payment_request_credit_card_editor_interactive_uitest.cc
|
| index 2f75250e9d3bd83bb307992d5387e9817bf5b704..a5f3d48422527af094dd3d22df3ca492dc582cf8 100644
|
| --- a/chrome/browser/ui/views/payments/payment_request_credit_card_editor_interactive_uitest.cc
|
| +++ b/chrome/browser/ui/views/payments/payment_request_credit_card_editor_interactive_uitest.cc
|
| @@ -4,15 +4,23 @@
|
|
|
| #include "base/macros.h"
|
| #include "base/strings/utf_string_conversions.h"
|
| +#include "base/time/time.h"
|
| #include "chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h"
|
| #include "chrome/browser/ui/views/payments/payment_request_interactive_uitest_base.h"
|
| #include "chrome/browser/ui/views/payments/validating_textfield.h"
|
| #include "components/autofill/core/browser/field_types.h"
|
| #include "components/autofill/core/browser/personal_data_manager.h"
|
| +#include "components/autofill/core/browser/test_autofill_clock.h"
|
| #include "components/payments/payment_request.h"
|
|
|
| namespace payments {
|
|
|
| +namespace {
|
| +
|
| +const base::Time kJune2017 = base::Time::FromDoubleT(1497552271);
|
| +
|
| +} // namespace
|
| +
|
| class PaymentRequestCreditCardEditorTest
|
| : public PaymentRequestInteractiveTestBase {
|
| protected:
|
| @@ -24,6 +32,9 @@ class PaymentRequestCreditCardEditorTest
|
| };
|
|
|
| IN_PROC_BROWSER_TEST_F(PaymentRequestCreditCardEditorTest, EnteringValidData) {
|
| + autofill::TestAutofillClock test_clock;
|
| + test_clock.SetNow(kJune2017);
|
| +
|
| InvokePaymentRequestUI();
|
|
|
| OpenPaymentMethodScreen();
|
| @@ -34,8 +45,9 @@ IN_PROC_BROWSER_TEST_F(PaymentRequestCreditCardEditorTest, EnteringValidData) {
|
| autofill::CREDIT_CARD_NAME_FULL);
|
| SetEditorTextfieldValue(base::ASCIIToUTF16("4111111111111111"),
|
| autofill::CREDIT_CARD_NUMBER);
|
| - SetEditorTextfieldValue(base::ASCIIToUTF16("05/45"),
|
| - autofill::CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR);
|
| + SetComboboxValue(base::ASCIIToUTF16("05"), autofill::CREDIT_CARD_EXP_MONTH);
|
| + SetComboboxValue(base::ASCIIToUTF16("2026"),
|
| + autofill::CREDIT_CARD_EXP_4_DIGIT_YEAR);
|
|
|
| ResetEventObserver(DialogEvent::BACK_NAVIGATION);
|
|
|
| @@ -48,15 +60,51 @@ IN_PROC_BROWSER_TEST_F(PaymentRequestCreditCardEditorTest, EnteringValidData) {
|
| autofill::CreditCard* credit_card =
|
| personal_data_manager->GetCreditCards()[0];
|
| EXPECT_EQ(5, credit_card->expiration_month());
|
| - EXPECT_EQ(2045, credit_card->expiration_year());
|
| - EXPECT_EQ(2045, credit_card->expiration_year());
|
| + EXPECT_EQ(2026, credit_card->expiration_year());
|
| EXPECT_EQ(base::ASCIIToUTF16("1111"), credit_card->LastFourDigits());
|
| EXPECT_EQ(base::ASCIIToUTF16("Bob Jones"),
|
| credit_card->GetRawInfo(autofill::CREDIT_CARD_NAME_FULL));
|
| }
|
|
|
| IN_PROC_BROWSER_TEST_F(PaymentRequestCreditCardEditorTest,
|
| - EnteringInvalidData) {
|
| + EnteringExpiredCard) {
|
| + autofill::TestAutofillClock test_clock;
|
| + test_clock.SetNow(kJune2017);
|
| +
|
| + InvokePaymentRequestUI();
|
| +
|
| + OpenPaymentMethodScreen();
|
| +
|
| + OpenCreditCardEditorScreen();
|
| +
|
| + SetEditorTextfieldValue(base::ASCIIToUTF16("Bob Jones"),
|
| + autofill::CREDIT_CARD_NAME_FULL);
|
| + SetEditorTextfieldValue(base::ASCIIToUTF16("4111111111111111"),
|
| + autofill::CREDIT_CARD_NUMBER);
|
| + // The card is expired.
|
| + SetComboboxValue(base::ASCIIToUTF16("01"), autofill::CREDIT_CARD_EXP_MONTH);
|
| + SetComboboxValue(base::ASCIIToUTF16("2017"),
|
| + autofill::CREDIT_CARD_EXP_4_DIGIT_YEAR);
|
| +
|
| + ClickOnDialogViewAndWait(DialogViewID::EDITOR_SAVE_BUTTON);
|
| +
|
| + EXPECT_FALSE(IsEditorTextfieldInvalid(autofill::CREDIT_CARD_NAME_FULL));
|
| + EXPECT_FALSE(IsEditorTextfieldInvalid(autofill::CREDIT_CARD_NUMBER));
|
| + // TODO(mathp): Both expiration fields should be marked as invalid when the
|
| + // card is expired.
|
| + EXPECT_FALSE(IsEditorComboboxInvalid(autofill::CREDIT_CARD_EXP_MONTH));
|
| + EXPECT_FALSE(IsEditorComboboxInvalid(autofill::CREDIT_CARD_EXP_4_DIGIT_YEAR));
|
| +
|
| + autofill::PersonalDataManager* personal_data_manager =
|
| + GetPaymentRequests(GetActiveWebContents())[0]->personal_data_manager();
|
| + EXPECT_EQ(0u, personal_data_manager->GetCreditCards().size());
|
| +}
|
| +
|
| +IN_PROC_BROWSER_TEST_F(PaymentRequestCreditCardEditorTest,
|
| + EnteringInvalidCardNumber) {
|
| + autofill::TestAutofillClock test_clock;
|
| + test_clock.SetNow(kJune2017);
|
| +
|
| InvokePaymentRequestUI();
|
|
|
| OpenPaymentMethodScreen();
|
| @@ -67,15 +115,16 @@ IN_PROC_BROWSER_TEST_F(PaymentRequestCreditCardEditorTest,
|
| autofill::CREDIT_CARD_NAME_FULL);
|
| SetEditorTextfieldValue(base::ASCIIToUTF16("41111111invalidcard"),
|
| autofill::CREDIT_CARD_NUMBER);
|
| - SetEditorTextfieldValue(base::ASCIIToUTF16("05/45"),
|
| - autofill::CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR);
|
| + SetComboboxValue(base::ASCIIToUTF16("05"), autofill::CREDIT_CARD_EXP_MONTH);
|
| + SetComboboxValue(base::ASCIIToUTF16("2026"),
|
| + autofill::CREDIT_CARD_EXP_4_DIGIT_YEAR);
|
|
|
| ClickOnDialogViewAndWait(DialogViewID::EDITOR_SAVE_BUTTON);
|
|
|
| EXPECT_FALSE(IsEditorTextfieldInvalid(autofill::CREDIT_CARD_NAME_FULL));
|
| EXPECT_TRUE(IsEditorTextfieldInvalid(autofill::CREDIT_CARD_NUMBER));
|
| - EXPECT_FALSE(
|
| - IsEditorTextfieldInvalid(autofill::CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR));
|
| + EXPECT_FALSE(IsEditorComboboxInvalid(autofill::CREDIT_CARD_EXP_MONTH));
|
| + EXPECT_FALSE(IsEditorComboboxInvalid(autofill::CREDIT_CARD_EXP_4_DIGIT_YEAR));
|
|
|
| autofill::PersonalDataManager* personal_data_manager =
|
| GetPaymentRequests(GetActiveWebContents())[0]->personal_data_manager();
|
|
|