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

Unified Diff: chrome/browser/ui/views/payments/credit_card_editor_view_controller_browsertest.cc

Issue 2905733002: [WebPayments] Disabling done button when form invalid (Closed)
Patch Set: upload 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/payments/credit_card_editor_view_controller_browsertest.cc
diff --git a/chrome/browser/ui/views/payments/credit_card_editor_view_controller_browsertest.cc b/chrome/browser/ui/views/payments/credit_card_editor_view_controller_browsertest.cc
index be25d9a84f41ea2cc7900362e118e5f473e484d5..16501b9b74d1d95046c42434ba3434cdf3d7f234 100644
--- a/chrome/browser/ui/views/payments/credit_card_editor_view_controller_browsertest.cc
+++ b/chrome/browser/ui/views/payments/credit_card_editor_view_controller_browsertest.cc
@@ -685,4 +685,45 @@ IN_PROC_BROWSER_TEST_F(PaymentRequestCreditCardEditorTest, EnteringEmptyData) {
EXPECT_FALSE(textfield->IsValid());
}
+IN_PROC_BROWSER_TEST_F(PaymentRequestCreditCardEditorTest, DoneButtonDisabled) {
+ autofill::TestAutofillClock test_clock;
+ test_clock.SetNow(kJune2017);
+ InvokePaymentRequestUI();
+
+ autofill::AutofillProfile billing_profile(autofill::test::GetFullProfile());
+ AddAutofillProfile(billing_profile);
+
+ OpenCreditCardEditorScreen();
+
+ views::View* save_button = dialog_view()->GetViewByID(
+ static_cast<int>(DialogViewID::EDITOR_SAVE_BUTTON));
+
+ EXPECT_FALSE(save_button->enabled());
+
+ // Set all fields but one:
+ SetEditorTextfieldValue(base::ASCIIToUTF16("Bob Jones"),
+ autofill::CREDIT_CARD_NAME_FULL);
+ SetEditorTextfieldValue(base::ASCIIToUTF16("4111111111111111"),
+ autofill::CREDIT_CARD_NUMBER);
+ SetComboboxValue(base::ASCIIToUTF16("05"), autofill::CREDIT_CARD_EXP_MONTH);
+ SetComboboxValue(base::ASCIIToUTF16("2026"),
+ autofill::CREDIT_CARD_EXP_4_DIGIT_YEAR);
+
+ // Still disabled.
+ EXPECT_FALSE(save_button->enabled());
+
+ // Set the last field.
+ SelectBillingAddress(billing_profile.guid());
+
+ // Should be good to go.
+ EXPECT_TRUE(save_button->enabled());
+
+ // Change a field to something invalid, to make sure it works both ways.
+ SetEditorTextfieldValue(base::ASCIIToUTF16("Ni!"),
+ autofill::CREDIT_CARD_NUMBER);
+
+ // Back to being disabled.
+ EXPECT_FALSE(save_button->enabled());
+}
+
} // namespace payments

Powered by Google App Engine
This is Rietveld 408576698