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

Side by Side Diff: components/autofill/core/browser/form_structure_unittest.cc

Issue 2776223002: Adds UKM for autofill attributes in form_structure. (Closed)
Patch Set: Resolves merge conflicts with FORM_CONTAINS_UPI_VPA_HINT. 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 unified diff | Download patch
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 field.form_control_type = "select-one"; 142 field.form_control_type = "select-one";
143 form.fields.push_back(field); 143 form.fields.push_back(field);
144 144
145 field.label = base::string16(); 145 field.label = base::string16();
146 field.name = ASCIIToUTF16("Submit"); 146 field.name = ASCIIToUTF16("Submit");
147 field.form_control_type = "submit"; 147 field.form_control_type = "submit";
148 form.fields.push_back(field); 148 form.fields.push_back(field);
149 149
150 // Only text and select fields that are heuristically matched are counted. 150 // Only text and select fields that are heuristically matched are counted.
151 form_structure.reset(new FormStructure(form)); 151 form_structure.reset(new FormStructure(form));
152 form_structure->DetermineHeuristicTypes(); 152 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */);
153 EXPECT_EQ(3U, form_structure->autofill_count()); 153 EXPECT_EQ(3U, form_structure->autofill_count());
154 154
155 // Add a field with should_autocomplete=false. This should not be considered a 155 // Add a field with should_autocomplete=false. This should not be considered a
156 // fillable field. 156 // fillable field.
157 field.label = ASCIIToUTF16("address1"); 157 field.label = ASCIIToUTF16("address1");
158 field.name = ASCIIToUTF16("address1"); 158 field.name = ASCIIToUTF16("address1");
159 field.form_control_type = "text"; 159 field.form_control_type = "text";
160 field.should_autocomplete = false; 160 field.should_autocomplete = false;
161 form.fields.push_back(field); 161 form.fields.push_back(field);
162 162
163 form_structure.reset(new FormStructure(form)); 163 form_structure.reset(new FormStructure(form));
164 form_structure->DetermineHeuristicTypes(); 164 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */);
165 EXPECT_EQ(4U, form_structure->autofill_count()); 165 EXPECT_EQ(4U, form_structure->autofill_count());
166 } 166 }
167 167
168 TEST_F(FormStructureTest, SourceURL) { 168 TEST_F(FormStructureTest, SourceURL) {
169 FormData form; 169 FormData form;
170 form.origin = GURL("http://www.foo.com/"); 170 form.origin = GURL("http://www.foo.com/");
171 FormStructure form_structure(form); 171 FormStructure form_structure(form);
172 172
173 EXPECT_EQ(form.origin, form_structure.source_url()); 173 EXPECT_EQ(form.origin, form_structure.source_url());
174 } 174 }
(...skipping 14 matching lines...) Expand all
189 field.name = ASCIIToUTF16("password"); 189 field.name = ASCIIToUTF16("password");
190 field.form_control_type = "password"; 190 field.form_control_type = "password";
191 form.fields.push_back(field); 191 form.fields.push_back(field);
192 192
193 field.label = base::string16(); 193 field.label = base::string16();
194 field.name = ASCIIToUTF16("Submit"); 194 field.name = ASCIIToUTF16("Submit");
195 field.form_control_type = "submit"; 195 field.form_control_type = "submit";
196 form.fields.push_back(field); 196 form.fields.push_back(field);
197 197
198 form_structure.reset(new FormStructure(form)); 198 form_structure.reset(new FormStructure(form));
199 form_structure->DetermineHeuristicTypes(); 199 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */);
200 EXPECT_FALSE(form_structure->IsAutofillable()); 200 EXPECT_FALSE(form_structure->IsAutofillable());
201 201
202 // We now have three text fields, but only two auto-fillable fields. 202 // We now have three text fields, but only two auto-fillable fields.
203 field.label = ASCIIToUTF16("First Name"); 203 field.label = ASCIIToUTF16("First Name");
204 field.name = ASCIIToUTF16("firstname"); 204 field.name = ASCIIToUTF16("firstname");
205 field.form_control_type = "text"; 205 field.form_control_type = "text";
206 form.fields.push_back(field); 206 form.fields.push_back(field);
207 207
208 field.label = ASCIIToUTF16("Last Name"); 208 field.label = ASCIIToUTF16("Last Name");
209 field.name = ASCIIToUTF16("lastname"); 209 field.name = ASCIIToUTF16("lastname");
210 field.form_control_type = "text"; 210 field.form_control_type = "text";
211 form.fields.push_back(field); 211 form.fields.push_back(field);
212 212
213 form_structure.reset(new FormStructure(form)); 213 form_structure.reset(new FormStructure(form));
214 form_structure->DetermineHeuristicTypes(); 214 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */);
215 EXPECT_FALSE(form_structure->IsAutofillable()); 215 EXPECT_FALSE(form_structure->IsAutofillable());
216 216
217 // We now have three auto-fillable fields. 217 // We now have three auto-fillable fields.
218 field.label = ASCIIToUTF16("Email"); 218 field.label = ASCIIToUTF16("Email");
219 field.name = ASCIIToUTF16("email"); 219 field.name = ASCIIToUTF16("email");
220 field.form_control_type = "email"; 220 field.form_control_type = "email";
221 form.fields.push_back(field); 221 form.fields.push_back(field);
222 222
223 form_structure.reset(new FormStructure(form)); 223 form_structure.reset(new FormStructure(form));
224 form_structure->DetermineHeuristicTypes(); 224 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */);
225 EXPECT_TRUE(form_structure->IsAutofillable()); 225 EXPECT_TRUE(form_structure->IsAutofillable());
226 226
227 // The target cannot include http(s)://*/search... 227 // The target cannot include http(s)://*/search...
228 form.action = GURL("http://google.com/search?q=hello"); 228 form.action = GURL("http://google.com/search?q=hello");
229 form_structure.reset(new FormStructure(form)); 229 form_structure.reset(new FormStructure(form));
230 form_structure->DetermineHeuristicTypes(); 230 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */);
231 EXPECT_FALSE(form_structure->IsAutofillable()); 231 EXPECT_FALSE(form_structure->IsAutofillable());
232 232
233 // But search can be in the URL. 233 // But search can be in the URL.
234 form.action = GURL("http://search.com/?q=hello"); 234 form.action = GURL("http://search.com/?q=hello");
235 form_structure.reset(new FormStructure(form)); 235 form_structure.reset(new FormStructure(form));
236 form_structure->DetermineHeuristicTypes(); 236 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */);
237 EXPECT_TRUE(form_structure->IsAutofillable()); 237 EXPECT_TRUE(form_structure->IsAutofillable());
238 } 238 }
239 239
240 TEST_F(FormStructureTest, ShouldBeParsed) { 240 TEST_F(FormStructureTest, ShouldBeParsed) {
241 std::unique_ptr<FormStructure> form_structure; 241 std::unique_ptr<FormStructure> form_structure;
242 FormData form; 242 FormData form;
243 243
244 // We need at least three text fields to be parseable. 244 // We need at least three text fields to be parseable.
245 FormFieldData field; 245 FormFieldData field;
246 field.label = ASCIIToUTF16("username"); 246 field.label = ASCIIToUTF16("username");
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 field.label = ASCIIToUTF16("Zip code"); 398 field.label = ASCIIToUTF16("Zip code");
399 field.name = ASCIIToUTF16("zipcode"); 399 field.name = ASCIIToUTF16("zipcode");
400 form.fields.push_back(field); 400 form.fields.push_back(field);
401 401
402 field.label = base::string16(); 402 field.label = base::string16();
403 field.name = ASCIIToUTF16("Submit"); 403 field.name = ASCIIToUTF16("Submit");
404 field.form_control_type = "submit"; 404 field.form_control_type = "submit";
405 form.fields.push_back(field); 405 form.fields.push_back(field);
406 406
407 form_structure.reset(new FormStructure(form)); 407 form_structure.reset(new FormStructure(form));
408 form_structure->DetermineHeuristicTypes(); 408 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */);
409 EXPECT_TRUE(form_structure->IsAutofillable()); 409 EXPECT_TRUE(form_structure->IsAutofillable());
410 410
411 // Expect the correct number of fields. 411 // Expect the correct number of fields.
412 ASSERT_EQ(9U, form_structure->field_count()); 412 ASSERT_EQ(9U, form_structure->field_count());
413 ASSERT_EQ(8U, form_structure->autofill_count()); 413 ASSERT_EQ(8U, form_structure->autofill_count());
414 414
415 // First name. 415 // First name.
416 EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type()); 416 EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type());
417 // Last name. 417 // Last name.
418 EXPECT_EQ(NAME_LAST, form_structure->field(1)->heuristic_type()); 418 EXPECT_EQ(NAME_LAST, form_structure->field(1)->heuristic_type());
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 field.name = ASCIIToUTF16("field3"); 455 field.name = ASCIIToUTF16("field3");
456 field.autocomplete_attribute = "email"; 456 field.autocomplete_attribute = "email";
457 form.fields.push_back(field); 457 form.fields.push_back(field);
458 458
459 field.label = base::string16(); 459 field.label = base::string16();
460 field.name = ASCIIToUTF16("field4"); 460 field.name = ASCIIToUTF16("field4");
461 field.autocomplete_attribute = "upi-vpa"; 461 field.autocomplete_attribute = "upi-vpa";
462 form.fields.push_back(field); 462 form.fields.push_back(field);
463 463
464 form_structure.reset(new FormStructure(form)); 464 form_structure.reset(new FormStructure(form));
465 form_structure->DetermineHeuristicTypes(); 465 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */);
466 EXPECT_TRUE(form_structure->IsAutofillable()); 466 EXPECT_TRUE(form_structure->IsAutofillable());
467 EXPECT_TRUE(form_structure->has_author_specified_types()); 467 EXPECT_TRUE(form_structure->has_author_specified_types());
468 EXPECT_TRUE(form_structure->has_author_specified_upi_vpa_hint()); 468 EXPECT_TRUE(form_structure->has_author_specified_upi_vpa_hint());
469 469
470 // Expect the correct number of fields. 470 // Expect the correct number of fields.
471 ASSERT_EQ(4U, form_structure->field_count()); 471 ASSERT_EQ(4U, form_structure->field_count());
472 ASSERT_EQ(3U, form_structure->autofill_count()); 472 ASSERT_EQ(3U, form_structure->autofill_count());
473 473
474 EXPECT_EQ(HTML_TYPE_GIVEN_NAME, form_structure->field(0)->html_type()); 474 EXPECT_EQ(HTML_TYPE_GIVEN_NAME, form_structure->field(0)->html_type());
475 EXPECT_EQ(HTML_TYPE_FAMILY_NAME, form_structure->field(1)->html_type()); 475 EXPECT_EQ(HTML_TYPE_FAMILY_NAME, form_structure->field(1)->html_type());
(...skipping 22 matching lines...) Expand all
498 field.name = ASCIIToUTF16("lastname"); 498 field.name = ASCIIToUTF16("lastname");
499 field.autocomplete_attribute = "family-name"; 499 field.autocomplete_attribute = "family-name";
500 form.fields.push_back(field); 500 form.fields.push_back(field);
501 501
502 field.label = ASCIIToUTF16("Email:"); 502 field.label = ASCIIToUTF16("Email:");
503 field.name = ASCIIToUTF16("email"); 503 field.name = ASCIIToUTF16("email");
504 field.autocomplete_attribute = "email"; 504 field.autocomplete_attribute = "email";
505 form.fields.push_back(field); 505 form.fields.push_back(field);
506 506
507 form_structure.reset(new FormStructure(form)); 507 form_structure.reset(new FormStructure(form));
508 form_structure->DetermineHeuristicTypes(); 508 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */);
509 EXPECT_TRUE(form_structure->IsAutofillable()); 509 EXPECT_TRUE(form_structure->IsAutofillable());
510 510
511 // Expect the correct number of fields. 511 // Expect the correct number of fields.
512 ASSERT_EQ(3U, form_structure->field_count()); 512 ASSERT_EQ(3U, form_structure->field_count());
513 ASSERT_EQ(3U, form_structure->autofill_count()); 513 ASSERT_EQ(3U, form_structure->autofill_count());
514 514
515 // The heuristic type should be good. 515 // The heuristic type should be good.
516 EXPECT_EQ(HTML_TYPE_GIVEN_NAME, form_structure->field(0)->html_type()); 516 EXPECT_EQ(HTML_TYPE_GIVEN_NAME, form_structure->field(0)->html_type());
517 EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type()); 517 EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type());
518 518
519 // Set the form as a formless non checkout form. 519 // Set the form as a formless non checkout form.
520 form.is_formless_checkout = false; 520 form.is_formless_checkout = false;
521 form.is_form_tag = false; 521 form.is_form_tag = false;
522 522
523 form_structure.reset(new FormStructure(form)); 523 form_structure.reset(new FormStructure(form));
524 form_structure->DetermineHeuristicTypes(); 524 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */);
525 EXPECT_TRUE(form_structure->IsAutofillable()); 525 EXPECT_TRUE(form_structure->IsAutofillable());
526 526
527 // Expect the correct number of fields. 527 // Expect the correct number of fields.
528 ASSERT_EQ(3U, form_structure->field_count()); 528 ASSERT_EQ(3U, form_structure->field_count());
529 ASSERT_EQ(3U, form_structure->autofill_count()); 529 ASSERT_EQ(3U, form_structure->autofill_count());
530 530
531 // The heuristic type should be Unknown. 531 // The heuristic type should be Unknown.
532 EXPECT_EQ(HTML_TYPE_GIVEN_NAME, form_structure->field(0)->html_type()); 532 EXPECT_EQ(HTML_TYPE_GIVEN_NAME, form_structure->field(0)->html_type());
533 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(0)->heuristic_type()); 533 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(0)->heuristic_type());
534 } 534 }
(...skipping 20 matching lines...) Expand all
555 field.label = ASCIIToUTF16("Phone"); 555 field.label = ASCIIToUTF16("Phone");
556 field.name = ASCIIToUTF16("ctl01$ctl00$ShippingAddressCreditPhone$phone"); 556 field.name = ASCIIToUTF16("ctl01$ctl00$ShippingAddressCreditPhone$phone");
557 form.fields.push_back(field); 557 form.fields.push_back(field);
558 558
559 field.label = base::string16(); 559 field.label = base::string16();
560 field.name = ASCIIToUTF16("ctl01$ctl00$ShippingAddressCreditPhone$submit"); 560 field.name = ASCIIToUTF16("ctl01$ctl00$ShippingAddressCreditPhone$submit");
561 field.form_control_type = "submit"; 561 field.form_control_type = "submit";
562 form.fields.push_back(field); 562 form.fields.push_back(field);
563 563
564 std::unique_ptr<FormStructure> form_structure(new FormStructure(form)); 564 std::unique_ptr<FormStructure> form_structure(new FormStructure(form));
565 form_structure->DetermineHeuristicTypes(); 565 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */);
566 EXPECT_TRUE(form_structure->IsAutofillable()); 566 EXPECT_TRUE(form_structure->IsAutofillable());
567 567
568 // Expect the correct number of fields. 568 // Expect the correct number of fields.
569 ASSERT_EQ(5U, form_structure->field_count()); 569 ASSERT_EQ(5U, form_structure->field_count());
570 ASSERT_EQ(4U, form_structure->autofill_count()); 570 ASSERT_EQ(4U, form_structure->autofill_count());
571 571
572 // First name. 572 // First name.
573 EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type()); 573 EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type());
574 // Last name. 574 // Last name.
575 EXPECT_EQ(NAME_LAST, form_structure->field(1)->heuristic_type()); 575 EXPECT_EQ(NAME_LAST, form_structure->field(1)->heuristic_type());
(...skipping 19 matching lines...) Expand all
595 595
596 field.label = ASCIIToUTF16("Address 2"); 596 field.label = ASCIIToUTF16("Address 2");
597 field.name = ASCIIToUTF16("address2"); 597 field.name = ASCIIToUTF16("address2");
598 form.fields.push_back(field); 598 form.fields.push_back(field);
599 599
600 field.label = ASCIIToUTF16("Address 3"); 600 field.label = ASCIIToUTF16("Address 3");
601 field.name = ASCIIToUTF16("address3"); 601 field.name = ASCIIToUTF16("address3");
602 form.fields.push_back(field); 602 form.fields.push_back(field);
603 603
604 std::unique_ptr<FormStructure> form_structure(new FormStructure(form)); 604 std::unique_ptr<FormStructure> form_structure(new FormStructure(form));
605 form_structure->DetermineHeuristicTypes(); 605 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */);
606 EXPECT_TRUE(form_structure->IsAutofillable()); 606 EXPECT_TRUE(form_structure->IsAutofillable());
607 607
608 // Expect the correct number of fields. 608 // Expect the correct number of fields.
609 ASSERT_EQ(3U, form_structure->field_count()); 609 ASSERT_EQ(3U, form_structure->field_count());
610 ASSERT_EQ(3U, form_structure->autofill_count()); 610 ASSERT_EQ(3U, form_structure->autofill_count());
611 611
612 // Address 1. 612 // Address 1.
613 EXPECT_EQ(ADDRESS_HOME_LINE1, form_structure->field(0)->heuristic_type()); 613 EXPECT_EQ(ADDRESS_HOME_LINE1, form_structure->field(0)->heuristic_type());
614 // Address 2. 614 // Address 2.
615 EXPECT_EQ(ADDRESS_HOME_LINE2, form_structure->field(1)->heuristic_type()); 615 EXPECT_EQ(ADDRESS_HOME_LINE2, form_structure->field(1)->heuristic_type());
(...skipping 15 matching lines...) Expand all
631 field.label = ASCIIToUTF16("Expiration"); 631 field.label = ASCIIToUTF16("Expiration");
632 field.name = ASCIIToUTF16("cc_exp"); 632 field.name = ASCIIToUTF16("cc_exp");
633 form.fields.push_back(field); 633 form.fields.push_back(field);
634 634
635 // Another field to reach the minimum 3. 635 // Another field to reach the minimum 3.
636 field.label = ASCIIToUTF16("Zip"); 636 field.label = ASCIIToUTF16("Zip");
637 field.name = ASCIIToUTF16("zip"); 637 field.name = ASCIIToUTF16("zip");
638 form.fields.push_back(field); 638 form.fields.push_back(field);
639 639
640 form_structure.reset(new FormStructure(form)); 640 form_structure.reset(new FormStructure(form));
641 form_structure->DetermineHeuristicTypes(); 641 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */);
642 642
643 EXPECT_TRUE(form_structure->IsCompleteCreditCardForm()); 643 EXPECT_TRUE(form_structure->IsCompleteCreditCardForm());
644 } 644 }
645 645
646 TEST_F(FormStructureTest, IsCompleteCreditCardForm_Full) { 646 TEST_F(FormStructureTest, IsCompleteCreditCardForm_Full) {
647 std::unique_ptr<FormStructure> form_structure; 647 std::unique_ptr<FormStructure> form_structure;
648 FormData form; 648 FormData form;
649 649
650 FormFieldData field; 650 FormFieldData field;
651 field.form_control_type = "text"; 651 field.form_control_type = "text";
(...skipping 17 matching lines...) Expand all
669 field.label = ASCIIToUTF16("Verification"); 669 field.label = ASCIIToUTF16("Verification");
670 field.name = ASCIIToUTF16("verification"); 670 field.name = ASCIIToUTF16("verification");
671 form.fields.push_back(field); 671 form.fields.push_back(field);
672 672
673 field.label = base::string16(); 673 field.label = base::string16();
674 field.name = ASCIIToUTF16("Submit"); 674 field.name = ASCIIToUTF16("Submit");
675 field.form_control_type = "submit"; 675 field.form_control_type = "submit";
676 form.fields.push_back(field); 676 form.fields.push_back(field);
677 677
678 form_structure.reset(new FormStructure(form)); 678 form_structure.reset(new FormStructure(form));
679 form_structure->DetermineHeuristicTypes(); 679 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */);
680 680
681 EXPECT_TRUE(form_structure->IsCompleteCreditCardForm()); 681 EXPECT_TRUE(form_structure->IsCompleteCreditCardForm());
682 } 682 }
683 683
684 // A form with only the credit card number is not considered sufficient. 684 // A form with only the credit card number is not considered sufficient.
685 TEST_F(FormStructureTest, IsCompleteCreditCardForm_OnlyCCNumber) { 685 TEST_F(FormStructureTest, IsCompleteCreditCardForm_OnlyCCNumber) {
686 std::unique_ptr<FormStructure> form_structure; 686 std::unique_ptr<FormStructure> form_structure;
687 FormData form; 687 FormData form;
688 688
689 FormFieldData field; 689 FormFieldData field;
690 field.form_control_type = "text"; 690 field.form_control_type = "text";
691 691
692 field.label = ASCIIToUTF16("Card Number"); 692 field.label = ASCIIToUTF16("Card Number");
693 field.name = ASCIIToUTF16("card_number"); 693 field.name = ASCIIToUTF16("card_number");
694 form.fields.push_back(field); 694 form.fields.push_back(field);
695 695
696 form_structure.reset(new FormStructure(form)); 696 form_structure.reset(new FormStructure(form));
697 form_structure->DetermineHeuristicTypes(); 697 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */);
698 698
699 EXPECT_FALSE(form_structure->IsCompleteCreditCardForm()); 699 EXPECT_FALSE(form_structure->IsCompleteCreditCardForm());
700 } 700 }
701 701
702 // A form with only the credit card number is not considered sufficient. 702 // A form with only the credit card number is not considered sufficient.
703 TEST_F(FormStructureTest, IsCompleteCreditCardForm_AddressForm) { 703 TEST_F(FormStructureTest, IsCompleteCreditCardForm_AddressForm) {
704 std::unique_ptr<FormStructure> form_structure; 704 std::unique_ptr<FormStructure> form_structure;
705 FormData form; 705 FormData form;
706 706
707 FormFieldData field; 707 FormFieldData field;
(...skipping 20 matching lines...) Expand all
728 form.fields.push_back(field); 728 form.fields.push_back(field);
729 729
730 field.label = ASCIIToUTF16("Address"); 730 field.label = ASCIIToUTF16("Address");
731 field.name = base::string16(); 731 field.name = base::string16();
732 form.fields.push_back(field); 732 form.fields.push_back(field);
733 733
734 field.label = ASCIIToUTF16("Zip code"); 734 field.label = ASCIIToUTF16("Zip code");
735 field.name = base::string16(); 735 field.name = base::string16();
736 form.fields.push_back(field); 736 form.fields.push_back(field);
737 form_structure.reset(new FormStructure(form)); 737 form_structure.reset(new FormStructure(form));
738 form_structure->DetermineHeuristicTypes(); 738 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */);
739 739
740 EXPECT_FALSE(form_structure->IsCompleteCreditCardForm()); 740 EXPECT_FALSE(form_structure->IsCompleteCreditCardForm());
741 } 741 }
742 742
743 // Verify that we can correctly process the 'autocomplete' attribute for phone 743 // Verify that we can correctly process the 'autocomplete' attribute for phone
744 // number types (especially phone prefixes and suffixes). 744 // number types (especially phone prefixes and suffixes).
745 TEST_F(FormStructureTest, HeuristicsAutocompleteAttributePhoneTypes) { 745 TEST_F(FormStructureTest, HeuristicsAutocompleteAttributePhoneTypes) {
746 std::unique_ptr<FormStructure> form_structure; 746 std::unique_ptr<FormStructure> form_structure;
747 FormData form; 747 FormData form;
748 748
749 FormFieldData field; 749 FormFieldData field;
750 field.form_control_type = "text"; 750 field.form_control_type = "text";
751 751
752 field.label = base::string16(); 752 field.label = base::string16();
753 field.name = ASCIIToUTF16("field1"); 753 field.name = ASCIIToUTF16("field1");
754 field.autocomplete_attribute = "tel-local"; 754 field.autocomplete_attribute = "tel-local";
755 form.fields.push_back(field); 755 form.fields.push_back(field);
756 756
757 field.label = base::string16(); 757 field.label = base::string16();
758 field.name = ASCIIToUTF16("field2"); 758 field.name = ASCIIToUTF16("field2");
759 field.autocomplete_attribute = "tel-local-prefix"; 759 field.autocomplete_attribute = "tel-local-prefix";
760 form.fields.push_back(field); 760 form.fields.push_back(field);
761 761
762 field.label = base::string16(); 762 field.label = base::string16();
763 field.name = ASCIIToUTF16("field3"); 763 field.name = ASCIIToUTF16("field3");
764 field.autocomplete_attribute = "tel-local-suffix"; 764 field.autocomplete_attribute = "tel-local-suffix";
765 form.fields.push_back(field); 765 form.fields.push_back(field);
766 766
767 form_structure.reset(new FormStructure(form)); 767 form_structure.reset(new FormStructure(form));
768 form_structure->DetermineHeuristicTypes(); 768 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */);
769 EXPECT_TRUE(form_structure->IsAutofillable()); 769 EXPECT_TRUE(form_structure->IsAutofillable());
770 770
771 // Expect the correct number of fields. 771 // Expect the correct number of fields.
772 ASSERT_EQ(3U, form_structure->field_count()); 772 ASSERT_EQ(3U, form_structure->field_count());
773 EXPECT_EQ(3U, form_structure->autofill_count()); 773 EXPECT_EQ(3U, form_structure->autofill_count());
774 774
775 EXPECT_EQ(HTML_TYPE_TEL_LOCAL, form_structure->field(0)->html_type()); 775 EXPECT_EQ(HTML_TYPE_TEL_LOCAL, form_structure->field(0)->html_type());
776 EXPECT_EQ(AutofillField::IGNORED, form_structure->field(0)->phone_part()); 776 EXPECT_EQ(AutofillField::IGNORED, form_structure->field(0)->phone_part());
777 EXPECT_EQ(HTML_TYPE_TEL_LOCAL_PREFIX, form_structure->field(1)->html_type()); 777 EXPECT_EQ(HTML_TYPE_TEL_LOCAL_PREFIX, form_structure->field(1)->html_type());
778 EXPECT_EQ(AutofillField::PHONE_PREFIX, 778 EXPECT_EQ(AutofillField::PHONE_PREFIX,
(...skipping 19 matching lines...) Expand all
798 798
799 field.label = ASCIIToUTF16("Last Name"); 799 field.label = ASCIIToUTF16("Last Name");
800 field.name = ASCIIToUTF16("lastname"); 800 field.name = ASCIIToUTF16("lastname");
801 form.fields.push_back(field); 801 form.fields.push_back(field);
802 802
803 field.label = ASCIIToUTF16("Email"); 803 field.label = ASCIIToUTF16("Email");
804 field.name = ASCIIToUTF16("email"); 804 field.name = ASCIIToUTF16("email");
805 form.fields.push_back(field); 805 form.fields.push_back(field);
806 806
807 form_structure.reset(new FormStructure(form)); 807 form_structure.reset(new FormStructure(form));
808 form_structure->DetermineHeuristicTypes(); 808 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */);
809 EXPECT_TRUE(form_structure->IsAutofillable()); 809 EXPECT_TRUE(form_structure->IsAutofillable());
810 EXPECT_TRUE(form_structure->ShouldBeCrowdsourced()); 810 EXPECT_TRUE(form_structure->ShouldBeCrowdsourced());
811 811
812 ASSERT_EQ(3U, form_structure->field_count()); 812 ASSERT_EQ(3U, form_structure->field_count());
813 ASSERT_EQ(3U, form_structure->autofill_count()); 813 ASSERT_EQ(3U, form_structure->autofill_count());
814 814
815 EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type()); 815 EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type());
816 EXPECT_EQ(NAME_LAST, form_structure->field(1)->heuristic_type()); 816 EXPECT_EQ(NAME_LAST, form_structure->field(1)->heuristic_type());
817 EXPECT_EQ(EMAIL_ADDRESS, form_structure->field(2)->heuristic_type()); 817 EXPECT_EQ(EMAIL_ADDRESS, form_structure->field(2)->heuristic_type());
818 } 818 }
(...skipping 17 matching lines...) Expand all
836 field.label = ASCIIToUTF16("Last Name"); 836 field.label = ASCIIToUTF16("Last Name");
837 field.name = ASCIIToUTF16("lastname"); 837 field.name = ASCIIToUTF16("lastname");
838 field.autocomplete_attribute = ""; 838 field.autocomplete_attribute = "";
839 form.fields.push_back(field); 839 form.fields.push_back(field);
840 840
841 field.label = ASCIIToUTF16("Email"); 841 field.label = ASCIIToUTF16("Email");
842 field.name = ASCIIToUTF16("email"); 842 field.name = ASCIIToUTF16("email");
843 form.fields.push_back(field); 843 form.fields.push_back(field);
844 844
845 form_structure.reset(new FormStructure(form)); 845 form_structure.reset(new FormStructure(form));
846 form_structure->DetermineHeuristicTypes(); 846 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */);
847 EXPECT_TRUE(form_structure->IsAutofillable()); 847 EXPECT_TRUE(form_structure->IsAutofillable());
848 EXPECT_TRUE(form_structure->ShouldBeCrowdsourced()); 848 EXPECT_TRUE(form_structure->ShouldBeCrowdsourced());
849 849
850 ASSERT_EQ(3U, form_structure->field_count()); 850 ASSERT_EQ(3U, form_structure->field_count());
851 ASSERT_EQ(3U, form_structure->autofill_count()); 851 ASSERT_EQ(3U, form_structure->autofill_count());
852 852
853 EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type()); 853 EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type());
854 EXPECT_EQ(NAME_LAST, form_structure->field(1)->heuristic_type()); 854 EXPECT_EQ(NAME_LAST, form_structure->field(1)->heuristic_type());
855 EXPECT_EQ(EMAIL_ADDRESS, form_structure->field(2)->heuristic_type()); 855 EXPECT_EQ(EMAIL_ADDRESS, form_structure->field(2)->heuristic_type());
856 } 856 }
(...skipping 22 matching lines...) Expand all
879 879
880 field.label = ASCIIToUTF16("Last Name"); 880 field.label = ASCIIToUTF16("Last Name");
881 field.name = ASCIIToUTF16("lastname"); 881 field.name = ASCIIToUTF16("lastname");
882 form.fields.push_back(field); 882 form.fields.push_back(field);
883 883
884 field.label = ASCIIToUTF16("Email"); 884 field.label = ASCIIToUTF16("Email");
885 field.name = ASCIIToUTF16("email"); 885 field.name = ASCIIToUTF16("email");
886 form.fields.push_back(field); 886 form.fields.push_back(field);
887 887
888 form_structure.reset(new FormStructure(form)); 888 form_structure.reset(new FormStructure(form));
889 form_structure->DetermineHeuristicTypes(); 889 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */);
890 EXPECT_TRUE(form_structure->IsAutofillable()); 890 EXPECT_TRUE(form_structure->IsAutofillable());
891 EXPECT_TRUE(form_structure->ShouldBeCrowdsourced()); 891 EXPECT_TRUE(form_structure->ShouldBeCrowdsourced());
892 892
893 ASSERT_EQ(4U, form_structure->field_count()); 893 ASSERT_EQ(4U, form_structure->field_count());
894 ASSERT_EQ(3U, form_structure->autofill_count()); 894 ASSERT_EQ(3U, form_structure->autofill_count());
895 895
896 EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type()); 896 EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type());
897 EXPECT_EQ(NAME_MIDDLE, form_structure->field(1)->heuristic_type()); 897 EXPECT_EQ(NAME_MIDDLE, form_structure->field(1)->heuristic_type());
898 EXPECT_EQ(NAME_LAST, form_structure->field(2)->heuristic_type()); 898 EXPECT_EQ(NAME_LAST, form_structure->field(2)->heuristic_type());
899 EXPECT_EQ(EMAIL_ADDRESS, form_structure->field(3)->heuristic_type()); 899 EXPECT_EQ(EMAIL_ADDRESS, form_structure->field(3)->heuristic_type());
(...skipping 11 matching lines...) Expand all
911 911
912 field.label = ASCIIToUTF16("First Name"); 912 field.label = ASCIIToUTF16("First Name");
913 field.name = ASCIIToUTF16("firstname"); 913 field.name = ASCIIToUTF16("firstname");
914 form.fields.push_back(field); 914 form.fields.push_back(field);
915 915
916 field.label = ASCIIToUTF16("Last Name"); 916 field.label = ASCIIToUTF16("Last Name");
917 field.name = ASCIIToUTF16("lastname"); 917 field.name = ASCIIToUTF16("lastname");
918 form.fields.push_back(field); 918 form.fields.push_back(field);
919 919
920 form_structure.reset(new FormStructure(form)); 920 form_structure.reset(new FormStructure(form));
921 form_structure->DetermineHeuristicTypes(); 921 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */);
922 EXPECT_FALSE(form_structure->IsAutofillable()); 922 EXPECT_FALSE(form_structure->IsAutofillable());
923 EXPECT_FALSE(form_structure->ShouldBeCrowdsourced()); 923 EXPECT_FALSE(form_structure->ShouldBeCrowdsourced());
924 924
925 ASSERT_EQ(2U, form_structure->field_count()); 925 ASSERT_EQ(2U, form_structure->field_count());
926 ASSERT_EQ(0U, form_structure->autofill_count()); 926 ASSERT_EQ(0U, form_structure->autofill_count());
927 927
928 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(0)->heuristic_type()); 928 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(0)->heuristic_type());
929 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(1)->heuristic_type()); 929 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(1)->heuristic_type());
930 EXPECT_EQ(NO_SERVER_DATA, form_structure->field(0)->server_type()); 930 EXPECT_EQ(NO_SERVER_DATA, form_structure->field(0)->server_type());
931 EXPECT_EQ(NO_SERVER_DATA, form_structure->field(1)->server_type()); 931 EXPECT_EQ(NO_SERVER_DATA, form_structure->field(1)->server_type());
(...skipping 14 matching lines...) Expand all
946 field.name = ASCIIToUTF16("firstname"); 946 field.name = ASCIIToUTF16("firstname");
947 field.autocomplete_attribute = "given-name"; 947 field.autocomplete_attribute = "given-name";
948 form.fields.push_back(field); 948 form.fields.push_back(field);
949 949
950 field.label = ASCIIToUTF16("Last Name"); 950 field.label = ASCIIToUTF16("Last Name");
951 field.name = ASCIIToUTF16("lastname"); 951 field.name = ASCIIToUTF16("lastname");
952 field.autocomplete_attribute = ""; 952 field.autocomplete_attribute = "";
953 form.fields.push_back(field); 953 form.fields.push_back(field);
954 954
955 form_structure.reset(new FormStructure(form)); 955 form_structure.reset(new FormStructure(form));
956 form_structure->DetermineHeuristicTypes(); 956 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */);
957 EXPECT_FALSE(form_structure->IsAutofillable()); 957 EXPECT_FALSE(form_structure->IsAutofillable());
958 EXPECT_FALSE(form_structure->ShouldBeCrowdsourced()); 958 EXPECT_FALSE(form_structure->ShouldBeCrowdsourced());
959 959
960 ASSERT_EQ(2U, form_structure->field_count()); 960 ASSERT_EQ(2U, form_structure->field_count());
961 ASSERT_EQ(1U, form_structure->autofill_count()); 961 ASSERT_EQ(1U, form_structure->autofill_count());
962 962
963 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(0)->heuristic_type()); 963 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(0)->heuristic_type());
964 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(1)->heuristic_type()); 964 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(1)->heuristic_type());
965 EXPECT_EQ(NO_SERVER_DATA, form_structure->field(0)->server_type()); 965 EXPECT_EQ(NO_SERVER_DATA, form_structure->field(0)->server_type());
966 EXPECT_EQ(NO_SERVER_DATA, form_structure->field(1)->server_type()); 966 EXPECT_EQ(NO_SERVER_DATA, form_structure->field(1)->server_type());
(...skipping 22 matching lines...) Expand all
989 field.name = ASCIIToUTF16("email"); 989 field.name = ASCIIToUTF16("email");
990 field.autocomplete_attribute = "username"; 990 field.autocomplete_attribute = "username";
991 form.fields.push_back(field); 991 form.fields.push_back(field);
992 992
993 field.label = ASCIIToUTF16("Password"); 993 field.label = ASCIIToUTF16("Password");
994 field.name = ASCIIToUTF16("Password"); 994 field.name = ASCIIToUTF16("Password");
995 field.form_control_type = "password"; 995 field.form_control_type = "password";
996 form.fields.push_back(field); 996 form.fields.push_back(field);
997 997
998 FormStructure form_structure(form); 998 FormStructure form_structure(form);
999 form_structure.DetermineHeuristicTypes(); 999 form_structure.DetermineHeuristicTypes(nullptr /* ukm_service */);
1000 EXPECT_TRUE(form_structure.ShouldBeCrowdsourced()); 1000 EXPECT_TRUE(form_structure.ShouldBeCrowdsourced());
1001 } 1001 }
1002 1002
1003 // Verify that we can correctly process sections listed in the |autocomplete| 1003 // Verify that we can correctly process sections listed in the |autocomplete|
1004 // attribute. 1004 // attribute.
1005 TEST_F(FormStructureTest, HeuristicsAutocompleteAttributeWithSections) { 1005 TEST_F(FormStructureTest, HeuristicsAutocompleteAttributeWithSections) {
1006 FormData form; 1006 FormData form;
1007 1007
1008 FormFieldData field; 1008 FormFieldData field;
1009 field.form_control_type = "text"; 1009 field.form_control_type = "text";
(...skipping 30 matching lines...) Expand all
1040 // implement implicit section names from attributes like "shipping email"; see 1040 // implement implicit section names from attributes like "shipping email"; see
1041 // the implementation for more details. 1041 // the implementation for more details.
1042 field.autocomplete_attribute = "section--shipping email"; 1042 field.autocomplete_attribute = "section--shipping email";
1043 form.fields.push_back(field); 1043 form.fields.push_back(field);
1044 1044
1045 // Credit card fields are implicitly in a separate section from other fields. 1045 // Credit card fields are implicitly in a separate section from other fields.
1046 field.autocomplete_attribute = "section-foo cc-number"; 1046 field.autocomplete_attribute = "section-foo cc-number";
1047 form.fields.push_back(field); 1047 form.fields.push_back(field);
1048 1048
1049 FormStructure form_structure(form); 1049 FormStructure form_structure(form);
1050 form_structure.DetermineHeuristicTypes(); 1050 form_structure.DetermineHeuristicTypes(nullptr /* ukm_service */);
1051 EXPECT_TRUE(form_structure.IsAutofillable()); 1051 EXPECT_TRUE(form_structure.IsAutofillable());
1052 1052
1053 // Expect the correct number of fields. 1053 // Expect the correct number of fields.
1054 ASSERT_EQ(9U, form_structure.field_count()); 1054 ASSERT_EQ(9U, form_structure.field_count());
1055 EXPECT_EQ(9U, form_structure.autofill_count()); 1055 EXPECT_EQ(9U, form_structure.autofill_count());
1056 1056
1057 // All of the fields in this form should be parsed as belonging to different 1057 // All of the fields in this form should be parsed as belonging to different
1058 // sections. 1058 // sections.
1059 std::set<std::string> section_names; 1059 std::set<std::string> section_names;
1060 for (size_t i = 0; i < 9; ++i) { 1060 for (size_t i = 0; i < 9; ++i) {
(...skipping 24 matching lines...) Expand all
1085 field.autocomplete_attribute = "garbage section-foo email"; 1085 field.autocomplete_attribute = "garbage section-foo email";
1086 form.fields.push_back(field); 1086 form.fields.push_back(field);
1087 field.autocomplete_attribute = "garbage section-bar email"; 1087 field.autocomplete_attribute = "garbage section-bar email";
1088 form.fields.push_back(field); 1088 form.fields.push_back(field);
1089 field.autocomplete_attribute = "garbage shipping email"; 1089 field.autocomplete_attribute = "garbage shipping email";
1090 form.fields.push_back(field); 1090 form.fields.push_back(field);
1091 field.autocomplete_attribute = "garbage billing email"; 1091 field.autocomplete_attribute = "garbage billing email";
1092 form.fields.push_back(field); 1092 form.fields.push_back(field);
1093 1093
1094 FormStructure form_structure(form); 1094 FormStructure form_structure(form);
1095 form_structure.DetermineHeuristicTypes(); 1095 form_structure.DetermineHeuristicTypes(nullptr /* ukm_service */);
1096 1096
1097 // Expect the correct number of fields. 1097 // Expect the correct number of fields.
1098 ASSERT_EQ(6U, form_structure.field_count()); 1098 ASSERT_EQ(6U, form_structure.field_count());
1099 EXPECT_EQ(2U, form_structure.autofill_count()); 1099 EXPECT_EQ(2U, form_structure.autofill_count());
1100 1100
1101 // All of the fields in this form should be parsed as belonging to the same 1101 // All of the fields in this form should be parsed as belonging to the same
1102 // section. 1102 // section.
1103 std::set<std::string> section_names; 1103 std::set<std::string> section_names;
1104 for (size_t i = 0; i < 6; ++i) { 1104 for (size_t i = 0; i < 6; ++i) {
1105 section_names.insert(form_structure.field(i)->section()); 1105 section_names.insert(form_structure.field(i)->section());
1106 } 1106 }
1107 EXPECT_EQ(1U, section_names.size()); 1107 EXPECT_EQ(1U, section_names.size());
1108 } 1108 }
1109 1109
1110 // Verify that we can correctly process repeated sections listed in the 1110 // Verify that we can correctly process repeated sections listed in the
1111 // |autocomplete| attribute. 1111 // |autocomplete| attribute.
1112 TEST_F(FormStructureTest, HeuristicsAutocompleteAttributeWithSectionsRepeated) { 1112 TEST_F(FormStructureTest, HeuristicsAutocompleteAttributeWithSectionsRepeated) {
1113 FormData form; 1113 FormData form;
1114 1114
1115 FormFieldData field; 1115 FormFieldData field;
1116 field.form_control_type = "text"; 1116 field.form_control_type = "text";
1117 1117
1118 field.autocomplete_attribute = "section-foo email"; 1118 field.autocomplete_attribute = "section-foo email";
1119 form.fields.push_back(field); 1119 form.fields.push_back(field);
1120 field.autocomplete_attribute = "section-foo address-line1"; 1120 field.autocomplete_attribute = "section-foo address-line1";
1121 form.fields.push_back(field); 1121 form.fields.push_back(field);
1122 1122
1123 FormStructure form_structure(form); 1123 FormStructure form_structure(form);
1124 form_structure.DetermineHeuristicTypes(); 1124 form_structure.DetermineHeuristicTypes(nullptr /* ukm_service */);
1125 1125
1126 // Expect the correct number of fields. 1126 // Expect the correct number of fields.
1127 ASSERT_EQ(2U, form_structure.field_count()); 1127 ASSERT_EQ(2U, form_structure.field_count());
1128 EXPECT_EQ(2U, form_structure.autofill_count()); 1128 EXPECT_EQ(2U, form_structure.autofill_count());
1129 1129
1130 // All of the fields in this form should be parsed as belonging to the same 1130 // All of the fields in this form should be parsed as belonging to the same
1131 // section. 1131 // section.
1132 std::set<std::string> section_names; 1132 std::set<std::string> section_names;
1133 for (size_t i = 0; i < 2; ++i) { 1133 for (size_t i = 0; i < 2; ++i) {
1134 section_names.insert(form_structure.field(i)->section()); 1134 section_names.insert(form_structure.field(i)->section());
(...skipping 16 matching lines...) Expand all
1151 field.autocomplete_attribute = "section-foo email"; 1151 field.autocomplete_attribute = "section-foo email";
1152 form.fields.push_back(field); 1152 form.fields.push_back(field);
1153 field.name = base::string16(); 1153 field.name = base::string16();
1154 field.autocomplete_attribute = "name"; 1154 field.autocomplete_attribute = "name";
1155 form.fields.push_back(field); 1155 form.fields.push_back(field);
1156 field.name = ASCIIToUTF16("two"); 1156 field.name = ASCIIToUTF16("two");
1157 field.autocomplete_attribute = "address-line1"; 1157 field.autocomplete_attribute = "address-line1";
1158 form.fields.push_back(field); 1158 form.fields.push_back(field);
1159 1159
1160 FormStructure form_structure(form); 1160 FormStructure form_structure(form);
1161 form_structure.DetermineHeuristicTypes(); 1161 form_structure.DetermineHeuristicTypes(nullptr /* ukm_service */);
1162 1162
1163 // Expect the correct number of fields. 1163 // Expect the correct number of fields.
1164 ASSERT_EQ(4U, form_structure.field_count()); 1164 ASSERT_EQ(4U, form_structure.field_count());
1165 EXPECT_EQ(4U, form_structure.autofill_count()); 1165 EXPECT_EQ(4U, form_structure.autofill_count());
1166 1166
1167 // Normally, the two separate address fields would cause us to detect two 1167 // Normally, the two separate address fields would cause us to detect two
1168 // separate sections; but because there is an author-specified section in this 1168 // separate sections; but because there is an author-specified section in this
1169 // form, we do not apply these usual heuristics. 1169 // form, we do not apply these usual heuristics.
1170 EXPECT_EQ(ASCIIToUTF16("one"), form_structure.field(0)->name); 1170 EXPECT_EQ(ASCIIToUTF16("one"), form_structure.field(0)->name);
1171 EXPECT_EQ(ASCIIToUTF16("two"), form_structure.field(3)->name); 1171 EXPECT_EQ(ASCIIToUTF16("two"), form_structure.field(3)->name);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1215 field.label = ASCIIToUTF16("Phone Number:"); 1215 field.label = ASCIIToUTF16("Phone Number:");
1216 field.name = ASCIIToUTF16("BillTo.Phone"); 1216 field.name = ASCIIToUTF16("BillTo.Phone");
1217 form.fields.push_back(field); 1217 form.fields.push_back(field);
1218 1218
1219 field.label = base::string16(); 1219 field.label = base::string16();
1220 field.name = ASCIIToUTF16("Submit"); 1220 field.name = ASCIIToUTF16("Submit");
1221 field.form_control_type = "submit"; 1221 field.form_control_type = "submit";
1222 form.fields.push_back(field); 1222 form.fields.push_back(field);
1223 1223
1224 form_structure.reset(new FormStructure(form)); 1224 form_structure.reset(new FormStructure(form));
1225 form_structure->DetermineHeuristicTypes(); 1225 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */);
1226 EXPECT_TRUE(form_structure->IsAutofillable()); 1226 EXPECT_TRUE(form_structure->IsAutofillable());
1227 ASSERT_EQ(10U, form_structure->field_count()); 1227 ASSERT_EQ(10U, form_structure->field_count());
1228 ASSERT_EQ(9U, form_structure->autofill_count()); 1228 ASSERT_EQ(9U, form_structure->autofill_count());
1229 1229
1230 // First name. 1230 // First name.
1231 EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type()); 1231 EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type());
1232 // Last name. 1232 // Last name.
1233 EXPECT_EQ(NAME_LAST, form_structure->field(1)->heuristic_type()); 1233 EXPECT_EQ(NAME_LAST, form_structure->field(1)->heuristic_type());
1234 // Address. 1234 // Address.
1235 EXPECT_EQ(ADDRESS_HOME_LINE1, form_structure->field(2)->heuristic_type()); 1235 EXPECT_EQ(ADDRESS_HOME_LINE1, form_structure->field(2)->heuristic_type());
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1281 field.name = ASCIIToUTF16("Home.PostalCode"); 1281 field.name = ASCIIToUTF16("Home.PostalCode");
1282 form.fields.push_back(field); 1282 form.fields.push_back(field);
1283 1283
1284 field.label = base::string16(); 1284 field.label = base::string16();
1285 field.name = ASCIIToUTF16("Submit"); 1285 field.name = ASCIIToUTF16("Submit");
1286 field.value = ASCIIToUTF16("continue"); 1286 field.value = ASCIIToUTF16("continue");
1287 field.form_control_type = "submit"; 1287 field.form_control_type = "submit";
1288 form.fields.push_back(field); 1288 form.fields.push_back(field);
1289 1289
1290 form_structure.reset(new FormStructure(form)); 1290 form_structure.reset(new FormStructure(form));
1291 form_structure->DetermineHeuristicTypes(); 1291 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */);
1292 EXPECT_TRUE(form_structure->IsAutofillable()); 1292 EXPECT_TRUE(form_structure->IsAutofillable());
1293 ASSERT_EQ(7U, form_structure->field_count()); 1293 ASSERT_EQ(7U, form_structure->field_count());
1294 ASSERT_EQ(6U, form_structure->autofill_count()); 1294 ASSERT_EQ(6U, form_structure->autofill_count());
1295 1295
1296 // Email. 1296 // Email.
1297 EXPECT_EQ(EMAIL_ADDRESS, form_structure->field(0)->heuristic_type()); 1297 EXPECT_EQ(EMAIL_ADDRESS, form_structure->field(0)->heuristic_type());
1298 // Full name. 1298 // Full name.
1299 EXPECT_EQ(NAME_FULL, form_structure->field(1)->heuristic_type()); 1299 EXPECT_EQ(NAME_FULL, form_structure->field(1)->heuristic_type());
1300 // Company 1300 // Company
1301 EXPECT_EQ(COMPANY_NAME, form_structure->field(2)->heuristic_type()); 1301 EXPECT_EQ(COMPANY_NAME, form_structure->field(2)->heuristic_type());
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1346 field.label = ASCIIToUTF16("Zip code"); 1346 field.label = ASCIIToUTF16("Zip code");
1347 field.name = base::string16(); 1347 field.name = base::string16();
1348 form.fields.push_back(field); 1348 form.fields.push_back(field);
1349 1349
1350 field.label = base::string16(); 1350 field.label = base::string16();
1351 field.name = ASCIIToUTF16("Submit"); 1351 field.name = ASCIIToUTF16("Submit");
1352 field.form_control_type = "submit"; 1352 field.form_control_type = "submit";
1353 form.fields.push_back(field); 1353 form.fields.push_back(field);
1354 1354
1355 form_structure.reset(new FormStructure(form)); 1355 form_structure.reset(new FormStructure(form));
1356 form_structure->DetermineHeuristicTypes(); 1356 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */);
1357 EXPECT_TRUE(form_structure->IsAutofillable()); 1357 EXPECT_TRUE(form_structure->IsAutofillable());
1358 ASSERT_EQ(8U, form_structure->field_count()); 1358 ASSERT_EQ(8U, form_structure->field_count());
1359 ASSERT_EQ(7U, form_structure->autofill_count()); 1359 ASSERT_EQ(7U, form_structure->autofill_count());
1360 1360
1361 // First name. 1361 // First name.
1362 EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type()); 1362 EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type());
1363 // Last name. 1363 // Last name.
1364 EXPECT_EQ(NAME_LAST, form_structure->field(1)->heuristic_type()); 1364 EXPECT_EQ(NAME_LAST, form_structure->field(1)->heuristic_type());
1365 // Email. 1365 // Email.
1366 EXPECT_EQ(EMAIL_ADDRESS, form_structure->field(2)->heuristic_type()); 1366 EXPECT_EQ(EMAIL_ADDRESS, form_structure->field(2)->heuristic_type());
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1403 field.label = ASCIIToUTF16("Verification"); 1403 field.label = ASCIIToUTF16("Verification");
1404 field.name = ASCIIToUTF16("verification"); 1404 field.name = ASCIIToUTF16("verification");
1405 form.fields.push_back(field); 1405 form.fields.push_back(field);
1406 1406
1407 field.label = base::string16(); 1407 field.label = base::string16();
1408 field.name = ASCIIToUTF16("Submit"); 1408 field.name = ASCIIToUTF16("Submit");
1409 field.form_control_type = "submit"; 1409 field.form_control_type = "submit";
1410 form.fields.push_back(field); 1410 form.fields.push_back(field);
1411 1411
1412 form_structure.reset(new FormStructure(form)); 1412 form_structure.reset(new FormStructure(form));
1413 form_structure->DetermineHeuristicTypes(); 1413 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */);
1414 EXPECT_TRUE(form_structure->IsAutofillable()); 1414 EXPECT_TRUE(form_structure->IsAutofillable());
1415 ASSERT_EQ(6U, form_structure->field_count()); 1415 ASSERT_EQ(6U, form_structure->field_count());
1416 ASSERT_EQ(5U, form_structure->autofill_count()); 1416 ASSERT_EQ(5U, form_structure->autofill_count());
1417 1417
1418 // Credit card name. 1418 // Credit card name.
1419 EXPECT_EQ(CREDIT_CARD_NAME_FULL, form_structure->field(0)->heuristic_type()); 1419 EXPECT_EQ(CREDIT_CARD_NAME_FULL, form_structure->field(0)->heuristic_type());
1420 // Credit card number. 1420 // Credit card number.
1421 EXPECT_EQ(CREDIT_CARD_NUMBER, form_structure->field(1)->heuristic_type()); 1421 EXPECT_EQ(CREDIT_CARD_NUMBER, form_structure->field(1)->heuristic_type());
1422 // Credit card expiration month. 1422 // Credit card expiration month.
1423 EXPECT_EQ(CREDIT_CARD_EXP_MONTH, form_structure->field(2)->heuristic_type()); 1423 EXPECT_EQ(CREDIT_CARD_EXP_MONTH, form_structure->field(2)->heuristic_type());
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1463 field.label = ASCIIToUTF16("Verification"); 1463 field.label = ASCIIToUTF16("Verification");
1464 field.name = ASCIIToUTF16("verification"); 1464 field.name = ASCIIToUTF16("verification");
1465 form.fields.push_back(field); 1465 form.fields.push_back(field);
1466 1466
1467 field.label = base::string16(); 1467 field.label = base::string16();
1468 field.name = ASCIIToUTF16("Submit"); 1468 field.name = ASCIIToUTF16("Submit");
1469 field.form_control_type = "submit"; 1469 field.form_control_type = "submit";
1470 form.fields.push_back(field); 1470 form.fields.push_back(field);
1471 1471
1472 form_structure.reset(new FormStructure(form)); 1472 form_structure.reset(new FormStructure(form));
1473 form_structure->DetermineHeuristicTypes(); 1473 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */);
1474 EXPECT_TRUE(form_structure->IsAutofillable()); 1474 EXPECT_TRUE(form_structure->IsAutofillable());
1475 ASSERT_EQ(7U, form_structure->field_count()); 1475 ASSERT_EQ(7U, form_structure->field_count());
1476 ASSERT_EQ(5U, form_structure->autofill_count()); 1476 ASSERT_EQ(5U, form_structure->autofill_count());
1477 1477
1478 // Credit card name. 1478 // Credit card name.
1479 EXPECT_EQ(CREDIT_CARD_NAME_FULL, form_structure->field(0)->heuristic_type()); 1479 EXPECT_EQ(CREDIT_CARD_NAME_FULL, form_structure->field(0)->heuristic_type());
1480 // Credit card type. This is an unknown type but related to the credit card. 1480 // Credit card type. This is an unknown type but related to the credit card.
1481 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(1)->heuristic_type()); 1481 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(1)->heuristic_type());
1482 // Credit card number. 1482 // Credit card number.
1483 EXPECT_EQ(CREDIT_CARD_NUMBER, form_structure->field(2)->heuristic_type()); 1483 EXPECT_EQ(CREDIT_CARD_NUMBER, form_structure->field(2)->heuristic_type());
(...skipping 26 matching lines...) Expand all
1510 1510
1511 field.label = ASCIIToUTF16("Address Line3"); 1511 field.label = ASCIIToUTF16("Address Line3");
1512 field.name = ASCIIToUTF16("Address"); 1512 field.name = ASCIIToUTF16("Address");
1513 form.fields.push_back(field); 1513 form.fields.push_back(field);
1514 1514
1515 field.label = ASCIIToUTF16("City"); 1515 field.label = ASCIIToUTF16("City");
1516 field.name = ASCIIToUTF16("city"); 1516 field.name = ASCIIToUTF16("city");
1517 form.fields.push_back(field); 1517 form.fields.push_back(field);
1518 1518
1519 form_structure.reset(new FormStructure(form)); 1519 form_structure.reset(new FormStructure(form));
1520 form_structure->DetermineHeuristicTypes(); 1520 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */);
1521 EXPECT_TRUE(form_structure->IsAutofillable()); 1521 EXPECT_TRUE(form_structure->IsAutofillable());
1522 ASSERT_EQ(4U, form_structure->field_count()); 1522 ASSERT_EQ(4U, form_structure->field_count());
1523 ASSERT_EQ(4U, form_structure->autofill_count()); 1523 ASSERT_EQ(4U, form_structure->autofill_count());
1524 1524
1525 // Address Line 1. 1525 // Address Line 1.
1526 EXPECT_EQ(ADDRESS_HOME_LINE1, form_structure->field(0)->heuristic_type()); 1526 EXPECT_EQ(ADDRESS_HOME_LINE1, form_structure->field(0)->heuristic_type());
1527 // Address Line 2. 1527 // Address Line 2.
1528 EXPECT_EQ(ADDRESS_HOME_LINE2, form_structure->field(1)->heuristic_type()); 1528 EXPECT_EQ(ADDRESS_HOME_LINE2, form_structure->field(1)->heuristic_type());
1529 // Address Line 3. 1529 // Address Line 3.
1530 EXPECT_EQ(ADDRESS_HOME_LINE3, form_structure->field(2)->heuristic_type()); 1530 EXPECT_EQ(ADDRESS_HOME_LINE3, form_structure->field(2)->heuristic_type());
(...skipping 19 matching lines...) Expand all
1550 1550
1551 field.label = ASCIIToUTF16("Address Line3"); 1551 field.label = ASCIIToUTF16("Address Line3");
1552 field.name = ASCIIToUTF16("billing.address.addressLine3"); 1552 field.name = ASCIIToUTF16("billing.address.addressLine3");
1553 form.fields.push_back(field); 1553 form.fields.push_back(field);
1554 1554
1555 field.label = ASCIIToUTF16("Address Line4"); 1555 field.label = ASCIIToUTF16("Address Line4");
1556 field.name = ASCIIToUTF16("billing.address.addressLine4"); 1556 field.name = ASCIIToUTF16("billing.address.addressLine4");
1557 form.fields.push_back(field); 1557 form.fields.push_back(field);
1558 1558
1559 form_structure.reset(new FormStructure(form)); 1559 form_structure.reset(new FormStructure(form));
1560 form_structure->DetermineHeuristicTypes(); 1560 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */);
1561 ASSERT_EQ(4U, form_structure->field_count()); 1561 ASSERT_EQ(4U, form_structure->field_count());
1562 ASSERT_EQ(3U, form_structure->autofill_count()); 1562 ASSERT_EQ(3U, form_structure->autofill_count());
1563 1563
1564 // Address Line 1. 1564 // Address Line 1.
1565 EXPECT_EQ(ADDRESS_HOME_LINE1, form_structure->field(0)->heuristic_type()); 1565 EXPECT_EQ(ADDRESS_HOME_LINE1, form_structure->field(0)->heuristic_type());
1566 // Address Line 2. 1566 // Address Line 2.
1567 EXPECT_EQ(ADDRESS_HOME_LINE2, form_structure->field(1)->heuristic_type()); 1567 EXPECT_EQ(ADDRESS_HOME_LINE2, form_structure->field(1)->heuristic_type());
1568 // Address Line 3. 1568 // Address Line 3.
1569 EXPECT_EQ(ADDRESS_HOME_LINE3, form_structure->field(2)->heuristic_type()); 1569 EXPECT_EQ(ADDRESS_HOME_LINE3, form_structure->field(2)->heuristic_type());
1570 // Address Line 4 (ignored). 1570 // Address Line 4 (ignored).
(...skipping 22 matching lines...) Expand all
1593 1593
1594 field.label = ASCIIToUTF16("Street address second line"); 1594 field.label = ASCIIToUTF16("Street address second line");
1595 field.name = ASCIIToUTF16("FOPIH_RgWebCC_0_IHAddress_ads2"); 1595 field.name = ASCIIToUTF16("FOPIH_RgWebCC_0_IHAddress_ads2");
1596 form.fields.push_back(field); 1596 form.fields.push_back(field);
1597 1597
1598 field.label = ASCIIToUTF16("City:"); 1598 field.label = ASCIIToUTF16("City:");
1599 field.name = ASCIIToUTF16("FOPIH_RgWebCC_0_IHAddress_adct"); 1599 field.name = ASCIIToUTF16("FOPIH_RgWebCC_0_IHAddress_adct");
1600 form.fields.push_back(field); 1600 form.fields.push_back(field);
1601 1601
1602 form_structure.reset(new FormStructure(form)); 1602 form_structure.reset(new FormStructure(form));
1603 form_structure->DetermineHeuristicTypes(); 1603 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */);
1604 EXPECT_TRUE(form_structure->IsAutofillable()); 1604 EXPECT_TRUE(form_structure->IsAutofillable());
1605 ASSERT_EQ(4U, form_structure->field_count()); 1605 ASSERT_EQ(4U, form_structure->field_count());
1606 EXPECT_EQ(4U, form_structure->autofill_count()); 1606 EXPECT_EQ(4U, form_structure->autofill_count());
1607 1607
1608 // Address Line 1. 1608 // Address Line 1.
1609 EXPECT_EQ(ADDRESS_HOME_LINE1, form_structure->field(0)->heuristic_type()); 1609 EXPECT_EQ(ADDRESS_HOME_LINE1, form_structure->field(0)->heuristic_type());
1610 // Suite / Apt. 1610 // Suite / Apt.
1611 EXPECT_EQ(ADDRESS_HOME_LINE2, form_structure->field(1)->heuristic_type()); 1611 EXPECT_EQ(ADDRESS_HOME_LINE2, form_structure->field(1)->heuristic_type());
1612 // Address Line 3. 1612 // Address Line 3.
1613 EXPECT_EQ(ADDRESS_HOME_LINE3, form_structure->field(2)->heuristic_type()); 1613 EXPECT_EQ(ADDRESS_HOME_LINE3, form_structure->field(2)->heuristic_type());
(...skipping 17 matching lines...) Expand all
1631 1631
1632 field.label = ASCIIToUTF16("Floor number, suite number, etc"); 1632 field.label = ASCIIToUTF16("Floor number, suite number, etc");
1633 field.name = ASCIIToUTF16("address2"); 1633 field.name = ASCIIToUTF16("address2");
1634 form.fields.push_back(field); 1634 form.fields.push_back(field);
1635 1635
1636 field.label = ASCIIToUTF16("City:"); 1636 field.label = ASCIIToUTF16("City:");
1637 field.name = ASCIIToUTF16("city"); 1637 field.name = ASCIIToUTF16("city");
1638 form.fields.push_back(field); 1638 form.fields.push_back(field);
1639 1639
1640 form_structure.reset(new FormStructure(form)); 1640 form_structure.reset(new FormStructure(form));
1641 form_structure->DetermineHeuristicTypes(); 1641 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */);
1642 EXPECT_TRUE(form_structure->IsAutofillable()); 1642 EXPECT_TRUE(form_structure->IsAutofillable());
1643 ASSERT_EQ(3U, form_structure->field_count()); 1643 ASSERT_EQ(3U, form_structure->field_count());
1644 ASSERT_EQ(3U, form_structure->autofill_count()); 1644 ASSERT_EQ(3U, form_structure->autofill_count());
1645 1645
1646 // Address Line 1. 1646 // Address Line 1.
1647 EXPECT_EQ(ADDRESS_HOME_LINE1, form_structure->field(0)->heuristic_type()); 1647 EXPECT_EQ(ADDRESS_HOME_LINE1, form_structure->field(0)->heuristic_type());
1648 // Address Line 2. 1648 // Address Line 2.
1649 EXPECT_EQ(ADDRESS_HOME_LINE2, form_structure->field(1)->heuristic_type()); 1649 EXPECT_EQ(ADDRESS_HOME_LINE2, form_structure->field(1)->heuristic_type());
1650 // City. 1650 // City.
1651 EXPECT_EQ(ADDRESS_HOME_CITY, form_structure->field(2)->heuristic_type()); 1651 EXPECT_EQ(ADDRESS_HOME_CITY, form_structure->field(2)->heuristic_type());
(...skipping 12 matching lines...) Expand all
1664 1664
1665 field.label = ASCIIToUTF16("Address Line2"); 1665 field.label = ASCIIToUTF16("Address Line2");
1666 field.name = ASCIIToUTF16("Address"); 1666 field.name = ASCIIToUTF16("Address");
1667 form.fields.push_back(field); 1667 form.fields.push_back(field);
1668 1668
1669 field.label = ASCIIToUTF16("State/Province/Region"); 1669 field.label = ASCIIToUTF16("State/Province/Region");
1670 field.name = ASCIIToUTF16("State"); 1670 field.name = ASCIIToUTF16("State");
1671 form.fields.push_back(field); 1671 form.fields.push_back(field);
1672 1672
1673 form_structure.reset(new FormStructure(form)); 1673 form_structure.reset(new FormStructure(form));
1674 form_structure->DetermineHeuristicTypes(); 1674 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */);
1675 EXPECT_TRUE(form_structure->IsAutofillable()); 1675 EXPECT_TRUE(form_structure->IsAutofillable());
1676 ASSERT_EQ(3U, form_structure->field_count()); 1676 ASSERT_EQ(3U, form_structure->field_count());
1677 ASSERT_EQ(3U, form_structure->autofill_count()); 1677 ASSERT_EQ(3U, form_structure->autofill_count());
1678 1678
1679 // Address Line 1. 1679 // Address Line 1.
1680 EXPECT_EQ(ADDRESS_HOME_LINE1, form_structure->field(0)->heuristic_type()); 1680 EXPECT_EQ(ADDRESS_HOME_LINE1, form_structure->field(0)->heuristic_type());
1681 // Address Line 2. 1681 // Address Line 2.
1682 EXPECT_EQ(ADDRESS_HOME_LINE2, form_structure->field(1)->heuristic_type()); 1682 EXPECT_EQ(ADDRESS_HOME_LINE2, form_structure->field(1)->heuristic_type());
1683 // State. 1683 // State.
1684 EXPECT_EQ(ADDRESS_HOME_STATE, form_structure->field(2)->heuristic_type()); 1684 EXPECT_EQ(ADDRESS_HOME_STATE, form_structure->field(2)->heuristic_type());
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1730 1730
1731 field.label = ASCIIToUTF16("Phone*:"); 1731 field.label = ASCIIToUTF16("Phone*:");
1732 field.name = ASCIIToUTF16("editBillingAddress$phoneBox"); 1732 field.name = ASCIIToUTF16("editBillingAddress$phoneBox");
1733 form.fields.push_back(field); 1733 form.fields.push_back(field);
1734 1734
1735 field.label = ASCIIToUTF16("Email Address*:"); 1735 field.label = ASCIIToUTF16("Email Address*:");
1736 field.name = ASCIIToUTF16("email$emailBox"); 1736 field.name = ASCIIToUTF16("email$emailBox");
1737 form.fields.push_back(field); 1737 form.fields.push_back(field);
1738 1738
1739 form_structure.reset(new FormStructure(form)); 1739 form_structure.reset(new FormStructure(form));
1740 form_structure->DetermineHeuristicTypes(); 1740 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */);
1741 EXPECT_TRUE(form_structure->IsAutofillable()); 1741 EXPECT_TRUE(form_structure->IsAutofillable());
1742 ASSERT_EQ(11U, form_structure->field_count()); 1742 ASSERT_EQ(11U, form_structure->field_count());
1743 ASSERT_EQ(11U, form_structure->autofill_count()); 1743 ASSERT_EQ(11U, form_structure->autofill_count());
1744 1744
1745 EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type()); 1745 EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type());
1746 EXPECT_EQ(NAME_LAST, form_structure->field(1)->heuristic_type()); 1746 EXPECT_EQ(NAME_LAST, form_structure->field(1)->heuristic_type());
1747 EXPECT_EQ(COMPANY_NAME, form_structure->field(2)->heuristic_type()); 1747 EXPECT_EQ(COMPANY_NAME, form_structure->field(2)->heuristic_type());
1748 EXPECT_EQ(ADDRESS_HOME_LINE1, form_structure->field(3)->heuristic_type()); 1748 EXPECT_EQ(ADDRESS_HOME_LINE1, form_structure->field(3)->heuristic_type());
1749 EXPECT_EQ(ADDRESS_HOME_LINE2, form_structure->field(4)->heuristic_type()); 1749 EXPECT_EQ(ADDRESS_HOME_LINE2, form_structure->field(4)->heuristic_type());
1750 EXPECT_EQ(ADDRESS_HOME_CITY, form_structure->field(5)->heuristic_type()); 1750 EXPECT_EQ(ADDRESS_HOME_CITY, form_structure->field(5)->heuristic_type());
(...skipping 28 matching lines...) Expand all
1779 // passed, phone will be parsed as 1779 // passed, phone will be parsed as
1780 // <country code> - <area code> - <phone>. 1780 // <country code> - <area code> - <phone>.
1781 form.fields.push_back(field); 1781 form.fields.push_back(field);
1782 1782
1783 field.label = ASCIIToUTF16("ext.:"); 1783 field.label = ASCIIToUTF16("ext.:");
1784 field.name = ASCIIToUTF16("dayphone4"); 1784 field.name = ASCIIToUTF16("dayphone4");
1785 field.max_length = 0; 1785 field.max_length = 0;
1786 form.fields.push_back(field); 1786 form.fields.push_back(field);
1787 1787
1788 form_structure.reset(new FormStructure(form)); 1788 form_structure.reset(new FormStructure(form));
1789 form_structure->DetermineHeuristicTypes(); 1789 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */);
1790 EXPECT_TRUE(form_structure->IsAutofillable()); 1790 EXPECT_TRUE(form_structure->IsAutofillable());
1791 ASSERT_EQ(4U, form_structure->field_count()); 1791 ASSERT_EQ(4U, form_structure->field_count());
1792 ASSERT_EQ(4U, form_structure->autofill_count()); 1792 ASSERT_EQ(4U, form_structure->autofill_count());
1793 1793
1794 // Area code. 1794 // Area code.
1795 EXPECT_EQ(PHONE_HOME_CITY_CODE, form_structure->field(0)->heuristic_type()); 1795 EXPECT_EQ(PHONE_HOME_CITY_CODE, form_structure->field(0)->heuristic_type());
1796 // Phone number suffix. 1796 // Phone number suffix.
1797 EXPECT_EQ(PHONE_HOME_NUMBER, 1797 EXPECT_EQ(PHONE_HOME_NUMBER,
1798 form_structure->field(1)->heuristic_type()); 1798 form_structure->field(1)->heuristic_type());
1799 // Phone number suffix. 1799 // Phone number suffix.
(...skipping 24 matching lines...) Expand all
1824 1824
1825 field.label = ASCIIToUTF16("Expiration Date"); 1825 field.label = ASCIIToUTF16("Expiration Date");
1826 field.name = ASCIIToUTF16("expiration_month"); 1826 field.name = ASCIIToUTF16("expiration_month");
1827 form.fields.push_back(field); 1827 form.fields.push_back(field);
1828 1828
1829 field.label = ASCIIToUTF16("Expiration Year"); 1829 field.label = ASCIIToUTF16("Expiration Year");
1830 field.name = ASCIIToUTF16("expiration_year"); 1830 field.name = ASCIIToUTF16("expiration_year");
1831 form.fields.push_back(field); 1831 form.fields.push_back(field);
1832 1832
1833 form_structure.reset(new FormStructure(form)); 1833 form_structure.reset(new FormStructure(form));
1834 form_structure->DetermineHeuristicTypes(); 1834 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */);
1835 EXPECT_TRUE(form_structure->IsAutofillable()); 1835 EXPECT_TRUE(form_structure->IsAutofillable());
1836 1836
1837 // Expect the correct number of fields. 1837 // Expect the correct number of fields.
1838 ASSERT_EQ(5U, form_structure->field_count()); 1838 ASSERT_EQ(5U, form_structure->field_count());
1839 EXPECT_EQ(5U, form_structure->autofill_count()); 1839 EXPECT_EQ(5U, form_structure->autofill_count());
1840 1840
1841 // Name on Card. 1841 // Name on Card.
1842 EXPECT_EQ(CREDIT_CARD_NAME_FULL, form_structure->field(0)->heuristic_type()); 1842 EXPECT_EQ(CREDIT_CARD_NAME_FULL, form_structure->field(0)->heuristic_type());
1843 // Address. 1843 // Address.
1844 EXPECT_EQ(ADDRESS_HOME_LINE1, form_structure->field(1)->heuristic_type()); 1844 EXPECT_EQ(ADDRESS_HOME_LINE1, form_structure->field(1)->heuristic_type());
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1878 1878
1879 field.label = base::string16(); 1879 field.label = base::string16();
1880 field.name = ASCIIToUTF16("ccexpiresyear"); 1880 field.name = ASCIIToUTF16("ccexpiresyear");
1881 form.fields.push_back(field); 1881 form.fields.push_back(field);
1882 1882
1883 field.label = ASCIIToUTF16("cvc number"); 1883 field.label = ASCIIToUTF16("cvc number");
1884 field.name = ASCIIToUTF16("csc"); 1884 field.name = ASCIIToUTF16("csc");
1885 form.fields.push_back(field); 1885 form.fields.push_back(field);
1886 1886
1887 form_structure.reset(new FormStructure(form)); 1887 form_structure.reset(new FormStructure(form));
1888 form_structure->DetermineHeuristicTypes(); 1888 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */);
1889 EXPECT_TRUE(form_structure->IsAutofillable()); 1889 EXPECT_TRUE(form_structure->IsAutofillable());
1890 1890
1891 // Expect the correct number of fields. 1891 // Expect the correct number of fields.
1892 ASSERT_EQ(6U, form_structure->field_count()); 1892 ASSERT_EQ(6U, form_structure->field_count());
1893 ASSERT_EQ(6U, form_structure->autofill_count()); 1893 ASSERT_EQ(6U, form_structure->autofill_count());
1894 1894
1895 // Card Number. 1895 // Card Number.
1896 EXPECT_EQ(CREDIT_CARD_NUMBER, form_structure->field(0)->heuristic_type()); 1896 EXPECT_EQ(CREDIT_CARD_NUMBER, form_structure->field(0)->heuristic_type());
1897 // First name. 1897 // First name.
1898 EXPECT_EQ(CREDIT_CARD_NAME_FIRST, form_structure->field(1)->heuristic_type()); 1898 EXPECT_EQ(CREDIT_CARD_NAME_FIRST, form_structure->field(1)->heuristic_type());
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1936 1936
1937 field.label = base::string16(); 1937 field.label = base::string16();
1938 field.name = ASCIIToUTF16("ccexpiresyear"); 1938 field.name = ASCIIToUTF16("ccexpiresyear");
1939 form.fields.push_back(field); 1939 form.fields.push_back(field);
1940 1940
1941 field.label = ASCIIToUTF16("cvc number"); 1941 field.label = ASCIIToUTF16("cvc number");
1942 field.name = ASCIIToUTF16("csc"); 1942 field.name = ASCIIToUTF16("csc");
1943 form.fields.push_back(field); 1943 form.fields.push_back(field);
1944 1944
1945 form_structure.reset(new FormStructure(form)); 1945 form_structure.reset(new FormStructure(form));
1946 form_structure->DetermineHeuristicTypes(); 1946 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */);
1947 EXPECT_TRUE(form_structure->IsAutofillable()); 1947 EXPECT_TRUE(form_structure->IsAutofillable());
1948 1948
1949 // Expect the correct number of fields. 1949 // Expect the correct number of fields.
1950 ASSERT_EQ(6U, form_structure->field_count()); 1950 ASSERT_EQ(6U, form_structure->field_count());
1951 ASSERT_EQ(6U, form_structure->autofill_count()); 1951 ASSERT_EQ(6U, form_structure->autofill_count());
1952 1952
1953 // First name. 1953 // First name.
1954 EXPECT_EQ(CREDIT_CARD_NAME_FIRST, form_structure->field(0)->heuristic_type()); 1954 EXPECT_EQ(CREDIT_CARD_NAME_FIRST, form_structure->field(0)->heuristic_type());
1955 // Last name. 1955 // Last name.
1956 EXPECT_EQ(CREDIT_CARD_NAME_LAST, form_structure->field(1)->heuristic_type()); 1956 EXPECT_EQ(CREDIT_CARD_NAME_LAST, form_structure->field(1)->heuristic_type());
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
2119 AutofillQueryContents encoded_query5; 2119 AutofillQueryContents encoded_query5;
2120 EXPECT_FALSE(FormStructure::EncodeQueryRequest(bad_forms, &encoded_signatures, 2120 EXPECT_FALSE(FormStructure::EncodeQueryRequest(bad_forms, &encoded_signatures,
2121 &encoded_query5)); 2121 &encoded_query5));
2122 } 2122 }
2123 2123
2124 TEST_F(FormStructureTest, EncodeUploadRequest) { 2124 TEST_F(FormStructureTest, EncodeUploadRequest) {
2125 std::unique_ptr<FormStructure> form_structure; 2125 std::unique_ptr<FormStructure> form_structure;
2126 std::vector<ServerFieldTypeSet> possible_field_types; 2126 std::vector<ServerFieldTypeSet> possible_field_types;
2127 FormData form; 2127 FormData form;
2128 form_structure.reset(new FormStructure(form)); 2128 form_structure.reset(new FormStructure(form));
2129 form_structure->DetermineHeuristicTypes(); 2129 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */);
2130 2130
2131 FormFieldData field; 2131 FormFieldData field;
2132 field.form_control_type = "text"; 2132 field.form_control_type = "text";
2133 2133
2134 field.label = ASCIIToUTF16("First Name"); 2134 field.label = ASCIIToUTF16("First Name");
2135 field.name = ASCIIToUTF16("firstname"); 2135 field.name = ASCIIToUTF16("firstname");
2136 form.fields.push_back(field); 2136 form.fields.push_back(field);
2137 possible_field_types.push_back(ServerFieldTypeSet()); 2137 possible_field_types.push_back(ServerFieldTypeSet());
2138 possible_field_types.back().insert(NAME_FIRST); 2138 possible_field_types.back().insert(NAME_FIRST);
2139 2139
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
2295 EXPECT_FALSE(form_structure->EncodeUploadRequest( 2295 EXPECT_FALSE(form_structure->EncodeUploadRequest(
2296 available_field_types, false, std::string(), true, &encoded_upload4)); 2296 available_field_types, false, std::string(), true, &encoded_upload4));
2297 } 2297 }
2298 2298
2299 TEST_F(FormStructureTest, 2299 TEST_F(FormStructureTest,
2300 EncodeUploadRequestWithAdditionalPasswordFormSignature) { 2300 EncodeUploadRequestWithAdditionalPasswordFormSignature) {
2301 std::unique_ptr<FormStructure> form_structure; 2301 std::unique_ptr<FormStructure> form_structure;
2302 std::vector<ServerFieldTypeSet> possible_field_types; 2302 std::vector<ServerFieldTypeSet> possible_field_types;
2303 FormData form; 2303 FormData form;
2304 form_structure.reset(new FormStructure(form)); 2304 form_structure.reset(new FormStructure(form));
2305 form_structure->DetermineHeuristicTypes(); 2305 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */);
2306 2306
2307 FormFieldData field; 2307 FormFieldData field;
2308 field.label = ASCIIToUTF16("First Name"); 2308 field.label = ASCIIToUTF16("First Name");
2309 field.name = ASCIIToUTF16("firstname"); 2309 field.name = ASCIIToUTF16("firstname");
2310 field.autocomplete_attribute = "given-name"; 2310 field.autocomplete_attribute = "given-name";
2311 form.fields.push_back(field); 2311 form.fields.push_back(field);
2312 possible_field_types.push_back(ServerFieldTypeSet()); 2312 possible_field_types.push_back(ServerFieldTypeSet());
2313 possible_field_types.back().insert(NAME_FIRST); 2313 possible_field_types.back().insert(NAME_FIRST);
2314 2314
2315 field.label = ASCIIToUTF16("Last Name"); 2315 field.label = ASCIIToUTF16("Last Name");
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
2434 std::string encoded_upload_string; 2434 std::string encoded_upload_string;
2435 encoded_upload.SerializeToString(&encoded_upload_string); 2435 encoded_upload.SerializeToString(&encoded_upload_string);
2436 EXPECT_EQ(expected_upload_string, encoded_upload_string); 2436 EXPECT_EQ(expected_upload_string, encoded_upload_string);
2437 } 2437 }
2438 2438
2439 TEST_F(FormStructureTest, EncodeUploadRequest_WithAutocomplete) { 2439 TEST_F(FormStructureTest, EncodeUploadRequest_WithAutocomplete) {
2440 std::unique_ptr<FormStructure> form_structure; 2440 std::unique_ptr<FormStructure> form_structure;
2441 std::vector<ServerFieldTypeSet> possible_field_types; 2441 std::vector<ServerFieldTypeSet> possible_field_types;
2442 FormData form; 2442 FormData form;
2443 form_structure.reset(new FormStructure(form)); 2443 form_structure.reset(new FormStructure(form));
2444 form_structure->DetermineHeuristicTypes(); 2444 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */);
2445 2445
2446 FormFieldData field; 2446 FormFieldData field;
2447 field.form_control_type = "text"; 2447 field.form_control_type = "text";
2448 2448
2449 field.label = ASCIIToUTF16("First Name"); 2449 field.label = ASCIIToUTF16("First Name");
2450 field.name = ASCIIToUTF16("firstname"); 2450 field.name = ASCIIToUTF16("firstname");
2451 field.autocomplete_attribute = "given-name"; 2451 field.autocomplete_attribute = "given-name";
2452 form.fields.push_back(field); 2452 form.fields.push_back(field);
2453 possible_field_types.push_back(ServerFieldTypeSet()); 2453 possible_field_types.push_back(ServerFieldTypeSet());
2454 possible_field_types.back().insert(NAME_FIRST); 2454 possible_field_types.back().insert(NAME_FIRST);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
2505 std::string encoded_upload_string; 2505 std::string encoded_upload_string;
2506 encoded_upload.SerializeToString(&encoded_upload_string); 2506 encoded_upload.SerializeToString(&encoded_upload_string);
2507 EXPECT_EQ(expected_upload_string, encoded_upload_string); 2507 EXPECT_EQ(expected_upload_string, encoded_upload_string);
2508 } 2508 }
2509 2509
2510 TEST_F(FormStructureTest, EncodeUploadRequest_ObservedSubmissionFalse) { 2510 TEST_F(FormStructureTest, EncodeUploadRequest_ObservedSubmissionFalse) {
2511 std::unique_ptr<FormStructure> form_structure; 2511 std::unique_ptr<FormStructure> form_structure;
2512 std::vector<ServerFieldTypeSet> possible_field_types; 2512 std::vector<ServerFieldTypeSet> possible_field_types;
2513 FormData form; 2513 FormData form;
2514 form_structure.reset(new FormStructure(form)); 2514 form_structure.reset(new FormStructure(form));
2515 form_structure->DetermineHeuristicTypes(); 2515 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */);
2516 2516
2517 FormFieldData field; 2517 FormFieldData field;
2518 field.form_control_type = "text"; 2518 field.form_control_type = "text";
2519 2519
2520 field.label = ASCIIToUTF16("First Name"); 2520 field.label = ASCIIToUTF16("First Name");
2521 field.name = ASCIIToUTF16("firstname"); 2521 field.name = ASCIIToUTF16("firstname");
2522 form.fields.push_back(field); 2522 form.fields.push_back(field);
2523 possible_field_types.push_back(ServerFieldTypeSet()); 2523 possible_field_types.push_back(ServerFieldTypeSet());
2524 possible_field_types.back().insert(NAME_FIRST); 2524 possible_field_types.back().insert(NAME_FIRST);
2525 2525
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
2574 std::string encoded_upload_string; 2574 std::string encoded_upload_string;
2575 encoded_upload.SerializeToString(&encoded_upload_string); 2575 encoded_upload.SerializeToString(&encoded_upload_string);
2576 EXPECT_EQ(expected_upload_string, encoded_upload_string); 2576 EXPECT_EQ(expected_upload_string, encoded_upload_string);
2577 } 2577 }
2578 2578
2579 TEST_F(FormStructureTest, EncodeUploadRequest_WithLabels) { 2579 TEST_F(FormStructureTest, EncodeUploadRequest_WithLabels) {
2580 std::unique_ptr<FormStructure> form_structure; 2580 std::unique_ptr<FormStructure> form_structure;
2581 std::vector<ServerFieldTypeSet> possible_field_types; 2581 std::vector<ServerFieldTypeSet> possible_field_types;
2582 FormData form; 2582 FormData form;
2583 form_structure.reset(new FormStructure(form)); 2583 form_structure.reset(new FormStructure(form));
2584 form_structure->DetermineHeuristicTypes(); 2584 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */);
2585 2585
2586 FormFieldData field; 2586 FormFieldData field;
2587 field.form_control_type = "text"; 2587 field.form_control_type = "text";
2588 2588
2589 // No label for the first field. 2589 // No label for the first field.
2590 form.fields.push_back(field); 2590 form.fields.push_back(field);
2591 possible_field_types.push_back(ServerFieldTypeSet()); 2591 possible_field_types.push_back(ServerFieldTypeSet());
2592 possible_field_types.back().insert(NAME_FIRST); 2592 possible_field_types.back().insert(NAME_FIRST);
2593 2593
2594 field.label = ASCIIToUTF16("Last Name"); 2594 field.label = ASCIIToUTF16("Last Name");
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
2711 } 2711 }
2712 2712
2713 // Test that the form name is sent in the upload request. 2713 // Test that the form name is sent in the upload request.
2714 TEST_F(FormStructureTest, EncodeUploadRequest_WithFormName) { 2714 TEST_F(FormStructureTest, EncodeUploadRequest_WithFormName) {
2715 std::unique_ptr<FormStructure> form_structure; 2715 std::unique_ptr<FormStructure> form_structure;
2716 std::vector<ServerFieldTypeSet> possible_field_types; 2716 std::vector<ServerFieldTypeSet> possible_field_types;
2717 FormData form; 2717 FormData form;
2718 // Setting the form name which we expect to see in the upload. 2718 // Setting the form name which we expect to see in the upload.
2719 form.name = ASCIIToUTF16("myform"); 2719 form.name = ASCIIToUTF16("myform");
2720 form_structure.reset(new FormStructure(form)); 2720 form_structure.reset(new FormStructure(form));
2721 form_structure->DetermineHeuristicTypes(); 2721 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */);
2722 2722
2723 FormFieldData field; 2723 FormFieldData field;
2724 field.form_control_type = "text"; 2724 field.form_control_type = "text";
2725 2725
2726 form.fields.push_back(field); 2726 form.fields.push_back(field);
2727 possible_field_types.push_back(ServerFieldTypeSet()); 2727 possible_field_types.push_back(ServerFieldTypeSet());
2728 possible_field_types.back().insert(NAME_FIRST); 2728 possible_field_types.back().insert(NAME_FIRST);
2729 2729
2730 form.fields.push_back(field); 2730 form.fields.push_back(field);
2731 possible_field_types.push_back(ServerFieldTypeSet()); 2731 possible_field_types.push_back(ServerFieldTypeSet());
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
2773 std::string encoded_upload_string; 2773 std::string encoded_upload_string;
2774 encoded_upload.SerializeToString(&encoded_upload_string); 2774 encoded_upload.SerializeToString(&encoded_upload_string);
2775 EXPECT_EQ(expected_upload_string, encoded_upload_string); 2775 EXPECT_EQ(expected_upload_string, encoded_upload_string);
2776 } 2776 }
2777 2777
2778 TEST_F(FormStructureTest, EncodeUploadRequestPartialMetadata) { 2778 TEST_F(FormStructureTest, EncodeUploadRequestPartialMetadata) {
2779 std::unique_ptr<FormStructure> form_structure; 2779 std::unique_ptr<FormStructure> form_structure;
2780 std::vector<ServerFieldTypeSet> possible_field_types; 2780 std::vector<ServerFieldTypeSet> possible_field_types;
2781 FormData form; 2781 FormData form;
2782 form_structure.reset(new FormStructure(form)); 2782 form_structure.reset(new FormStructure(form));
2783 form_structure->DetermineHeuristicTypes(); 2783 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */);
2784 2784
2785 FormFieldData field; 2785 FormFieldData field;
2786 field.form_control_type = "text"; 2786 field.form_control_type = "text";
2787 2787
2788 // Some fields don't have "name" or "autocomplete" attributes, and some have 2788 // Some fields don't have "name" or "autocomplete" attributes, and some have
2789 // neither. 2789 // neither.
2790 // No label. 2790 // No label.
2791 form.fields.push_back(field); 2791 form.fields.push_back(field);
2792 possible_field_types.push_back(ServerFieldTypeSet()); 2792 possible_field_types.push_back(ServerFieldTypeSet());
2793 possible_field_types.back().insert(NAME_FIRST); 2793 possible_field_types.back().insert(NAME_FIRST);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
2846 } 2846 }
2847 2847
2848 // Sending field metadata to the server is disabled. 2848 // Sending field metadata to the server is disabled.
2849 TEST_F(FormStructureTest, EncodeUploadRequest_DisabledMetadataTrial) { 2849 TEST_F(FormStructureTest, EncodeUploadRequest_DisabledMetadataTrial) {
2850 DisableAutofillMetadataFieldTrial(); 2850 DisableAutofillMetadataFieldTrial();
2851 2851
2852 std::unique_ptr<FormStructure> form_structure; 2852 std::unique_ptr<FormStructure> form_structure;
2853 std::vector<ServerFieldTypeSet> possible_field_types; 2853 std::vector<ServerFieldTypeSet> possible_field_types;
2854 FormData form; 2854 FormData form;
2855 form_structure.reset(new FormStructure(form)); 2855 form_structure.reset(new FormStructure(form));
2856 form_structure->DetermineHeuristicTypes(); 2856 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */);
2857 2857
2858 FormFieldData field; 2858 FormFieldData field;
2859 field.form_control_type = "text"; 2859 field.form_control_type = "text";
2860 2860
2861 field.label = ASCIIToUTF16("First Name"); 2861 field.label = ASCIIToUTF16("First Name");
2862 field.name = ASCIIToUTF16("firstname"); 2862 field.name = ASCIIToUTF16("firstname");
2863 field.id = ASCIIToUTF16("first_name"); 2863 field.id = ASCIIToUTF16("first_name");
2864 field.autocomplete_attribute = "given-name"; 2864 field.autocomplete_attribute = "given-name";
2865 field.css_classes = ASCIIToUTF16("class1 class2"); 2865 field.css_classes = ASCIIToUTF16("class1 class2");
2866 form.fields.push_back(field); 2866 form.fields.push_back(field);
(...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after
3774 3774
3775 field.label = ASCIIToUTF16("password"); 3775 field.label = ASCIIToUTF16("password");
3776 field.name = ASCIIToUTF16("password"); 3776 field.name = ASCIIToUTF16("password");
3777 field.form_control_type = "password"; 3777 field.form_control_type = "password";
3778 field.autocomplete_attribute = "new-password"; 3778 field.autocomplete_attribute = "new-password";
3779 form.fields.push_back(field); 3779 form.fields.push_back(field);
3780 3780
3781 FormStructure form_structure(form); 3781 FormStructure form_structure(form);
3782 std::vector<FormStructure*> forms; 3782 std::vector<FormStructure*> forms;
3783 forms.push_back(&form_structure); 3783 forms.push_back(&form_structure);
3784 forms.front()->DetermineHeuristicTypes(); 3784 forms.front()->DetermineHeuristicTypes(nullptr /* ukm_service */);
3785 3785
3786 AutofillQueryResponseContents response; 3786 AutofillQueryResponseContents response;
3787 response.add_field()->set_autofill_type(EMAIL_ADDRESS); 3787 response.add_field()->set_autofill_type(EMAIL_ADDRESS);
3788 response.add_field()->set_autofill_type(ACCOUNT_CREATION_PASSWORD); 3788 response.add_field()->set_autofill_type(ACCOUNT_CREATION_PASSWORD);
3789 3789
3790 std::string response_string; 3790 std::string response_string;
3791 ASSERT_TRUE(response.SerializeToString(&response_string)); 3791 ASSERT_TRUE(response.SerializeToString(&response_string));
3792 FormStructure::ParseQueryResponse(response_string, forms, nullptr); 3792 FormStructure::ParseQueryResponse(response_string, forms, nullptr);
3793 3793
3794 ASSERT_GE(forms[0]->field_count(), 2U); 3794 ASSERT_GE(forms[0]->field_count(), 2U);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
3835 prefix = FormStructure::FindLongestCommonPrefix(strings); 3835 prefix = FormStructure::FindLongestCommonPrefix(strings);
3836 EXPECT_EQ(ASCIIToUTF16("1234567890123456"), prefix); 3836 EXPECT_EQ(ASCIIToUTF16("1234567890123456"), prefix);
3837 3837
3838 // Empty vector. 3838 // Empty vector.
3839 strings.clear(); 3839 strings.clear();
3840 prefix = FormStructure::FindLongestCommonPrefix(strings); 3840 prefix = FormStructure::FindLongestCommonPrefix(strings);
3841 EXPECT_EQ(ASCIIToUTF16(""), prefix); 3841 EXPECT_EQ(ASCIIToUTF16(""), prefix);
3842 } 3842 }
3843 3843
3844 } // namespace autofill 3844 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/form_structure.cc ('k') | components/autofill/core/browser/personal_data_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698