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

Unified Diff: components/autofill/core/browser/autofill_manager_unittest.cc

Issue 2796873002: Sending autofill types for username fields in sign-in forms for improving username detection. (Closed)
Patch Set: Fix compilation error Created 3 years, 8 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: components/autofill/core/browser/autofill_manager_unittest.cc
diff --git a/components/autofill/core/browser/autofill_manager_unittest.cc b/components/autofill/core/browser/autofill_manager_unittest.cc
index 2fbe6fce536c47abdfa22f70bfd3c90b1612a07e..34bdd02ef311740ebecfcb5bd2ca7f9846c01ec6 100644
--- a/components/autofill/core/browser/autofill_manager_unittest.cc
+++ b/components/autofill/core/browser/autofill_manager_unittest.cc
@@ -5899,4 +5899,48 @@ TEST_F(AutofillManagerTest, FormWithLongOptionValuesIsAcceptable) {
}
}
+// Test that a sign-in form submission sends an upload with types matching the
+// fields.
+TEST_F(AutofillManagerTest, SignInFormSubmission_Upload) {
+ // Set up our form data (it's already filled out with user data).
+ FormData form;
+ form.origin = GURL("http://myform.com/form.html");
+ form.action = GURL("http://myform.com/submit.html");
+
+ std::vector<ServerFieldTypeSet> expected_types;
+ ServerFieldTypeSet types;
+
+ FormFieldData field;
+ test::CreateTestFormField("Email", "email", "theking@gmail.com", "text",
+ &field);
+ form.fields.push_back(field);
+ types.insert(EMAIL_ADDRESS);
+ expected_types.push_back(types);
+
+ test::CreateTestFormField("Password", "pw", "secret", "password", &field);
+ form.fields.push_back(field);
+ types.clear();
+ types.insert(PASSWORD);
+ expected_types.push_back(types);
+
+ // We will expect these types in the upload and no observed submission. (the
+ // callback initiated by WaitForAsyncUploadProcess checks these expectations.)
+ autofill_manager_->set_expected_submitted_field_types(expected_types);
+ autofill_manager_->set_expected_observed_submission(true);
+ autofill_manager_->ResetRunLoop();
+
+ std::unique_ptr<FormStructure> form_structure(new FormStructure(form));
+ form_structure->set_is_signin_upload(true);
+ form_structure->field(1)->set_possible_types({autofill::PASSWORD});
+
+ std::string signature = form_structure->FormSignatureAsStr();
+ autofill_manager_->StartUploadProcess(std::move(form_structure),
+ base::TimeTicks::Now(), true);
+
+ // Wait for upload to complete (will check expected types as well).
+ autofill_manager_->WaitForAsyncUploadProcess();
+
+ EXPECT_EQ(signature, autofill_manager_->GetSubmittedFormSignature());
+}
+
} // namespace autofill
« no previous file with comments | « components/autofill/core/browser/autofill_manager.cc ('k') | components/autofill/core/browser/form_structure.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698