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

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

Issue 2881643002: Focus first invalid field of payment request editor (Closed)
Patch Set: 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/payments/shipping_address_editor_view_controller_browsertest.cc
diff --git a/chrome/browser/ui/views/payments/shipping_address_editor_view_controller_browsertest.cc b/chrome/browser/ui/views/payments/shipping_address_editor_view_controller_browsertest.cc
index 09e70791e5500db1960e9a05fc353cf7da68f011..040b03013285b043cf131be93a462433f375cc55 100644
--- a/chrome/browser/ui/views/payments/shipping_address_editor_view_controller_browsertest.cc
+++ b/chrome/browser/ui/views/payments/shipping_address_editor_view_controller_browsertest.cc
@@ -485,12 +485,14 @@ IN_PROC_BROWSER_TEST_F(PaymentRequestShippingAddressEditorTest,
AddAutofillProfile(profile);
InvokePaymentRequestUI();
+ SetRegionDataLoader(&test_region_data_loader_);
// One shipping address is available, but it's not selected.
PaymentRequest* request = GetPaymentRequests(GetActiveWebContents()).front();
EXPECT_EQ(1U, request->state()->shipping_profiles().size());
EXPECT_EQ(nullptr, request->state()->selected_shipping_profile());
+ test_region_data_loader_.set_synchronous_callback(true);
OpenShippingAddressSectionScreen();
ResetEventObserver(DialogEvent::SHIPPING_ADDRESS_EDITOR_OPENED);
@@ -527,4 +529,49 @@ IN_PROC_BROWSER_TEST_F(PaymentRequestShippingAddressEditorTest,
request->state()->selected_shipping_profile());
}
+IN_PROC_BROWSER_TEST_F(PaymentRequestShippingAddressEditorTest,
+ FocusFirstInvalidField_Name) {
+ InvokePaymentRequestUI();
+ SetRegionDataLoader(&test_region_data_loader_);
+
+ test_region_data_loader_.set_synchronous_callback(true);
+ OpenShippingAddressEditorScreen();
+
+ // We know that the name field is always the first one in a shipping address.
+ views::Textfield* textfield = static_cast<views::Textfield*>(
+ dialog_view()->GetViewByID(static_cast<int>(autofill::NAME_FULL)));
+ DCHECK(textfield);
+ EXPECT_TRUE(textfield->text().empty());
+ EXPECT_TRUE(textfield->invalid());
+ EXPECT_TRUE(textfield->HasFocus());
+}
+
+IN_PROC_BROWSER_TEST_F(PaymentRequestShippingAddressEditorTest,
+ FocusFirstInvalidField_NotName) {
+ // Add address with the name set, so that another views takes focus.
+ autofill::AutofillProfile profile;
+ profile.SetInfo(autofill::AutofillType(autofill::NAME_FULL),
+ base::ASCIIToUTF16(kNameFull), "fr_CA");
+ AddAutofillProfile(profile);
+
+ InvokePaymentRequestUI();
+ SetRegionDataLoader(&test_region_data_loader_);
+ test_region_data_loader_.set_synchronous_callback(true);
+ OpenShippingAddressSectionScreen();
+ ResetEventObserver(DialogEvent::SHIPPING_ADDRESS_EDITOR_OPENED);
+ ClickOnChildInListViewAndWait(/*child_index=*/0, /*num_children=*/1,
+ DialogViewID::SHIPPING_ADDRESS_SHEET_LIST_VIEW);
+
+ views::Textfield* textfield = static_cast<views::Textfield*>(
+ dialog_view()->GetViewByID(static_cast<int>(autofill::NAME_FULL)));
+ DCHECK(textfield);
+ EXPECT_FALSE(textfield->text().empty());
+ EXPECT_FALSE(textfield->invalid());
+ EXPECT_FALSE(textfield->HasFocus());
+
+ // Since we can't easily tell which field is after name, let's just make sure
+ // that it is an invalid field.
+ EXPECT_NE(textfield->GetFocusManager()->GetFocusedView(), nullptr);
+}
+
} // namespace payments

Powered by Google App Engine
This is Rietveld 408576698