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

Unified Diff: chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc

Issue 58683002: rAc: fix validation logic when autofill completion sets country (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix filling as well as validation Created 7 years, 1 month 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/autofill/autofill_dialog_controller_browsertest.cc
diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc b/chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc
index 36f9283b4a0e4dbbd71882617c918418abc923b6..6891278af28b3897cac8fec66d0653aec6979eec 100644
--- a/chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc
+++ b/chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc
@@ -492,6 +492,64 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, FillInputFromAutofill) {
}
}
+// For now, no matter what, the country must always be US. See
+// http://crbug.com/247518
+IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest,
+ FillInputFromForeignProfile) {
+ AutofillProfile full_profile(test::GetFullProfile());
+ full_profile.SetInfo(AutofillType(ADDRESS_HOME_COUNTRY),
+ ASCIIToUTF16("France"), "en-US");
+ controller()->GetTestingManager()->AddTestingProfile(&full_profile);
+
+ const DetailInputs& inputs =
+ controller()->RequestedFieldsForSection(SECTION_SHIPPING);
+ const DetailInput& triggering_input = inputs[0];
+ string16 value = full_profile.GetRawInfo(triggering_input.type);
Dan Beam 2013/11/05 02:54:43 nit: base::string16 in new code (or using base::st
+ TestableAutofillDialogView* view = controller()->GetTestableView();
+ view->SetTextContentsOfInput(triggering_input,
+ value.substr(0, value.size() / 2));
+ view->ActivateInput(triggering_input);
+
+ ASSERT_EQ(&triggering_input, controller()->input_showing_popup());
+ controller()->DidAcceptSuggestion(string16(), 0);
+
+ // All inputs should be filled.
+ AutofillProfileWrapper wrapper(&full_profile);
+ for (size_t i = 0; i < inputs.size(); ++i) {
+ string16 expectation =
+ AutofillType(inputs[i].type).GetStorableType() == ADDRESS_HOME_COUNTRY ?
+ ASCIIToUTF16("United States") :
+ wrapper.GetInfo(AutofillType(inputs[i].type));
+ EXPECT_EQ(expectation, view->GetTextContentsOfInput(inputs[i]));
+ }
+
+ // Now simulate some user edits and try again.
+ std::vector<string16> expectations;
+ for (size_t i = 0; i < inputs.size(); ++i) {
+ string16 users_input = i % 2 == 0 ? string16() : ASCIIToUTF16("dummy");
+ view->SetTextContentsOfInput(inputs[i], users_input);
+ // Empty inputs should be filled, others should be left alone.
+ string16 expectation =
+ &inputs[i] == &triggering_input || users_input.empty() ?
+ wrapper.GetInfo(AutofillType(inputs[i].type)) :
+ users_input;
+ if (AutofillType(inputs[i].type).GetStorableType() == ADDRESS_HOME_COUNTRY)
+ expectation = ASCIIToUTF16("United States");
+
+ expectations.push_back(expectation);
+ }
+
+ view->SetTextContentsOfInput(triggering_input,
+ value.substr(0, value.size() / 2));
+ view->ActivateInput(triggering_input);
+ ASSERT_EQ(&triggering_input, controller()->input_showing_popup());
+ controller()->DidAcceptSuggestion(string16(), 0);
+
+ for (size_t i = 0; i < inputs.size(); ++i) {
+ EXPECT_EQ(expectations[i], view->GetTextContentsOfInput(inputs[i]));
+ }
+}
+
// This test makes sure that picking a profile variant in the Autofill
// popup works as expected.
IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest,

Powered by Google App Engine
This is Rietveld 408576698