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

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

Issue 1422853003: [Autofill] Send the form name in Autofill uploads where metadata is collected. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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
« no previous file with comments | « components/autofill/core/browser/form_structure.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/autofill/core/browser/form_structure_unittest.cc
diff --git a/components/autofill/core/browser/form_structure_unittest.cc b/components/autofill/core/browser/form_structure_unittest.cc
index 2746a0ead65562756877e9c9511ad025ae18fc69..5a0cb53bdeb142b8c79c26956d3808a4ff800e95 100644
--- a/components/autofill/core/browser/form_structure_unittest.cc
+++ b/components/autofill/core/browser/form_structure_unittest.cc
@@ -1960,6 +1960,56 @@ TEST_F(FormStructureTest, EncodeUploadRequest_WithLabels) {
encoded_xml);
}
+// Test that the form name is sent in the upload request.
+TEST_F(FormStructureTest, EncodeUploadRequest_WithFormName) {
+ scoped_ptr<FormStructure> form_structure;
+ std::vector<ServerFieldTypeSet> possible_field_types;
+ FormData form;
+ // Setting the form name which we expect to see in the upload.
+ form.name = base::ASCIIToUTF16("myform");
+ form_structure.reset(new FormStructure(form));
+ form_structure->DetermineHeuristicTypes();
+
+ FormFieldData field;
+ field.form_control_type = "text";
+
+ form.fields.push_back(field);
+ possible_field_types.push_back(ServerFieldTypeSet());
+ possible_field_types.back().insert(NAME_FIRST);
+
+ form.fields.push_back(field);
+ possible_field_types.push_back(ServerFieldTypeSet());
+ possible_field_types.back().insert(NAME_LAST);
+
+ form.fields.push_back(field);
+ possible_field_types.push_back(ServerFieldTypeSet());
+ possible_field_types.back().insert(EMAIL_ADDRESS);
+
+ form_structure.reset(new FormStructure(form));
+
+ ASSERT_EQ(form_structure->field_count(), possible_field_types.size());
+ for (size_t i = 0; i < form_structure->field_count(); ++i)
+ form_structure->field(i)->set_possible_types(possible_field_types[i]);
+
+ ServerFieldTypeSet available_field_types;
+ available_field_types.insert(NAME_FIRST);
+ available_field_types.insert(NAME_LAST);
+ available_field_types.insert(EMAIL_ADDRESS);
+
+ std::string encoded_xml;
+ EXPECT_TRUE(form_structure->EncodeUploadRequest(available_field_types, true,
+ std::string(), &encoded_xml));
+ EXPECT_EQ("<?xml version=\"1.0\" encoding=\"UTF-8\"?><autofillupload"
+ " clientversion=\"6.1.1715.1442/en (GGLL)\""
+ " formsignature=\"2345951786066580868\" autofillused=\"true\""
+ " datapresent=\"1440\" actionsignature=\"15724779818122431245\""
+ " formname=\"myform\"><field signature=\"1318412689\" type=\"text\""
+ " autofilltype=\"3\"/><field signature=\"1318412689\" type=\"text\""
+ " autofilltype=\"5\"/><field signature=\"1318412689\" type=\"text\""
+ " autofilltype=\"9\"/></autofillupload>",
+ encoded_xml);
+}
+
TEST_F(FormStructureTest, EncodeUploadRequestPartialMetadata) {
scoped_ptr<FormStructure> form_structure;
std::vector<ServerFieldTypeSet> possible_field_types;
« no previous file with comments | « components/autofill/core/browser/form_structure.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698