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

Side by Side 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, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/browser/form_structure.h" 5 #include "components/autofill/browser/form_structure.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "components/autofill/browser/autocheckout_page_meta_data.h"
10 #include "components/autofill/browser/autofill_metrics.h" 11 #include "components/autofill/browser/autofill_metrics.h"
11 #include "components/autofill/common/form_data.h" 12 #include "components/autofill/common/form_data.h"
12 #include "components/autofill/common/form_field_data.h" 13 #include "components/autofill/common/form_field_data.h"
13 #include "googleurl/src/gurl.h" 14 #include "googleurl/src/gurl.h"
14 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputElement.h" 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputElement.h"
16 17
17 using WebKit::WebInputElement; 18 using WebKit::WebInputElement;
18 19
19 namespace autofill { 20 namespace autofill {
(...skipping 2360 matching lines...) Expand 10 before | Expand all | Expand 10 after
2380 form.fields.push_back(field); 2381 form.fields.push_back(field);
2381 2382
2382 EXPECT_EQ(form, FormStructure(form, std::string()).ToFormData()); 2383 EXPECT_EQ(form, FormStructure(form, std::string()).ToFormData());
2383 2384
2384 // Currently |FormStructure(form_data)ToFormData().user_submitted| is always 2385 // Currently |FormStructure(form_data)ToFormData().user_submitted| is always
2385 // false. This forces a future author that changes this to update this test. 2386 // false. This forces a future author that changes this to update this test.
2386 form.user_submitted = true; 2387 form.user_submitted = true;
2387 EXPECT_NE(form, FormStructure(form, std::string()).ToFormData()); 2388 EXPECT_NE(form, FormStructure(form, std::string()).ToFormData());
2388 } 2389 }
2389 2390
2391 TEST(FormStructureTest, SkipFieldTest) {
2392 FormData form;
2393 form.name = ASCIIToUTF16("the-name");
2394 form.method = ASCIIToUTF16("POST");
2395 form.origin = GURL("http://cool.com");
2396 form.action = form.origin.Resolve("/login");
2397
2398 FormFieldData field;
2399 field.label = ASCIIToUTF16("username");
2400 field.name = ASCIIToUTF16("username");
2401 field.form_control_type = "text";
2402 form.fields.push_back(field);
2403
2404 field.label = ASCIIToUTF16("password");
2405 field.name = ASCIIToUTF16("password");
2406 field.form_control_type = "password";
2407 form.fields.push_back(field);
2408
2409 field.label = base::string16();
2410 field.name = ASCIIToUTF16("email");
2411 field.form_control_type = "text";
2412 form.fields.push_back(field);
2413
2414 ScopedVector<FormStructure> forms;
2415 forms.push_back(new FormStructure(form, std::string()));
2416 std::vector<std::string> encoded_signatures;
2417 std::string encoded_xml;
2418
2419 const char * const kSignature = "18006745212084723782";
2420 const char * const kResponse =
2421 "<\?xml version=\"1.0\" encoding=\"UTF-8\"?><autofillquery "
2422 "clientversion=\"6.1.1715.1442/en (GGLL)\" accepts=\"e\"><form "
2423 "signature=\"18006745212084723782\"><field signature=\"239111655\"/>"
2424 "<field signature=\"420638584\"/></form></autofillquery>";
2425 ASSERT_TRUE(FormStructure::EncodeQueryRequest(forms.get(),
2426 &encoded_signatures,
2427 &encoded_xml));
2428 ASSERT_EQ(1U, encoded_signatures.size());
2429 EXPECT_EQ(kSignature, encoded_signatures[0]);
2430 EXPECT_EQ(kResponse, encoded_xml);
2431
2432 AutocheckoutPageMetaData page_meta_data;
2433 const char * const kServerResponse =
2434 "<autofillqueryresponse><field autofilltype=\"3\" />"
2435 "<field autofilltype=\"9\" /></autofillqueryresponse>";
2436 FormStructure::ParseQueryResponse(kServerResponse, forms.get(),
2437 &page_meta_data, TestAutofillMetrics());
2438 ASSERT_EQ(NAME_FIRST, forms[0]->field(0)->server_type());
2439 ASSERT_EQ(NO_SERVER_DATA, forms[0]->field(1)->server_type());
2440 ASSERT_EQ(EMAIL_ADDRESS, forms[0]->field(2)->server_type());
2441 }
2442
2390 } // namespace autofill 2443 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698