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

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

Issue 16164003: Field's server type mapping (using Autofill server response) for forms with checkable elements/pass… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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: components/autofill/browser/form_structure_unittest.cc
diff --git a/components/autofill/browser/form_structure_unittest.cc b/components/autofill/browser/form_structure_unittest.cc
index 9fde80fb5dd4db5cb695d1fca3188c5d2356dfe3..4c6af54402bd7a77b111e83c36c2bfe13c94f7b4 100644
--- a/components/autofill/browser/form_structure_unittest.cc
+++ b/components/autofill/browser/form_structure_unittest.cc
@@ -7,6 +7,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/string_util.h"
#include "base/utf_string_conversions.h"
+#include "components/autofill/browser/autocheckout_page_meta_data.h"
#include "components/autofill/browser/autofill_metrics.h"
#include "components/autofill/common/form_data.h"
#include "components/autofill/common/form_field_data.h"
@@ -2387,4 +2388,56 @@ TEST(FormStructureTest, ToFormData) {
EXPECT_NE(form, FormStructure(form, std::string()).ToFormData());
}
+TEST(FormStructureTest, SkipFieldTest) {
+ FormData form;
+ form.name = ASCIIToUTF16("the-name");
+ form.method = ASCIIToUTF16("POST");
+ form.origin = GURL("http://cool.com");
+ form.action = form.origin.Resolve("/login");
+
+ FormFieldData field;
+ field.label = ASCIIToUTF16("username");
+ field.name = ASCIIToUTF16("username");
+ field.form_control_type = "text";
+ form.fields.push_back(field);
+
+ field.label = ASCIIToUTF16("password");
+ field.name = ASCIIToUTF16("password");
+ field.form_control_type = "password";
+ form.fields.push_back(field);
+
+ field.label = base::string16();
+ field.name = ASCIIToUTF16("email");
+ field.form_control_type = "text";
+ form.fields.push_back(field);
+
+ ScopedVector<FormStructure> forms;
+ forms.push_back(new FormStructure(form, std::string()));
+ std::vector<std::string> encoded_signatures;
+ std::string encoded_xml;
+
+ const char * const kSignature = "18006745212084723782";
+ const char * const kResponse =
+ "<\?xml version=\"1.0\" encoding=\"UTF-8\"?><autofillquery "
+ "clientversion=\"6.1.1715.1442/en (GGLL)\" accepts=\"e\"><form "
+ "signature=\"18006745212084723782\"><field signature=\"239111655\"/>"
+ "<field signature=\"420638584\"/></form></autofillquery>";
+ ASSERT_TRUE(FormStructure::EncodeQueryRequest(forms.get(),
+ &encoded_signatures,
+ &encoded_xml));
+ ASSERT_EQ(1U, encoded_signatures.size());
+ EXPECT_EQ(kSignature, encoded_signatures[0]);
+ EXPECT_EQ(kResponse, encoded_xml);
+
+ AutocheckoutPageMetaData page_meta_data;
+ const char * const kServerResponse =
+ "<autofillqueryresponse><field autofilltype=\"3\" />"
+ "<field autofilltype=\"9\" /></autofillqueryresponse>";
+ FormStructure::ParseQueryResponse(kServerResponse, forms.get(),
+ &page_meta_data, TestAutofillMetrics());
+ ASSERT_EQ(NAME_FIRST, forms[0]->field(0)->server_type());
+ ASSERT_EQ(NO_SERVER_DATA, forms[0]->field(1)->server_type());
+ ASSERT_EQ(EMAIL_ADDRESS, forms[0]->field(2)->server_type());
+}
+
} // namespace autofill

Powered by Google App Engine
This is Rietveld 408576698