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

Side by Side 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, 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 unified diff | Download patch
« no previous file with comments | « components/autofill/core/browser/form_structure.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/autofill/core/browser/form_structure.h" 5 #include "components/autofill/core/browser/form_structure.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/metrics/field_trial.h" 9 #include "base/metrics/field_trial.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 1942 matching lines...) Expand 10 before | Expand all | Expand 10 after
1953 " formsignature=\"6949133589768631292\" autofillused=\"true\"" 1953 " formsignature=\"6949133589768631292\" autofillused=\"true\""
1954 " datapresent=\"1440\"" 1954 " datapresent=\"1440\""
1955 " actionsignature=\"15724779818122431245\">" 1955 " actionsignature=\"15724779818122431245\">"
1956 "<field signature=\"1318412689\" type=\"text\" autofilltype=\"3\"/>" 1956 "<field signature=\"1318412689\" type=\"text\" autofilltype=\"3\"/>"
1957 "<field signature=\"1318412689\" type=\"text\" label=\"Last Name\"" 1957 "<field signature=\"1318412689\" type=\"text\" label=\"Last Name\""
1958 " autofilltype=\"5\"/><field signature=\"1318412689\" type=\"text\"" 1958 " autofilltype=\"5\"/><field signature=\"1318412689\" type=\"text\""
1959 " label=\"Email\" autofilltype=\"9\"/></autofillupload>", 1959 " label=\"Email\" autofilltype=\"9\"/></autofillupload>",
1960 encoded_xml); 1960 encoded_xml);
1961 } 1961 }
1962 1962
1963 // Test that the form name is sent in the upload request.
1964 TEST_F(FormStructureTest, EncodeUploadRequest_WithFormName) {
1965 scoped_ptr<FormStructure> form_structure;
1966 std::vector<ServerFieldTypeSet> possible_field_types;
1967 FormData form;
1968 // Setting the form name which we expect to see in the upload.
1969 form.name = base::ASCIIToUTF16("myform");
1970 form_structure.reset(new FormStructure(form));
1971 form_structure->DetermineHeuristicTypes();
1972
1973 FormFieldData field;
1974 field.form_control_type = "text";
1975
1976 form.fields.push_back(field);
1977 possible_field_types.push_back(ServerFieldTypeSet());
1978 possible_field_types.back().insert(NAME_FIRST);
1979
1980 form.fields.push_back(field);
1981 possible_field_types.push_back(ServerFieldTypeSet());
1982 possible_field_types.back().insert(NAME_LAST);
1983
1984 form.fields.push_back(field);
1985 possible_field_types.push_back(ServerFieldTypeSet());
1986 possible_field_types.back().insert(EMAIL_ADDRESS);
1987
1988 form_structure.reset(new FormStructure(form));
1989
1990 ASSERT_EQ(form_structure->field_count(), possible_field_types.size());
1991 for (size_t i = 0; i < form_structure->field_count(); ++i)
1992 form_structure->field(i)->set_possible_types(possible_field_types[i]);
1993
1994 ServerFieldTypeSet available_field_types;
1995 available_field_types.insert(NAME_FIRST);
1996 available_field_types.insert(NAME_LAST);
1997 available_field_types.insert(EMAIL_ADDRESS);
1998
1999 std::string encoded_xml;
2000 EXPECT_TRUE(form_structure->EncodeUploadRequest(available_field_types, true,
2001 std::string(), &encoded_xml));
2002 EXPECT_EQ("<?xml version=\"1.0\" encoding=\"UTF-8\"?><autofillupload"
2003 " clientversion=\"6.1.1715.1442/en (GGLL)\""
2004 " formsignature=\"2345951786066580868\" autofillused=\"true\""
2005 " datapresent=\"1440\" actionsignature=\"15724779818122431245\""
2006 " formname=\"myform\"><field signature=\"1318412689\" type=\"text\""
2007 " autofilltype=\"3\"/><field signature=\"1318412689\" type=\"text\""
2008 " autofilltype=\"5\"/><field signature=\"1318412689\" type=\"text\""
2009 " autofilltype=\"9\"/></autofillupload>",
2010 encoded_xml);
2011 }
2012
1963 TEST_F(FormStructureTest, EncodeUploadRequestPartialMetadata) { 2013 TEST_F(FormStructureTest, EncodeUploadRequestPartialMetadata) {
1964 scoped_ptr<FormStructure> form_structure; 2014 scoped_ptr<FormStructure> form_structure;
1965 std::vector<ServerFieldTypeSet> possible_field_types; 2015 std::vector<ServerFieldTypeSet> possible_field_types;
1966 FormData form; 2016 FormData form;
1967 form_structure.reset(new FormStructure(form)); 2017 form_structure.reset(new FormStructure(form));
1968 form_structure->DetermineHeuristicTypes(); 2018 form_structure->DetermineHeuristicTypes();
1969 2019
1970 FormFieldData field; 2020 FormFieldData field;
1971 field.form_control_type = "text"; 2021 field.form_control_type = "text";
1972 2022
(...skipping 1054 matching lines...) Expand 10 before | Expand all | Expand 10 after
3027 "</autofillqueryresponse>"; 3077 "</autofillqueryresponse>";
3028 3078
3029 FormStructure::ParseQueryResponse(response, forms.get(), nullptr); 3079 FormStructure::ParseQueryResponse(response, forms.get(), nullptr);
3030 3080
3031 ASSERT_GE(forms[0]->field_count(), 2U); 3081 ASSERT_GE(forms[0]->field_count(), 2U);
3032 EXPECT_EQ(NO_SERVER_DATA, forms[0]->field(0)->server_type()); 3082 EXPECT_EQ(NO_SERVER_DATA, forms[0]->field(0)->server_type());
3033 EXPECT_EQ(76, forms[0]->field(1)->server_type()); 3083 EXPECT_EQ(76, forms[0]->field(1)->server_type());
3034 } 3084 }
3035 3085
3036 } // namespace autofill 3086 } // namespace autofill
OLDNEW
« 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