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

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: Adds UKM for autofill attributes in form_structure. 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 */, GURL());
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 */, GURL());
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 */, GURL());
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 */, GURL());
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 */, GURL());
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 */, GURL());
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 */, GURL());
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 */, GURL());
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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 field.name = ASCIIToUTF16("field2"); 450 field.name = ASCIIToUTF16("field2");
451 field.autocomplete_attribute = "family-name"; 451 field.autocomplete_attribute = "family-name";
452 form.fields.push_back(field); 452 form.fields.push_back(field);
453 453
454 field.label = base::string16(); 454 field.label = base::string16();
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 form_structure.reset(new FormStructure(form)); 459 form_structure.reset(new FormStructure(form));
460 form_structure->DetermineHeuristicTypes(); 460 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */, GURL());
461 EXPECT_TRUE(form_structure->IsAutofillable()); 461 EXPECT_TRUE(form_structure->IsAutofillable());
462 462
463 // Expect the correct number of fields. 463 // Expect the correct number of fields.
464 ASSERT_EQ(3U, form_structure->field_count()); 464 ASSERT_EQ(3U, form_structure->field_count());
465 ASSERT_EQ(3U, form_structure->autofill_count()); 465 ASSERT_EQ(3U, form_structure->autofill_count());
466 466
467 EXPECT_EQ(HTML_TYPE_GIVEN_NAME, form_structure->field(0)->html_type()); 467 EXPECT_EQ(HTML_TYPE_GIVEN_NAME, form_structure->field(0)->html_type());
468 EXPECT_EQ(HTML_TYPE_FAMILY_NAME, form_structure->field(1)->html_type()); 468 EXPECT_EQ(HTML_TYPE_FAMILY_NAME, form_structure->field(1)->html_type());
469 EXPECT_EQ(HTML_TYPE_EMAIL, form_structure->field(2)->html_type()); 469 EXPECT_EQ(HTML_TYPE_EMAIL, form_structure->field(2)->html_type());
470 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(0)->heuristic_type()); 470 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(0)->heuristic_type());
(...skipping 18 matching lines...) Expand all
489 field.name = ASCIIToUTF16("lastname"); 489 field.name = ASCIIToUTF16("lastname");
490 field.autocomplete_attribute = "family-name"; 490 field.autocomplete_attribute = "family-name";
491 form.fields.push_back(field); 491 form.fields.push_back(field);
492 492
493 field.label = ASCIIToUTF16("Email:"); 493 field.label = ASCIIToUTF16("Email:");
494 field.name = ASCIIToUTF16("email"); 494 field.name = ASCIIToUTF16("email");
495 field.autocomplete_attribute = "email"; 495 field.autocomplete_attribute = "email";
496 form.fields.push_back(field); 496 form.fields.push_back(field);
497 497
498 form_structure.reset(new FormStructure(form)); 498 form_structure.reset(new FormStructure(form));
499 form_structure->DetermineHeuristicTypes(); 499 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */, GURL());
500 EXPECT_TRUE(form_structure->IsAutofillable()); 500 EXPECT_TRUE(form_structure->IsAutofillable());
501 501
502 // Expect the correct number of fields. 502 // Expect the correct number of fields.
503 ASSERT_EQ(3U, form_structure->field_count()); 503 ASSERT_EQ(3U, form_structure->field_count());
504 ASSERT_EQ(3U, form_structure->autofill_count()); 504 ASSERT_EQ(3U, form_structure->autofill_count());
505 505
506 // The heuristic type should be good. 506 // The heuristic type should be good.
507 EXPECT_EQ(HTML_TYPE_GIVEN_NAME, form_structure->field(0)->html_type()); 507 EXPECT_EQ(HTML_TYPE_GIVEN_NAME, form_structure->field(0)->html_type());
508 EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type()); 508 EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type());
509 509
510 // Set the form as a formless non checkout form. 510 // Set the form as a formless non checkout form.
511 form.is_formless_checkout = false; 511 form.is_formless_checkout = false;
512 form.is_form_tag = false; 512 form.is_form_tag = false;
513 513
514 form_structure.reset(new FormStructure(form)); 514 form_structure.reset(new FormStructure(form));
515 form_structure->DetermineHeuristicTypes(); 515 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */, GURL());
516 EXPECT_TRUE(form_structure->IsAutofillable()); 516 EXPECT_TRUE(form_structure->IsAutofillable());
517 517
518 // Expect the correct number of fields. 518 // Expect the correct number of fields.
519 ASSERT_EQ(3U, form_structure->field_count()); 519 ASSERT_EQ(3U, form_structure->field_count());
520 ASSERT_EQ(3U, form_structure->autofill_count()); 520 ASSERT_EQ(3U, form_structure->autofill_count());
521 521
522 // The heuristic type should be Unknown. 522 // The heuristic type should be Unknown.
523 EXPECT_EQ(HTML_TYPE_GIVEN_NAME, form_structure->field(0)->html_type()); 523 EXPECT_EQ(HTML_TYPE_GIVEN_NAME, form_structure->field(0)->html_type());
524 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(0)->heuristic_type()); 524 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(0)->heuristic_type());
525 } 525 }
(...skipping 20 matching lines...) Expand all
546 field.label = ASCIIToUTF16("Phone"); 546 field.label = ASCIIToUTF16("Phone");
547 field.name = ASCIIToUTF16("ctl01$ctl00$ShippingAddressCreditPhone$phone"); 547 field.name = ASCIIToUTF16("ctl01$ctl00$ShippingAddressCreditPhone$phone");
548 form.fields.push_back(field); 548 form.fields.push_back(field);
549 549
550 field.label = base::string16(); 550 field.label = base::string16();
551 field.name = ASCIIToUTF16("ctl01$ctl00$ShippingAddressCreditPhone$submit"); 551 field.name = ASCIIToUTF16("ctl01$ctl00$ShippingAddressCreditPhone$submit");
552 field.form_control_type = "submit"; 552 field.form_control_type = "submit";
553 form.fields.push_back(field); 553 form.fields.push_back(field);
554 554
555 std::unique_ptr<FormStructure> form_structure(new FormStructure(form)); 555 std::unique_ptr<FormStructure> form_structure(new FormStructure(form));
556 form_structure->DetermineHeuristicTypes(); 556 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */, GURL());
557 EXPECT_TRUE(form_structure->IsAutofillable()); 557 EXPECT_TRUE(form_structure->IsAutofillable());
558 558
559 // Expect the correct number of fields. 559 // Expect the correct number of fields.
560 ASSERT_EQ(5U, form_structure->field_count()); 560 ASSERT_EQ(5U, form_structure->field_count());
561 ASSERT_EQ(4U, form_structure->autofill_count()); 561 ASSERT_EQ(4U, form_structure->autofill_count());
562 562
563 // First name. 563 // First name.
564 EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type()); 564 EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type());
565 // Last name. 565 // Last name.
566 EXPECT_EQ(NAME_LAST, form_structure->field(1)->heuristic_type()); 566 EXPECT_EQ(NAME_LAST, form_structure->field(1)->heuristic_type());
(...skipping 19 matching lines...) Expand all
586 586
587 field.label = ASCIIToUTF16("Address 2"); 587 field.label = ASCIIToUTF16("Address 2");
588 field.name = ASCIIToUTF16("address2"); 588 field.name = ASCIIToUTF16("address2");
589 form.fields.push_back(field); 589 form.fields.push_back(field);
590 590
591 field.label = ASCIIToUTF16("Address 3"); 591 field.label = ASCIIToUTF16("Address 3");
592 field.name = ASCIIToUTF16("address3"); 592 field.name = ASCIIToUTF16("address3");
593 form.fields.push_back(field); 593 form.fields.push_back(field);
594 594
595 std::unique_ptr<FormStructure> form_structure(new FormStructure(form)); 595 std::unique_ptr<FormStructure> form_structure(new FormStructure(form));
596 form_structure->DetermineHeuristicTypes(); 596 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */, GURL());
597 EXPECT_TRUE(form_structure->IsAutofillable()); 597 EXPECT_TRUE(form_structure->IsAutofillable());
598 598
599 // Expect the correct number of fields. 599 // Expect the correct number of fields.
600 ASSERT_EQ(3U, form_structure->field_count()); 600 ASSERT_EQ(3U, form_structure->field_count());
601 ASSERT_EQ(3U, form_structure->autofill_count()); 601 ASSERT_EQ(3U, form_structure->autofill_count());
602 602
603 // Address 1. 603 // Address 1.
604 EXPECT_EQ(ADDRESS_HOME_LINE1, form_structure->field(0)->heuristic_type()); 604 EXPECT_EQ(ADDRESS_HOME_LINE1, form_structure->field(0)->heuristic_type());
605 // Address 2. 605 // Address 2.
606 EXPECT_EQ(ADDRESS_HOME_LINE2, form_structure->field(1)->heuristic_type()); 606 EXPECT_EQ(ADDRESS_HOME_LINE2, form_structure->field(1)->heuristic_type());
(...skipping 15 matching lines...) Expand all
622 field.label = ASCIIToUTF16("Expiration"); 622 field.label = ASCIIToUTF16("Expiration");
623 field.name = ASCIIToUTF16("cc_exp"); 623 field.name = ASCIIToUTF16("cc_exp");
624 form.fields.push_back(field); 624 form.fields.push_back(field);
625 625
626 // Another field to reach the minimum 3. 626 // Another field to reach the minimum 3.
627 field.label = ASCIIToUTF16("Zip"); 627 field.label = ASCIIToUTF16("Zip");
628 field.name = ASCIIToUTF16("zip"); 628 field.name = ASCIIToUTF16("zip");
629 form.fields.push_back(field); 629 form.fields.push_back(field);
630 630
631 form_structure.reset(new FormStructure(form)); 631 form_structure.reset(new FormStructure(form));
632 form_structure->DetermineHeuristicTypes(); 632 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */, GURL());
633 633
634 EXPECT_TRUE(form_structure->IsCompleteCreditCardForm()); 634 EXPECT_TRUE(form_structure->IsCompleteCreditCardForm());
635 } 635 }
636 636
637 TEST_F(FormStructureTest, IsCompleteCreditCardForm_Full) { 637 TEST_F(FormStructureTest, IsCompleteCreditCardForm_Full) {
638 std::unique_ptr<FormStructure> form_structure; 638 std::unique_ptr<FormStructure> form_structure;
639 FormData form; 639 FormData form;
640 640
641 FormFieldData field; 641 FormFieldData field;
642 field.form_control_type = "text"; 642 field.form_control_type = "text";
(...skipping 17 matching lines...) Expand all
660 field.label = ASCIIToUTF16("Verification"); 660 field.label = ASCIIToUTF16("Verification");
661 field.name = ASCIIToUTF16("verification"); 661 field.name = ASCIIToUTF16("verification");
662 form.fields.push_back(field); 662 form.fields.push_back(field);
663 663
664 field.label = base::string16(); 664 field.label = base::string16();
665 field.name = ASCIIToUTF16("Submit"); 665 field.name = ASCIIToUTF16("Submit");
666 field.form_control_type = "submit"; 666 field.form_control_type = "submit";
667 form.fields.push_back(field); 667 form.fields.push_back(field);
668 668
669 form_structure.reset(new FormStructure(form)); 669 form_structure.reset(new FormStructure(form));
670 form_structure->DetermineHeuristicTypes(); 670 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */, GURL());
671 671
672 EXPECT_TRUE(form_structure->IsCompleteCreditCardForm()); 672 EXPECT_TRUE(form_structure->IsCompleteCreditCardForm());
673 } 673 }
674 674
675 // A form with only the credit card number is not considered sufficient. 675 // A form with only the credit card number is not considered sufficient.
676 TEST_F(FormStructureTest, IsCompleteCreditCardForm_OnlyCCNumber) { 676 TEST_F(FormStructureTest, IsCompleteCreditCardForm_OnlyCCNumber) {
677 std::unique_ptr<FormStructure> form_structure; 677 std::unique_ptr<FormStructure> form_structure;
678 FormData form; 678 FormData form;
679 679
680 FormFieldData field; 680 FormFieldData field;
681 field.form_control_type = "text"; 681 field.form_control_type = "text";
682 682
683 field.label = ASCIIToUTF16("Card Number"); 683 field.label = ASCIIToUTF16("Card Number");
684 field.name = ASCIIToUTF16("card_number"); 684 field.name = ASCIIToUTF16("card_number");
685 form.fields.push_back(field); 685 form.fields.push_back(field);
686 686
687 form_structure.reset(new FormStructure(form)); 687 form_structure.reset(new FormStructure(form));
688 form_structure->DetermineHeuristicTypes(); 688 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */, GURL());
689 689
690 EXPECT_FALSE(form_structure->IsCompleteCreditCardForm()); 690 EXPECT_FALSE(form_structure->IsCompleteCreditCardForm());
691 } 691 }
692 692
693 // A form with only the credit card number is not considered sufficient. 693 // A form with only the credit card number is not considered sufficient.
694 TEST_F(FormStructureTest, IsCompleteCreditCardForm_AddressForm) { 694 TEST_F(FormStructureTest, IsCompleteCreditCardForm_AddressForm) {
695 std::unique_ptr<FormStructure> form_structure; 695 std::unique_ptr<FormStructure> form_structure;
696 FormData form; 696 FormData form;
697 697
698 FormFieldData field; 698 FormFieldData field;
(...skipping 20 matching lines...) Expand all
719 form.fields.push_back(field); 719 form.fields.push_back(field);
720 720
721 field.label = ASCIIToUTF16("Address"); 721 field.label = ASCIIToUTF16("Address");
722 field.name = base::string16(); 722 field.name = base::string16();
723 form.fields.push_back(field); 723 form.fields.push_back(field);
724 724
725 field.label = ASCIIToUTF16("Zip code"); 725 field.label = ASCIIToUTF16("Zip code");
726 field.name = base::string16(); 726 field.name = base::string16();
727 form.fields.push_back(field); 727 form.fields.push_back(field);
728 form_structure.reset(new FormStructure(form)); 728 form_structure.reset(new FormStructure(form));
729 form_structure->DetermineHeuristicTypes(); 729 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */, GURL());
730 730
731 EXPECT_FALSE(form_structure->IsCompleteCreditCardForm()); 731 EXPECT_FALSE(form_structure->IsCompleteCreditCardForm());
732 } 732 }
733 733
734 // Verify that we can correctly process the 'autocomplete' attribute for phone 734 // Verify that we can correctly process the 'autocomplete' attribute for phone
735 // number types (especially phone prefixes and suffixes). 735 // number types (especially phone prefixes and suffixes).
736 TEST_F(FormStructureTest, HeuristicsAutocompleteAttributePhoneTypes) { 736 TEST_F(FormStructureTest, HeuristicsAutocompleteAttributePhoneTypes) {
737 std::unique_ptr<FormStructure> form_structure; 737 std::unique_ptr<FormStructure> form_structure;
738 FormData form; 738 FormData form;
739 739
740 FormFieldData field; 740 FormFieldData field;
741 field.form_control_type = "text"; 741 field.form_control_type = "text";
742 742
743 field.label = base::string16(); 743 field.label = base::string16();
744 field.name = ASCIIToUTF16("field1"); 744 field.name = ASCIIToUTF16("field1");
745 field.autocomplete_attribute = "tel-local"; 745 field.autocomplete_attribute = "tel-local";
746 form.fields.push_back(field); 746 form.fields.push_back(field);
747 747
748 field.label = base::string16(); 748 field.label = base::string16();
749 field.name = ASCIIToUTF16("field2"); 749 field.name = ASCIIToUTF16("field2");
750 field.autocomplete_attribute = "tel-local-prefix"; 750 field.autocomplete_attribute = "tel-local-prefix";
751 form.fields.push_back(field); 751 form.fields.push_back(field);
752 752
753 field.label = base::string16(); 753 field.label = base::string16();
754 field.name = ASCIIToUTF16("field3"); 754 field.name = ASCIIToUTF16("field3");
755 field.autocomplete_attribute = "tel-local-suffix"; 755 field.autocomplete_attribute = "tel-local-suffix";
756 form.fields.push_back(field); 756 form.fields.push_back(field);
757 757
758 form_structure.reset(new FormStructure(form)); 758 form_structure.reset(new FormStructure(form));
759 form_structure->DetermineHeuristicTypes(); 759 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */, GURL());
760 EXPECT_TRUE(form_structure->IsAutofillable()); 760 EXPECT_TRUE(form_structure->IsAutofillable());
761 761
762 // Expect the correct number of fields. 762 // Expect the correct number of fields.
763 ASSERT_EQ(3U, form_structure->field_count()); 763 ASSERT_EQ(3U, form_structure->field_count());
764 EXPECT_EQ(3U, form_structure->autofill_count()); 764 EXPECT_EQ(3U, form_structure->autofill_count());
765 765
766 EXPECT_EQ(HTML_TYPE_TEL_LOCAL, form_structure->field(0)->html_type()); 766 EXPECT_EQ(HTML_TYPE_TEL_LOCAL, form_structure->field(0)->html_type());
767 EXPECT_EQ(AutofillField::IGNORED, form_structure->field(0)->phone_part()); 767 EXPECT_EQ(AutofillField::IGNORED, form_structure->field(0)->phone_part());
768 EXPECT_EQ(HTML_TYPE_TEL_LOCAL_PREFIX, form_structure->field(1)->html_type()); 768 EXPECT_EQ(HTML_TYPE_TEL_LOCAL_PREFIX, form_structure->field(1)->html_type());
769 EXPECT_EQ(AutofillField::PHONE_PREFIX, 769 EXPECT_EQ(AutofillField::PHONE_PREFIX,
(...skipping 19 matching lines...) Expand all
789 789
790 field.label = ASCIIToUTF16("Last Name"); 790 field.label = ASCIIToUTF16("Last Name");
791 field.name = ASCIIToUTF16("lastname"); 791 field.name = ASCIIToUTF16("lastname");
792 form.fields.push_back(field); 792 form.fields.push_back(field);
793 793
794 field.label = ASCIIToUTF16("Email"); 794 field.label = ASCIIToUTF16("Email");
795 field.name = ASCIIToUTF16("email"); 795 field.name = ASCIIToUTF16("email");
796 form.fields.push_back(field); 796 form.fields.push_back(field);
797 797
798 form_structure.reset(new FormStructure(form)); 798 form_structure.reset(new FormStructure(form));
799 form_structure->DetermineHeuristicTypes(); 799 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */, GURL());
800 EXPECT_TRUE(form_structure->IsAutofillable()); 800 EXPECT_TRUE(form_structure->IsAutofillable());
801 EXPECT_TRUE(form_structure->ShouldBeCrowdsourced()); 801 EXPECT_TRUE(form_structure->ShouldBeCrowdsourced());
802 802
803 ASSERT_EQ(3U, form_structure->field_count()); 803 ASSERT_EQ(3U, form_structure->field_count());
804 ASSERT_EQ(3U, form_structure->autofill_count()); 804 ASSERT_EQ(3U, form_structure->autofill_count());
805 805
806 EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type()); 806 EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type());
807 EXPECT_EQ(NAME_LAST, form_structure->field(1)->heuristic_type()); 807 EXPECT_EQ(NAME_LAST, form_structure->field(1)->heuristic_type());
808 EXPECT_EQ(EMAIL_ADDRESS, form_structure->field(2)->heuristic_type()); 808 EXPECT_EQ(EMAIL_ADDRESS, form_structure->field(2)->heuristic_type());
809 } 809 }
(...skipping 17 matching lines...) Expand all
827 field.label = ASCIIToUTF16("Last Name"); 827 field.label = ASCIIToUTF16("Last Name");
828 field.name = ASCIIToUTF16("lastname"); 828 field.name = ASCIIToUTF16("lastname");
829 field.autocomplete_attribute = ""; 829 field.autocomplete_attribute = "";
830 form.fields.push_back(field); 830 form.fields.push_back(field);
831 831
832 field.label = ASCIIToUTF16("Email"); 832 field.label = ASCIIToUTF16("Email");
833 field.name = ASCIIToUTF16("email"); 833 field.name = ASCIIToUTF16("email");
834 form.fields.push_back(field); 834 form.fields.push_back(field);
835 835
836 form_structure.reset(new FormStructure(form)); 836 form_structure.reset(new FormStructure(form));
837 form_structure->DetermineHeuristicTypes(); 837 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */, GURL());
838 EXPECT_TRUE(form_structure->IsAutofillable()); 838 EXPECT_TRUE(form_structure->IsAutofillable());
839 EXPECT_TRUE(form_structure->ShouldBeCrowdsourced()); 839 EXPECT_TRUE(form_structure->ShouldBeCrowdsourced());
840 840
841 ASSERT_EQ(3U, form_structure->field_count()); 841 ASSERT_EQ(3U, form_structure->field_count());
842 ASSERT_EQ(3U, form_structure->autofill_count()); 842 ASSERT_EQ(3U, form_structure->autofill_count());
843 843
844 EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type()); 844 EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type());
845 EXPECT_EQ(NAME_LAST, form_structure->field(1)->heuristic_type()); 845 EXPECT_EQ(NAME_LAST, form_structure->field(1)->heuristic_type());
846 EXPECT_EQ(EMAIL_ADDRESS, form_structure->field(2)->heuristic_type()); 846 EXPECT_EQ(EMAIL_ADDRESS, form_structure->field(2)->heuristic_type());
847 } 847 }
(...skipping 22 matching lines...) Expand all
870 870
871 field.label = ASCIIToUTF16("Last Name"); 871 field.label = ASCIIToUTF16("Last Name");
872 field.name = ASCIIToUTF16("lastname"); 872 field.name = ASCIIToUTF16("lastname");
873 form.fields.push_back(field); 873 form.fields.push_back(field);
874 874
875 field.label = ASCIIToUTF16("Email"); 875 field.label = ASCIIToUTF16("Email");
876 field.name = ASCIIToUTF16("email"); 876 field.name = ASCIIToUTF16("email");
877 form.fields.push_back(field); 877 form.fields.push_back(field);
878 878
879 form_structure.reset(new FormStructure(form)); 879 form_structure.reset(new FormStructure(form));
880 form_structure->DetermineHeuristicTypes(); 880 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */, GURL());
881 EXPECT_TRUE(form_structure->IsAutofillable()); 881 EXPECT_TRUE(form_structure->IsAutofillable());
882 EXPECT_TRUE(form_structure->ShouldBeCrowdsourced()); 882 EXPECT_TRUE(form_structure->ShouldBeCrowdsourced());
883 883
884 ASSERT_EQ(4U, form_structure->field_count()); 884 ASSERT_EQ(4U, form_structure->field_count());
885 ASSERT_EQ(3U, form_structure->autofill_count()); 885 ASSERT_EQ(3U, form_structure->autofill_count());
886 886
887 EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type()); 887 EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type());
888 EXPECT_EQ(NAME_MIDDLE, form_structure->field(1)->heuristic_type()); 888 EXPECT_EQ(NAME_MIDDLE, form_structure->field(1)->heuristic_type());
889 EXPECT_EQ(NAME_LAST, form_structure->field(2)->heuristic_type()); 889 EXPECT_EQ(NAME_LAST, form_structure->field(2)->heuristic_type());
890 EXPECT_EQ(EMAIL_ADDRESS, form_structure->field(3)->heuristic_type()); 890 EXPECT_EQ(EMAIL_ADDRESS, form_structure->field(3)->heuristic_type());
(...skipping 11 matching lines...) Expand all
902 902
903 field.label = ASCIIToUTF16("First Name"); 903 field.label = ASCIIToUTF16("First Name");
904 field.name = ASCIIToUTF16("firstname"); 904 field.name = ASCIIToUTF16("firstname");
905 form.fields.push_back(field); 905 form.fields.push_back(field);
906 906
907 field.label = ASCIIToUTF16("Last Name"); 907 field.label = ASCIIToUTF16("Last Name");
908 field.name = ASCIIToUTF16("lastname"); 908 field.name = ASCIIToUTF16("lastname");
909 form.fields.push_back(field); 909 form.fields.push_back(field);
910 910
911 form_structure.reset(new FormStructure(form)); 911 form_structure.reset(new FormStructure(form));
912 form_structure->DetermineHeuristicTypes(); 912 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */, GURL());
913 EXPECT_FALSE(form_structure->IsAutofillable()); 913 EXPECT_FALSE(form_structure->IsAutofillable());
914 EXPECT_FALSE(form_structure->ShouldBeCrowdsourced()); 914 EXPECT_FALSE(form_structure->ShouldBeCrowdsourced());
915 915
916 ASSERT_EQ(2U, form_structure->field_count()); 916 ASSERT_EQ(2U, form_structure->field_count());
917 ASSERT_EQ(0U, form_structure->autofill_count()); 917 ASSERT_EQ(0U, form_structure->autofill_count());
918 918
919 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(0)->heuristic_type()); 919 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(0)->heuristic_type());
920 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(1)->heuristic_type()); 920 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(1)->heuristic_type());
921 EXPECT_EQ(NO_SERVER_DATA, form_structure->field(0)->server_type()); 921 EXPECT_EQ(NO_SERVER_DATA, form_structure->field(0)->server_type());
922 EXPECT_EQ(NO_SERVER_DATA, form_structure->field(1)->server_type()); 922 EXPECT_EQ(NO_SERVER_DATA, form_structure->field(1)->server_type());
(...skipping 14 matching lines...) Expand all
937 field.name = ASCIIToUTF16("firstname"); 937 field.name = ASCIIToUTF16("firstname");
938 field.autocomplete_attribute = "given-name"; 938 field.autocomplete_attribute = "given-name";
939 form.fields.push_back(field); 939 form.fields.push_back(field);
940 940
941 field.label = ASCIIToUTF16("Last Name"); 941 field.label = ASCIIToUTF16("Last Name");
942 field.name = ASCIIToUTF16("lastname"); 942 field.name = ASCIIToUTF16("lastname");
943 field.autocomplete_attribute = ""; 943 field.autocomplete_attribute = "";
944 form.fields.push_back(field); 944 form.fields.push_back(field);
945 945
946 form_structure.reset(new FormStructure(form)); 946 form_structure.reset(new FormStructure(form));
947 form_structure->DetermineHeuristicTypes(); 947 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */, GURL());
948 EXPECT_FALSE(form_structure->IsAutofillable()); 948 EXPECT_FALSE(form_structure->IsAutofillable());
949 EXPECT_FALSE(form_structure->ShouldBeCrowdsourced()); 949 EXPECT_FALSE(form_structure->ShouldBeCrowdsourced());
950 950
951 ASSERT_EQ(2U, form_structure->field_count()); 951 ASSERT_EQ(2U, form_structure->field_count());
952 ASSERT_EQ(1U, form_structure->autofill_count()); 952 ASSERT_EQ(1U, form_structure->autofill_count());
953 953
954 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(0)->heuristic_type()); 954 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(0)->heuristic_type());
955 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(1)->heuristic_type()); 955 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(1)->heuristic_type());
956 EXPECT_EQ(NO_SERVER_DATA, form_structure->field(0)->server_type()); 956 EXPECT_EQ(NO_SERVER_DATA, form_structure->field(0)->server_type());
957 EXPECT_EQ(NO_SERVER_DATA, form_structure->field(1)->server_type()); 957 EXPECT_EQ(NO_SERVER_DATA, form_structure->field(1)->server_type());
(...skipping 22 matching lines...) Expand all
980 field.name = ASCIIToUTF16("email"); 980 field.name = ASCIIToUTF16("email");
981 field.autocomplete_attribute = "username"; 981 field.autocomplete_attribute = "username";
982 form.fields.push_back(field); 982 form.fields.push_back(field);
983 983
984 field.label = ASCIIToUTF16("Password"); 984 field.label = ASCIIToUTF16("Password");
985 field.name = ASCIIToUTF16("Password"); 985 field.name = ASCIIToUTF16("Password");
986 field.form_control_type = "password"; 986 field.form_control_type = "password";
987 form.fields.push_back(field); 987 form.fields.push_back(field);
988 988
989 FormStructure form_structure(form); 989 FormStructure form_structure(form);
990 form_structure.DetermineHeuristicTypes(); 990 form_structure.DetermineHeuristicTypes(nullptr /* ukm_service */, GURL());
991 EXPECT_TRUE(form_structure.ShouldBeCrowdsourced()); 991 EXPECT_TRUE(form_structure.ShouldBeCrowdsourced());
992 } 992 }
993 993
994 // Verify that we can correctly process sections listed in the |autocomplete| 994 // Verify that we can correctly process sections listed in the |autocomplete|
995 // attribute. 995 // attribute.
996 TEST_F(FormStructureTest, HeuristicsAutocompleteAttributeWithSections) { 996 TEST_F(FormStructureTest, HeuristicsAutocompleteAttributeWithSections) {
997 FormData form; 997 FormData form;
998 998
999 FormFieldData field; 999 FormFieldData field;
1000 field.form_control_type = "text"; 1000 field.form_control_type = "text";
(...skipping 30 matching lines...) Expand all
1031 // implement implicit section names from attributes like "shipping email"; see 1031 // implement implicit section names from attributes like "shipping email"; see
1032 // the implementation for more details. 1032 // the implementation for more details.
1033 field.autocomplete_attribute = "section--shipping email"; 1033 field.autocomplete_attribute = "section--shipping email";
1034 form.fields.push_back(field); 1034 form.fields.push_back(field);
1035 1035
1036 // Credit card fields are implicitly in a separate section from other fields. 1036 // Credit card fields are implicitly in a separate section from other fields.
1037 field.autocomplete_attribute = "section-foo cc-number"; 1037 field.autocomplete_attribute = "section-foo cc-number";
1038 form.fields.push_back(field); 1038 form.fields.push_back(field);
1039 1039
1040 FormStructure form_structure(form); 1040 FormStructure form_structure(form);
1041 form_structure.DetermineHeuristicTypes(); 1041 form_structure.DetermineHeuristicTypes(nullptr /* ukm_service */, GURL());
1042 EXPECT_TRUE(form_structure.IsAutofillable()); 1042 EXPECT_TRUE(form_structure.IsAutofillable());
1043 1043
1044 // Expect the correct number of fields. 1044 // Expect the correct number of fields.
1045 ASSERT_EQ(9U, form_structure.field_count()); 1045 ASSERT_EQ(9U, form_structure.field_count());
1046 EXPECT_EQ(9U, form_structure.autofill_count()); 1046 EXPECT_EQ(9U, form_structure.autofill_count());
1047 1047
1048 // All of the fields in this form should be parsed as belonging to different 1048 // All of the fields in this form should be parsed as belonging to different
1049 // sections. 1049 // sections.
1050 std::set<std::string> section_names; 1050 std::set<std::string> section_names;
1051 for (size_t i = 0; i < 9; ++i) { 1051 for (size_t i = 0; i < 9; ++i) {
(...skipping 24 matching lines...) Expand all
1076 field.autocomplete_attribute = "garbage section-foo email"; 1076 field.autocomplete_attribute = "garbage section-foo email";
1077 form.fields.push_back(field); 1077 form.fields.push_back(field);
1078 field.autocomplete_attribute = "garbage section-bar email"; 1078 field.autocomplete_attribute = "garbage section-bar email";
1079 form.fields.push_back(field); 1079 form.fields.push_back(field);
1080 field.autocomplete_attribute = "garbage shipping email"; 1080 field.autocomplete_attribute = "garbage shipping email";
1081 form.fields.push_back(field); 1081 form.fields.push_back(field);
1082 field.autocomplete_attribute = "garbage billing email"; 1082 field.autocomplete_attribute = "garbage billing email";
1083 form.fields.push_back(field); 1083 form.fields.push_back(field);
1084 1084
1085 FormStructure form_structure(form); 1085 FormStructure form_structure(form);
1086 form_structure.DetermineHeuristicTypes(); 1086 form_structure.DetermineHeuristicTypes(nullptr /* ukm_service */, GURL());
1087 1087
1088 // Expect the correct number of fields. 1088 // Expect the correct number of fields.
1089 ASSERT_EQ(6U, form_structure.field_count()); 1089 ASSERT_EQ(6U, form_structure.field_count());
1090 EXPECT_EQ(2U, form_structure.autofill_count()); 1090 EXPECT_EQ(2U, form_structure.autofill_count());
1091 1091
1092 // All of the fields in this form should be parsed as belonging to the same 1092 // All of the fields in this form should be parsed as belonging to the same
1093 // section. 1093 // section.
1094 std::set<std::string> section_names; 1094 std::set<std::string> section_names;
1095 for (size_t i = 0; i < 6; ++i) { 1095 for (size_t i = 0; i < 6; ++i) {
1096 section_names.insert(form_structure.field(i)->section()); 1096 section_names.insert(form_structure.field(i)->section());
1097 } 1097 }
1098 EXPECT_EQ(1U, section_names.size()); 1098 EXPECT_EQ(1U, section_names.size());
1099 } 1099 }
1100 1100
1101 // Verify that we can correctly process repeated sections listed in the 1101 // Verify that we can correctly process repeated sections listed in the
1102 // |autocomplete| attribute. 1102 // |autocomplete| attribute.
1103 TEST_F(FormStructureTest, HeuristicsAutocompleteAttributeWithSectionsRepeated) { 1103 TEST_F(FormStructureTest, HeuristicsAutocompleteAttributeWithSectionsRepeated) {
1104 FormData form; 1104 FormData form;
1105 1105
1106 FormFieldData field; 1106 FormFieldData field;
1107 field.form_control_type = "text"; 1107 field.form_control_type = "text";
1108 1108
1109 field.autocomplete_attribute = "section-foo email"; 1109 field.autocomplete_attribute = "section-foo email";
1110 form.fields.push_back(field); 1110 form.fields.push_back(field);
1111 field.autocomplete_attribute = "section-foo address-line1"; 1111 field.autocomplete_attribute = "section-foo address-line1";
1112 form.fields.push_back(field); 1112 form.fields.push_back(field);
1113 1113
1114 FormStructure form_structure(form); 1114 FormStructure form_structure(form);
1115 form_structure.DetermineHeuristicTypes(); 1115 form_structure.DetermineHeuristicTypes(nullptr /* ukm_service */, GURL());
1116 1116
1117 // Expect the correct number of fields. 1117 // Expect the correct number of fields.
1118 ASSERT_EQ(2U, form_structure.field_count()); 1118 ASSERT_EQ(2U, form_structure.field_count());
1119 EXPECT_EQ(2U, form_structure.autofill_count()); 1119 EXPECT_EQ(2U, form_structure.autofill_count());
1120 1120
1121 // All of the fields in this form should be parsed as belonging to the same 1121 // All of the fields in this form should be parsed as belonging to the same
1122 // section. 1122 // section.
1123 std::set<std::string> section_names; 1123 std::set<std::string> section_names;
1124 for (size_t i = 0; i < 2; ++i) { 1124 for (size_t i = 0; i < 2; ++i) {
1125 section_names.insert(form_structure.field(i)->section()); 1125 section_names.insert(form_structure.field(i)->section());
(...skipping 16 matching lines...) Expand all
1142 field.autocomplete_attribute = "section-foo email"; 1142 field.autocomplete_attribute = "section-foo email";
1143 form.fields.push_back(field); 1143 form.fields.push_back(field);
1144 field.name = base::string16(); 1144 field.name = base::string16();
1145 field.autocomplete_attribute = "name"; 1145 field.autocomplete_attribute = "name";
1146 form.fields.push_back(field); 1146 form.fields.push_back(field);
1147 field.name = ASCIIToUTF16("two"); 1147 field.name = ASCIIToUTF16("two");
1148 field.autocomplete_attribute = "address-line1"; 1148 field.autocomplete_attribute = "address-line1";
1149 form.fields.push_back(field); 1149 form.fields.push_back(field);
1150 1150
1151 FormStructure form_structure(form); 1151 FormStructure form_structure(form);
1152 form_structure.DetermineHeuristicTypes(); 1152 form_structure.DetermineHeuristicTypes(nullptr /* ukm_service */, GURL());
1153 1153
1154 // Expect the correct number of fields. 1154 // Expect the correct number of fields.
1155 ASSERT_EQ(4U, form_structure.field_count()); 1155 ASSERT_EQ(4U, form_structure.field_count());
1156 EXPECT_EQ(4U, form_structure.autofill_count()); 1156 EXPECT_EQ(4U, form_structure.autofill_count());
1157 1157
1158 // Normally, the two separate address fields would cause us to detect two 1158 // Normally, the two separate address fields would cause us to detect two
1159 // separate sections; but because there is an author-specified section in this 1159 // separate sections; but because there is an author-specified section in this
1160 // form, we do not apply these usual heuristics. 1160 // form, we do not apply these usual heuristics.
1161 EXPECT_EQ(ASCIIToUTF16("one"), form_structure.field(0)->name); 1161 EXPECT_EQ(ASCIIToUTF16("one"), form_structure.field(0)->name);
1162 EXPECT_EQ(ASCIIToUTF16("two"), form_structure.field(3)->name); 1162 EXPECT_EQ(ASCIIToUTF16("two"), form_structure.field(3)->name);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1206 field.label = ASCIIToUTF16("Phone Number:"); 1206 field.label = ASCIIToUTF16("Phone Number:");
1207 field.name = ASCIIToUTF16("BillTo.Phone"); 1207 field.name = ASCIIToUTF16("BillTo.Phone");
1208 form.fields.push_back(field); 1208 form.fields.push_back(field);
1209 1209
1210 field.label = base::string16(); 1210 field.label = base::string16();
1211 field.name = ASCIIToUTF16("Submit"); 1211 field.name = ASCIIToUTF16("Submit");
1212 field.form_control_type = "submit"; 1212 field.form_control_type = "submit";
1213 form.fields.push_back(field); 1213 form.fields.push_back(field);
1214 1214
1215 form_structure.reset(new FormStructure(form)); 1215 form_structure.reset(new FormStructure(form));
1216 form_structure->DetermineHeuristicTypes(); 1216 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */, GURL());
1217 EXPECT_TRUE(form_structure->IsAutofillable()); 1217 EXPECT_TRUE(form_structure->IsAutofillable());
1218 ASSERT_EQ(10U, form_structure->field_count()); 1218 ASSERT_EQ(10U, form_structure->field_count());
1219 ASSERT_EQ(9U, form_structure->autofill_count()); 1219 ASSERT_EQ(9U, form_structure->autofill_count());
1220 1220
1221 // First name. 1221 // First name.
1222 EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type()); 1222 EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type());
1223 // Last name. 1223 // Last name.
1224 EXPECT_EQ(NAME_LAST, form_structure->field(1)->heuristic_type()); 1224 EXPECT_EQ(NAME_LAST, form_structure->field(1)->heuristic_type());
1225 // Address. 1225 // Address.
1226 EXPECT_EQ(ADDRESS_HOME_LINE1, form_structure->field(2)->heuristic_type()); 1226 EXPECT_EQ(ADDRESS_HOME_LINE1, form_structure->field(2)->heuristic_type());
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1272 field.name = ASCIIToUTF16("Home.PostalCode"); 1272 field.name = ASCIIToUTF16("Home.PostalCode");
1273 form.fields.push_back(field); 1273 form.fields.push_back(field);
1274 1274
1275 field.label = base::string16(); 1275 field.label = base::string16();
1276 field.name = ASCIIToUTF16("Submit"); 1276 field.name = ASCIIToUTF16("Submit");
1277 field.value = ASCIIToUTF16("continue"); 1277 field.value = ASCIIToUTF16("continue");
1278 field.form_control_type = "submit"; 1278 field.form_control_type = "submit";
1279 form.fields.push_back(field); 1279 form.fields.push_back(field);
1280 1280
1281 form_structure.reset(new FormStructure(form)); 1281 form_structure.reset(new FormStructure(form));
1282 form_structure->DetermineHeuristicTypes(); 1282 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */, GURL());
1283 EXPECT_TRUE(form_structure->IsAutofillable()); 1283 EXPECT_TRUE(form_structure->IsAutofillable());
1284 ASSERT_EQ(7U, form_structure->field_count()); 1284 ASSERT_EQ(7U, form_structure->field_count());
1285 ASSERT_EQ(6U, form_structure->autofill_count()); 1285 ASSERT_EQ(6U, form_structure->autofill_count());
1286 1286
1287 // Email. 1287 // Email.
1288 EXPECT_EQ(EMAIL_ADDRESS, form_structure->field(0)->heuristic_type()); 1288 EXPECT_EQ(EMAIL_ADDRESS, form_structure->field(0)->heuristic_type());
1289 // Full name. 1289 // Full name.
1290 EXPECT_EQ(NAME_FULL, form_structure->field(1)->heuristic_type()); 1290 EXPECT_EQ(NAME_FULL, form_structure->field(1)->heuristic_type());
1291 // Company 1291 // Company
1292 EXPECT_EQ(COMPANY_NAME, form_structure->field(2)->heuristic_type()); 1292 EXPECT_EQ(COMPANY_NAME, form_structure->field(2)->heuristic_type());
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1337 field.label = ASCIIToUTF16("Zip code"); 1337 field.label = ASCIIToUTF16("Zip code");
1338 field.name = base::string16(); 1338 field.name = base::string16();
1339 form.fields.push_back(field); 1339 form.fields.push_back(field);
1340 1340
1341 field.label = base::string16(); 1341 field.label = base::string16();
1342 field.name = ASCIIToUTF16("Submit"); 1342 field.name = ASCIIToUTF16("Submit");
1343 field.form_control_type = "submit"; 1343 field.form_control_type = "submit";
1344 form.fields.push_back(field); 1344 form.fields.push_back(field);
1345 1345
1346 form_structure.reset(new FormStructure(form)); 1346 form_structure.reset(new FormStructure(form));
1347 form_structure->DetermineHeuristicTypes(); 1347 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */, GURL());
1348 EXPECT_TRUE(form_structure->IsAutofillable()); 1348 EXPECT_TRUE(form_structure->IsAutofillable());
1349 ASSERT_EQ(8U, form_structure->field_count()); 1349 ASSERT_EQ(8U, form_structure->field_count());
1350 ASSERT_EQ(7U, form_structure->autofill_count()); 1350 ASSERT_EQ(7U, form_structure->autofill_count());
1351 1351
1352 // First name. 1352 // First name.
1353 EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type()); 1353 EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type());
1354 // Last name. 1354 // Last name.
1355 EXPECT_EQ(NAME_LAST, form_structure->field(1)->heuristic_type()); 1355 EXPECT_EQ(NAME_LAST, form_structure->field(1)->heuristic_type());
1356 // Email. 1356 // Email.
1357 EXPECT_EQ(EMAIL_ADDRESS, form_structure->field(2)->heuristic_type()); 1357 EXPECT_EQ(EMAIL_ADDRESS, form_structure->field(2)->heuristic_type());
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1394 field.label = ASCIIToUTF16("Verification"); 1394 field.label = ASCIIToUTF16("Verification");
1395 field.name = ASCIIToUTF16("verification"); 1395 field.name = ASCIIToUTF16("verification");
1396 form.fields.push_back(field); 1396 form.fields.push_back(field);
1397 1397
1398 field.label = base::string16(); 1398 field.label = base::string16();
1399 field.name = ASCIIToUTF16("Submit"); 1399 field.name = ASCIIToUTF16("Submit");
1400 field.form_control_type = "submit"; 1400 field.form_control_type = "submit";
1401 form.fields.push_back(field); 1401 form.fields.push_back(field);
1402 1402
1403 form_structure.reset(new FormStructure(form)); 1403 form_structure.reset(new FormStructure(form));
1404 form_structure->DetermineHeuristicTypes(); 1404 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */, GURL());
1405 EXPECT_TRUE(form_structure->IsAutofillable()); 1405 EXPECT_TRUE(form_structure->IsAutofillable());
1406 ASSERT_EQ(6U, form_structure->field_count()); 1406 ASSERT_EQ(6U, form_structure->field_count());
1407 ASSERT_EQ(5U, form_structure->autofill_count()); 1407 ASSERT_EQ(5U, form_structure->autofill_count());
1408 1408
1409 // Credit card name. 1409 // Credit card name.
1410 EXPECT_EQ(CREDIT_CARD_NAME_FULL, form_structure->field(0)->heuristic_type()); 1410 EXPECT_EQ(CREDIT_CARD_NAME_FULL, form_structure->field(0)->heuristic_type());
1411 // Credit card number. 1411 // Credit card number.
1412 EXPECT_EQ(CREDIT_CARD_NUMBER, form_structure->field(1)->heuristic_type()); 1412 EXPECT_EQ(CREDIT_CARD_NUMBER, form_structure->field(1)->heuristic_type());
1413 // Credit card expiration month. 1413 // Credit card expiration month.
1414 EXPECT_EQ(CREDIT_CARD_EXP_MONTH, form_structure->field(2)->heuristic_type()); 1414 EXPECT_EQ(CREDIT_CARD_EXP_MONTH, form_structure->field(2)->heuristic_type());
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1454 field.label = ASCIIToUTF16("Verification"); 1454 field.label = ASCIIToUTF16("Verification");
1455 field.name = ASCIIToUTF16("verification"); 1455 field.name = ASCIIToUTF16("verification");
1456 form.fields.push_back(field); 1456 form.fields.push_back(field);
1457 1457
1458 field.label = base::string16(); 1458 field.label = base::string16();
1459 field.name = ASCIIToUTF16("Submit"); 1459 field.name = ASCIIToUTF16("Submit");
1460 field.form_control_type = "submit"; 1460 field.form_control_type = "submit";
1461 form.fields.push_back(field); 1461 form.fields.push_back(field);
1462 1462
1463 form_structure.reset(new FormStructure(form)); 1463 form_structure.reset(new FormStructure(form));
1464 form_structure->DetermineHeuristicTypes(); 1464 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */, GURL());
1465 EXPECT_TRUE(form_structure->IsAutofillable()); 1465 EXPECT_TRUE(form_structure->IsAutofillable());
1466 ASSERT_EQ(7U, form_structure->field_count()); 1466 ASSERT_EQ(7U, form_structure->field_count());
1467 ASSERT_EQ(5U, form_structure->autofill_count()); 1467 ASSERT_EQ(5U, form_structure->autofill_count());
1468 1468
1469 // Credit card name. 1469 // Credit card name.
1470 EXPECT_EQ(CREDIT_CARD_NAME_FULL, form_structure->field(0)->heuristic_type()); 1470 EXPECT_EQ(CREDIT_CARD_NAME_FULL, form_structure->field(0)->heuristic_type());
1471 // Credit card type. This is an unknown type but related to the credit card. 1471 // Credit card type. This is an unknown type but related to the credit card.
1472 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(1)->heuristic_type()); 1472 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(1)->heuristic_type());
1473 // Credit card number. 1473 // Credit card number.
1474 EXPECT_EQ(CREDIT_CARD_NUMBER, form_structure->field(2)->heuristic_type()); 1474 EXPECT_EQ(CREDIT_CARD_NUMBER, form_structure->field(2)->heuristic_type());
(...skipping 26 matching lines...) Expand all
1501 1501
1502 field.label = ASCIIToUTF16("Address Line3"); 1502 field.label = ASCIIToUTF16("Address Line3");
1503 field.name = ASCIIToUTF16("Address"); 1503 field.name = ASCIIToUTF16("Address");
1504 form.fields.push_back(field); 1504 form.fields.push_back(field);
1505 1505
1506 field.label = ASCIIToUTF16("City"); 1506 field.label = ASCIIToUTF16("City");
1507 field.name = ASCIIToUTF16("city"); 1507 field.name = ASCIIToUTF16("city");
1508 form.fields.push_back(field); 1508 form.fields.push_back(field);
1509 1509
1510 form_structure.reset(new FormStructure(form)); 1510 form_structure.reset(new FormStructure(form));
1511 form_structure->DetermineHeuristicTypes(); 1511 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */, GURL());
1512 EXPECT_TRUE(form_structure->IsAutofillable()); 1512 EXPECT_TRUE(form_structure->IsAutofillable());
1513 ASSERT_EQ(4U, form_structure->field_count()); 1513 ASSERT_EQ(4U, form_structure->field_count());
1514 ASSERT_EQ(4U, form_structure->autofill_count()); 1514 ASSERT_EQ(4U, form_structure->autofill_count());
1515 1515
1516 // Address Line 1. 1516 // Address Line 1.
1517 EXPECT_EQ(ADDRESS_HOME_LINE1, form_structure->field(0)->heuristic_type()); 1517 EXPECT_EQ(ADDRESS_HOME_LINE1, form_structure->field(0)->heuristic_type());
1518 // Address Line 2. 1518 // Address Line 2.
1519 EXPECT_EQ(ADDRESS_HOME_LINE2, form_structure->field(1)->heuristic_type()); 1519 EXPECT_EQ(ADDRESS_HOME_LINE2, form_structure->field(1)->heuristic_type());
1520 // Address Line 3. 1520 // Address Line 3.
1521 EXPECT_EQ(ADDRESS_HOME_LINE3, form_structure->field(2)->heuristic_type()); 1521 EXPECT_EQ(ADDRESS_HOME_LINE3, form_structure->field(2)->heuristic_type());
(...skipping 19 matching lines...) Expand all
1541 1541
1542 field.label = ASCIIToUTF16("Address Line3"); 1542 field.label = ASCIIToUTF16("Address Line3");
1543 field.name = ASCIIToUTF16("billing.address.addressLine3"); 1543 field.name = ASCIIToUTF16("billing.address.addressLine3");
1544 form.fields.push_back(field); 1544 form.fields.push_back(field);
1545 1545
1546 field.label = ASCIIToUTF16("Address Line4"); 1546 field.label = ASCIIToUTF16("Address Line4");
1547 field.name = ASCIIToUTF16("billing.address.addressLine4"); 1547 field.name = ASCIIToUTF16("billing.address.addressLine4");
1548 form.fields.push_back(field); 1548 form.fields.push_back(field);
1549 1549
1550 form_structure.reset(new FormStructure(form)); 1550 form_structure.reset(new FormStructure(form));
1551 form_structure->DetermineHeuristicTypes(); 1551 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */, GURL());
1552 ASSERT_EQ(4U, form_structure->field_count()); 1552 ASSERT_EQ(4U, form_structure->field_count());
1553 ASSERT_EQ(3U, form_structure->autofill_count()); 1553 ASSERT_EQ(3U, form_structure->autofill_count());
1554 1554
1555 // Address Line 1. 1555 // Address Line 1.
1556 EXPECT_EQ(ADDRESS_HOME_LINE1, form_structure->field(0)->heuristic_type()); 1556 EXPECT_EQ(ADDRESS_HOME_LINE1, form_structure->field(0)->heuristic_type());
1557 // Address Line 2. 1557 // Address Line 2.
1558 EXPECT_EQ(ADDRESS_HOME_LINE2, form_structure->field(1)->heuristic_type()); 1558 EXPECT_EQ(ADDRESS_HOME_LINE2, form_structure->field(1)->heuristic_type());
1559 // Address Line 3. 1559 // Address Line 3.
1560 EXPECT_EQ(ADDRESS_HOME_LINE3, form_structure->field(2)->heuristic_type()); 1560 EXPECT_EQ(ADDRESS_HOME_LINE3, form_structure->field(2)->heuristic_type());
1561 // Address Line 4 (ignored). 1561 // Address Line 4 (ignored).
(...skipping 22 matching lines...) Expand all
1584 1584
1585 field.label = ASCIIToUTF16("Street address second line"); 1585 field.label = ASCIIToUTF16("Street address second line");
1586 field.name = ASCIIToUTF16("FOPIH_RgWebCC_0_IHAddress_ads2"); 1586 field.name = ASCIIToUTF16("FOPIH_RgWebCC_0_IHAddress_ads2");
1587 form.fields.push_back(field); 1587 form.fields.push_back(field);
1588 1588
1589 field.label = ASCIIToUTF16("City:"); 1589 field.label = ASCIIToUTF16("City:");
1590 field.name = ASCIIToUTF16("FOPIH_RgWebCC_0_IHAddress_adct"); 1590 field.name = ASCIIToUTF16("FOPIH_RgWebCC_0_IHAddress_adct");
1591 form.fields.push_back(field); 1591 form.fields.push_back(field);
1592 1592
1593 form_structure.reset(new FormStructure(form)); 1593 form_structure.reset(new FormStructure(form));
1594 form_structure->DetermineHeuristicTypes(); 1594 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */, GURL());
1595 EXPECT_TRUE(form_structure->IsAutofillable()); 1595 EXPECT_TRUE(form_structure->IsAutofillable());
1596 ASSERT_EQ(4U, form_structure->field_count()); 1596 ASSERT_EQ(4U, form_structure->field_count());
1597 EXPECT_EQ(4U, form_structure->autofill_count()); 1597 EXPECT_EQ(4U, form_structure->autofill_count());
1598 1598
1599 // Address Line 1. 1599 // Address Line 1.
1600 EXPECT_EQ(ADDRESS_HOME_LINE1, form_structure->field(0)->heuristic_type()); 1600 EXPECT_EQ(ADDRESS_HOME_LINE1, form_structure->field(0)->heuristic_type());
1601 // Suite / Apt. 1601 // Suite / Apt.
1602 EXPECT_EQ(ADDRESS_HOME_LINE2, form_structure->field(1)->heuristic_type()); 1602 EXPECT_EQ(ADDRESS_HOME_LINE2, form_structure->field(1)->heuristic_type());
1603 // Address Line 3. 1603 // Address Line 3.
1604 EXPECT_EQ(ADDRESS_HOME_LINE3, form_structure->field(2)->heuristic_type()); 1604 EXPECT_EQ(ADDRESS_HOME_LINE3, form_structure->field(2)->heuristic_type());
(...skipping 17 matching lines...) Expand all
1622 1622
1623 field.label = ASCIIToUTF16("Floor number, suite number, etc"); 1623 field.label = ASCIIToUTF16("Floor number, suite number, etc");
1624 field.name = ASCIIToUTF16("address2"); 1624 field.name = ASCIIToUTF16("address2");
1625 form.fields.push_back(field); 1625 form.fields.push_back(field);
1626 1626
1627 field.label = ASCIIToUTF16("City:"); 1627 field.label = ASCIIToUTF16("City:");
1628 field.name = ASCIIToUTF16("city"); 1628 field.name = ASCIIToUTF16("city");
1629 form.fields.push_back(field); 1629 form.fields.push_back(field);
1630 1630
1631 form_structure.reset(new FormStructure(form)); 1631 form_structure.reset(new FormStructure(form));
1632 form_structure->DetermineHeuristicTypes(); 1632 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */, GURL());
1633 EXPECT_TRUE(form_structure->IsAutofillable()); 1633 EXPECT_TRUE(form_structure->IsAutofillable());
1634 ASSERT_EQ(3U, form_structure->field_count()); 1634 ASSERT_EQ(3U, form_structure->field_count());
1635 ASSERT_EQ(3U, form_structure->autofill_count()); 1635 ASSERT_EQ(3U, form_structure->autofill_count());
1636 1636
1637 // Address Line 1. 1637 // Address Line 1.
1638 EXPECT_EQ(ADDRESS_HOME_LINE1, form_structure->field(0)->heuristic_type()); 1638 EXPECT_EQ(ADDRESS_HOME_LINE1, form_structure->field(0)->heuristic_type());
1639 // Address Line 2. 1639 // Address Line 2.
1640 EXPECT_EQ(ADDRESS_HOME_LINE2, form_structure->field(1)->heuristic_type()); 1640 EXPECT_EQ(ADDRESS_HOME_LINE2, form_structure->field(1)->heuristic_type());
1641 // City. 1641 // City.
1642 EXPECT_EQ(ADDRESS_HOME_CITY, form_structure->field(2)->heuristic_type()); 1642 EXPECT_EQ(ADDRESS_HOME_CITY, form_structure->field(2)->heuristic_type());
(...skipping 12 matching lines...) Expand all
1655 1655
1656 field.label = ASCIIToUTF16("Address Line2"); 1656 field.label = ASCIIToUTF16("Address Line2");
1657 field.name = ASCIIToUTF16("Address"); 1657 field.name = ASCIIToUTF16("Address");
1658 form.fields.push_back(field); 1658 form.fields.push_back(field);
1659 1659
1660 field.label = ASCIIToUTF16("State/Province/Region"); 1660 field.label = ASCIIToUTF16("State/Province/Region");
1661 field.name = ASCIIToUTF16("State"); 1661 field.name = ASCIIToUTF16("State");
1662 form.fields.push_back(field); 1662 form.fields.push_back(field);
1663 1663
1664 form_structure.reset(new FormStructure(form)); 1664 form_structure.reset(new FormStructure(form));
1665 form_structure->DetermineHeuristicTypes(); 1665 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */, GURL());
1666 EXPECT_TRUE(form_structure->IsAutofillable()); 1666 EXPECT_TRUE(form_structure->IsAutofillable());
1667 ASSERT_EQ(3U, form_structure->field_count()); 1667 ASSERT_EQ(3U, form_structure->field_count());
1668 ASSERT_EQ(3U, form_structure->autofill_count()); 1668 ASSERT_EQ(3U, form_structure->autofill_count());
1669 1669
1670 // Address Line 1. 1670 // Address Line 1.
1671 EXPECT_EQ(ADDRESS_HOME_LINE1, form_structure->field(0)->heuristic_type()); 1671 EXPECT_EQ(ADDRESS_HOME_LINE1, form_structure->field(0)->heuristic_type());
1672 // Address Line 2. 1672 // Address Line 2.
1673 EXPECT_EQ(ADDRESS_HOME_LINE2, form_structure->field(1)->heuristic_type()); 1673 EXPECT_EQ(ADDRESS_HOME_LINE2, form_structure->field(1)->heuristic_type());
1674 // State. 1674 // State.
1675 EXPECT_EQ(ADDRESS_HOME_STATE, form_structure->field(2)->heuristic_type()); 1675 EXPECT_EQ(ADDRESS_HOME_STATE, form_structure->field(2)->heuristic_type());
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1721 1721
1722 field.label = ASCIIToUTF16("Phone*:"); 1722 field.label = ASCIIToUTF16("Phone*:");
1723 field.name = ASCIIToUTF16("editBillingAddress$phoneBox"); 1723 field.name = ASCIIToUTF16("editBillingAddress$phoneBox");
1724 form.fields.push_back(field); 1724 form.fields.push_back(field);
1725 1725
1726 field.label = ASCIIToUTF16("Email Address*:"); 1726 field.label = ASCIIToUTF16("Email Address*:");
1727 field.name = ASCIIToUTF16("email$emailBox"); 1727 field.name = ASCIIToUTF16("email$emailBox");
1728 form.fields.push_back(field); 1728 form.fields.push_back(field);
1729 1729
1730 form_structure.reset(new FormStructure(form)); 1730 form_structure.reset(new FormStructure(form));
1731 form_structure->DetermineHeuristicTypes(); 1731 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */, GURL());
1732 EXPECT_TRUE(form_structure->IsAutofillable()); 1732 EXPECT_TRUE(form_structure->IsAutofillable());
1733 ASSERT_EQ(11U, form_structure->field_count()); 1733 ASSERT_EQ(11U, form_structure->field_count());
1734 ASSERT_EQ(11U, form_structure->autofill_count()); 1734 ASSERT_EQ(11U, form_structure->autofill_count());
1735 1735
1736 EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type()); 1736 EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type());
1737 EXPECT_EQ(NAME_LAST, form_structure->field(1)->heuristic_type()); 1737 EXPECT_EQ(NAME_LAST, form_structure->field(1)->heuristic_type());
1738 EXPECT_EQ(COMPANY_NAME, form_structure->field(2)->heuristic_type()); 1738 EXPECT_EQ(COMPANY_NAME, form_structure->field(2)->heuristic_type());
1739 EXPECT_EQ(ADDRESS_HOME_LINE1, form_structure->field(3)->heuristic_type()); 1739 EXPECT_EQ(ADDRESS_HOME_LINE1, form_structure->field(3)->heuristic_type());
1740 EXPECT_EQ(ADDRESS_HOME_LINE2, form_structure->field(4)->heuristic_type()); 1740 EXPECT_EQ(ADDRESS_HOME_LINE2, form_structure->field(4)->heuristic_type());
1741 EXPECT_EQ(ADDRESS_HOME_CITY, form_structure->field(5)->heuristic_type()); 1741 EXPECT_EQ(ADDRESS_HOME_CITY, form_structure->field(5)->heuristic_type());
(...skipping 28 matching lines...) Expand all
1770 // passed, phone will be parsed as 1770 // passed, phone will be parsed as
1771 // <country code> - <area code> - <phone>. 1771 // <country code> - <area code> - <phone>.
1772 form.fields.push_back(field); 1772 form.fields.push_back(field);
1773 1773
1774 field.label = ASCIIToUTF16("ext.:"); 1774 field.label = ASCIIToUTF16("ext.:");
1775 field.name = ASCIIToUTF16("dayphone4"); 1775 field.name = ASCIIToUTF16("dayphone4");
1776 field.max_length = 0; 1776 field.max_length = 0;
1777 form.fields.push_back(field); 1777 form.fields.push_back(field);
1778 1778
1779 form_structure.reset(new FormStructure(form)); 1779 form_structure.reset(new FormStructure(form));
1780 form_structure->DetermineHeuristicTypes(); 1780 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */, GURL());
1781 EXPECT_TRUE(form_structure->IsAutofillable()); 1781 EXPECT_TRUE(form_structure->IsAutofillable());
1782 ASSERT_EQ(4U, form_structure->field_count()); 1782 ASSERT_EQ(4U, form_structure->field_count());
1783 ASSERT_EQ(4U, form_structure->autofill_count()); 1783 ASSERT_EQ(4U, form_structure->autofill_count());
1784 1784
1785 // Area code. 1785 // Area code.
1786 EXPECT_EQ(PHONE_HOME_CITY_CODE, form_structure->field(0)->heuristic_type()); 1786 EXPECT_EQ(PHONE_HOME_CITY_CODE, form_structure->field(0)->heuristic_type());
1787 // Phone number suffix. 1787 // Phone number suffix.
1788 EXPECT_EQ(PHONE_HOME_NUMBER, 1788 EXPECT_EQ(PHONE_HOME_NUMBER,
1789 form_structure->field(1)->heuristic_type()); 1789 form_structure->field(1)->heuristic_type());
1790 // Phone number suffix. 1790 // Phone number suffix.
(...skipping 24 matching lines...) Expand all
1815 1815
1816 field.label = ASCIIToUTF16("Expiration Date"); 1816 field.label = ASCIIToUTF16("Expiration Date");
1817 field.name = ASCIIToUTF16("expiration_month"); 1817 field.name = ASCIIToUTF16("expiration_month");
1818 form.fields.push_back(field); 1818 form.fields.push_back(field);
1819 1819
1820 field.label = ASCIIToUTF16("Expiration Year"); 1820 field.label = ASCIIToUTF16("Expiration Year");
1821 field.name = ASCIIToUTF16("expiration_year"); 1821 field.name = ASCIIToUTF16("expiration_year");
1822 form.fields.push_back(field); 1822 form.fields.push_back(field);
1823 1823
1824 form_structure.reset(new FormStructure(form)); 1824 form_structure.reset(new FormStructure(form));
1825 form_structure->DetermineHeuristicTypes(); 1825 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */, GURL());
1826 EXPECT_TRUE(form_structure->IsAutofillable()); 1826 EXPECT_TRUE(form_structure->IsAutofillable());
1827 1827
1828 // Expect the correct number of fields. 1828 // Expect the correct number of fields.
1829 ASSERT_EQ(5U, form_structure->field_count()); 1829 ASSERT_EQ(5U, form_structure->field_count());
1830 EXPECT_EQ(5U, form_structure->autofill_count()); 1830 EXPECT_EQ(5U, form_structure->autofill_count());
1831 1831
1832 // Name on Card. 1832 // Name on Card.
1833 EXPECT_EQ(CREDIT_CARD_NAME_FULL, form_structure->field(0)->heuristic_type()); 1833 EXPECT_EQ(CREDIT_CARD_NAME_FULL, form_structure->field(0)->heuristic_type());
1834 // Address. 1834 // Address.
1835 EXPECT_EQ(ADDRESS_HOME_LINE1, form_structure->field(1)->heuristic_type()); 1835 EXPECT_EQ(ADDRESS_HOME_LINE1, form_structure->field(1)->heuristic_type());
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1869 1869
1870 field.label = base::string16(); 1870 field.label = base::string16();
1871 field.name = ASCIIToUTF16("ccexpiresyear"); 1871 field.name = ASCIIToUTF16("ccexpiresyear");
1872 form.fields.push_back(field); 1872 form.fields.push_back(field);
1873 1873
1874 field.label = ASCIIToUTF16("cvc number"); 1874 field.label = ASCIIToUTF16("cvc number");
1875 field.name = ASCIIToUTF16("csc"); 1875 field.name = ASCIIToUTF16("csc");
1876 form.fields.push_back(field); 1876 form.fields.push_back(field);
1877 1877
1878 form_structure.reset(new FormStructure(form)); 1878 form_structure.reset(new FormStructure(form));
1879 form_structure->DetermineHeuristicTypes(); 1879 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */, GURL());
1880 EXPECT_TRUE(form_structure->IsAutofillable()); 1880 EXPECT_TRUE(form_structure->IsAutofillable());
1881 1881
1882 // Expect the correct number of fields. 1882 // Expect the correct number of fields.
1883 ASSERT_EQ(6U, form_structure->field_count()); 1883 ASSERT_EQ(6U, form_structure->field_count());
1884 ASSERT_EQ(6U, form_structure->autofill_count()); 1884 ASSERT_EQ(6U, form_structure->autofill_count());
1885 1885
1886 // Card Number. 1886 // Card Number.
1887 EXPECT_EQ(CREDIT_CARD_NUMBER, form_structure->field(0)->heuristic_type()); 1887 EXPECT_EQ(CREDIT_CARD_NUMBER, form_structure->field(0)->heuristic_type());
1888 // First name. 1888 // First name.
1889 EXPECT_EQ(CREDIT_CARD_NAME_FIRST, form_structure->field(1)->heuristic_type()); 1889 EXPECT_EQ(CREDIT_CARD_NAME_FIRST, form_structure->field(1)->heuristic_type());
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1927 1927
1928 field.label = base::string16(); 1928 field.label = base::string16();
1929 field.name = ASCIIToUTF16("ccexpiresyear"); 1929 field.name = ASCIIToUTF16("ccexpiresyear");
1930 form.fields.push_back(field); 1930 form.fields.push_back(field);
1931 1931
1932 field.label = ASCIIToUTF16("cvc number"); 1932 field.label = ASCIIToUTF16("cvc number");
1933 field.name = ASCIIToUTF16("csc"); 1933 field.name = ASCIIToUTF16("csc");
1934 form.fields.push_back(field); 1934 form.fields.push_back(field);
1935 1935
1936 form_structure.reset(new FormStructure(form)); 1936 form_structure.reset(new FormStructure(form));
1937 form_structure->DetermineHeuristicTypes(); 1937 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */, GURL());
1938 EXPECT_TRUE(form_structure->IsAutofillable()); 1938 EXPECT_TRUE(form_structure->IsAutofillable());
1939 1939
1940 // Expect the correct number of fields. 1940 // Expect the correct number of fields.
1941 ASSERT_EQ(6U, form_structure->field_count()); 1941 ASSERT_EQ(6U, form_structure->field_count());
1942 ASSERT_EQ(6U, form_structure->autofill_count()); 1942 ASSERT_EQ(6U, form_structure->autofill_count());
1943 1943
1944 // First name. 1944 // First name.
1945 EXPECT_EQ(CREDIT_CARD_NAME_FIRST, form_structure->field(0)->heuristic_type()); 1945 EXPECT_EQ(CREDIT_CARD_NAME_FIRST, form_structure->field(0)->heuristic_type());
1946 // Last name. 1946 // Last name.
1947 EXPECT_EQ(CREDIT_CARD_NAME_LAST, form_structure->field(1)->heuristic_type()); 1947 EXPECT_EQ(CREDIT_CARD_NAME_LAST, form_structure->field(1)->heuristic_type());
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
2110 AutofillQueryContents encoded_query5; 2110 AutofillQueryContents encoded_query5;
2111 EXPECT_FALSE(FormStructure::EncodeQueryRequest(bad_forms, &encoded_signatures, 2111 EXPECT_FALSE(FormStructure::EncodeQueryRequest(bad_forms, &encoded_signatures,
2112 &encoded_query5)); 2112 &encoded_query5));
2113 } 2113 }
2114 2114
2115 TEST_F(FormStructureTest, EncodeUploadRequest) { 2115 TEST_F(FormStructureTest, EncodeUploadRequest) {
2116 std::unique_ptr<FormStructure> form_structure; 2116 std::unique_ptr<FormStructure> form_structure;
2117 std::vector<ServerFieldTypeSet> possible_field_types; 2117 std::vector<ServerFieldTypeSet> possible_field_types;
2118 FormData form; 2118 FormData form;
2119 form_structure.reset(new FormStructure(form)); 2119 form_structure.reset(new FormStructure(form));
2120 form_structure->DetermineHeuristicTypes(); 2120 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */, GURL());
2121 2121
2122 FormFieldData field; 2122 FormFieldData field;
2123 field.form_control_type = "text"; 2123 field.form_control_type = "text";
2124 2124
2125 field.label = ASCIIToUTF16("First Name"); 2125 field.label = ASCIIToUTF16("First Name");
2126 field.name = ASCIIToUTF16("firstname"); 2126 field.name = ASCIIToUTF16("firstname");
2127 form.fields.push_back(field); 2127 form.fields.push_back(field);
2128 possible_field_types.push_back(ServerFieldTypeSet()); 2128 possible_field_types.push_back(ServerFieldTypeSet());
2129 possible_field_types.back().insert(NAME_FIRST); 2129 possible_field_types.back().insert(NAME_FIRST);
2130 2130
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
2286 EXPECT_FALSE(form_structure->EncodeUploadRequest( 2286 EXPECT_FALSE(form_structure->EncodeUploadRequest(
2287 available_field_types, false, std::string(), true, &encoded_upload4)); 2287 available_field_types, false, std::string(), true, &encoded_upload4));
2288 } 2288 }
2289 2289
2290 TEST_F(FormStructureTest, 2290 TEST_F(FormStructureTest,
2291 EncodeUploadRequestWithAdditionalPasswordFormSignature) { 2291 EncodeUploadRequestWithAdditionalPasswordFormSignature) {
2292 std::unique_ptr<FormStructure> form_structure; 2292 std::unique_ptr<FormStructure> form_structure;
2293 std::vector<ServerFieldTypeSet> possible_field_types; 2293 std::vector<ServerFieldTypeSet> possible_field_types;
2294 FormData form; 2294 FormData form;
2295 form_structure.reset(new FormStructure(form)); 2295 form_structure.reset(new FormStructure(form));
2296 form_structure->DetermineHeuristicTypes(); 2296 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */, GURL());
2297 2297
2298 FormFieldData field; 2298 FormFieldData field;
2299 field.label = ASCIIToUTF16("First Name"); 2299 field.label = ASCIIToUTF16("First Name");
2300 field.name = ASCIIToUTF16("firstname"); 2300 field.name = ASCIIToUTF16("firstname");
2301 field.autocomplete_attribute = "given-name"; 2301 field.autocomplete_attribute = "given-name";
2302 form.fields.push_back(field); 2302 form.fields.push_back(field);
2303 possible_field_types.push_back(ServerFieldTypeSet()); 2303 possible_field_types.push_back(ServerFieldTypeSet());
2304 possible_field_types.back().insert(NAME_FIRST); 2304 possible_field_types.back().insert(NAME_FIRST);
2305 2305
2306 field.label = ASCIIToUTF16("Last Name"); 2306 field.label = ASCIIToUTF16("Last Name");
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
2425 std::string encoded_upload_string; 2425 std::string encoded_upload_string;
2426 encoded_upload.SerializeToString(&encoded_upload_string); 2426 encoded_upload.SerializeToString(&encoded_upload_string);
2427 EXPECT_EQ(expected_upload_string, encoded_upload_string); 2427 EXPECT_EQ(expected_upload_string, encoded_upload_string);
2428 } 2428 }
2429 2429
2430 TEST_F(FormStructureTest, EncodeUploadRequest_WithAutocomplete) { 2430 TEST_F(FormStructureTest, EncodeUploadRequest_WithAutocomplete) {
2431 std::unique_ptr<FormStructure> form_structure; 2431 std::unique_ptr<FormStructure> form_structure;
2432 std::vector<ServerFieldTypeSet> possible_field_types; 2432 std::vector<ServerFieldTypeSet> possible_field_types;
2433 FormData form; 2433 FormData form;
2434 form_structure.reset(new FormStructure(form)); 2434 form_structure.reset(new FormStructure(form));
2435 form_structure->DetermineHeuristicTypes(); 2435 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */, GURL());
2436 2436
2437 FormFieldData field; 2437 FormFieldData field;
2438 field.form_control_type = "text"; 2438 field.form_control_type = "text";
2439 2439
2440 field.label = ASCIIToUTF16("First Name"); 2440 field.label = ASCIIToUTF16("First Name");
2441 field.name = ASCIIToUTF16("firstname"); 2441 field.name = ASCIIToUTF16("firstname");
2442 field.autocomplete_attribute = "given-name"; 2442 field.autocomplete_attribute = "given-name";
2443 form.fields.push_back(field); 2443 form.fields.push_back(field);
2444 possible_field_types.push_back(ServerFieldTypeSet()); 2444 possible_field_types.push_back(ServerFieldTypeSet());
2445 possible_field_types.back().insert(NAME_FIRST); 2445 possible_field_types.back().insert(NAME_FIRST);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
2496 std::string encoded_upload_string; 2496 std::string encoded_upload_string;
2497 encoded_upload.SerializeToString(&encoded_upload_string); 2497 encoded_upload.SerializeToString(&encoded_upload_string);
2498 EXPECT_EQ(expected_upload_string, encoded_upload_string); 2498 EXPECT_EQ(expected_upload_string, encoded_upload_string);
2499 } 2499 }
2500 2500
2501 TEST_F(FormStructureTest, EncodeUploadRequest_ObservedSubmissionFalse) { 2501 TEST_F(FormStructureTest, EncodeUploadRequest_ObservedSubmissionFalse) {
2502 std::unique_ptr<FormStructure> form_structure; 2502 std::unique_ptr<FormStructure> form_structure;
2503 std::vector<ServerFieldTypeSet> possible_field_types; 2503 std::vector<ServerFieldTypeSet> possible_field_types;
2504 FormData form; 2504 FormData form;
2505 form_structure.reset(new FormStructure(form)); 2505 form_structure.reset(new FormStructure(form));
2506 form_structure->DetermineHeuristicTypes(); 2506 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */, GURL());
2507 2507
2508 FormFieldData field; 2508 FormFieldData field;
2509 field.form_control_type = "text"; 2509 field.form_control_type = "text";
2510 2510
2511 field.label = ASCIIToUTF16("First Name"); 2511 field.label = ASCIIToUTF16("First Name");
2512 field.name = ASCIIToUTF16("firstname"); 2512 field.name = ASCIIToUTF16("firstname");
2513 form.fields.push_back(field); 2513 form.fields.push_back(field);
2514 possible_field_types.push_back(ServerFieldTypeSet()); 2514 possible_field_types.push_back(ServerFieldTypeSet());
2515 possible_field_types.back().insert(NAME_FIRST); 2515 possible_field_types.back().insert(NAME_FIRST);
2516 2516
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
2565 std::string encoded_upload_string; 2565 std::string encoded_upload_string;
2566 encoded_upload.SerializeToString(&encoded_upload_string); 2566 encoded_upload.SerializeToString(&encoded_upload_string);
2567 EXPECT_EQ(expected_upload_string, encoded_upload_string); 2567 EXPECT_EQ(expected_upload_string, encoded_upload_string);
2568 } 2568 }
2569 2569
2570 TEST_F(FormStructureTest, EncodeUploadRequest_WithLabels) { 2570 TEST_F(FormStructureTest, EncodeUploadRequest_WithLabels) {
2571 std::unique_ptr<FormStructure> form_structure; 2571 std::unique_ptr<FormStructure> form_structure;
2572 std::vector<ServerFieldTypeSet> possible_field_types; 2572 std::vector<ServerFieldTypeSet> possible_field_types;
2573 FormData form; 2573 FormData form;
2574 form_structure.reset(new FormStructure(form)); 2574 form_structure.reset(new FormStructure(form));
2575 form_structure->DetermineHeuristicTypes(); 2575 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */, GURL());
2576 2576
2577 FormFieldData field; 2577 FormFieldData field;
2578 field.form_control_type = "text"; 2578 field.form_control_type = "text";
2579 2579
2580 // No label for the first field. 2580 // No label for the first field.
2581 form.fields.push_back(field); 2581 form.fields.push_back(field);
2582 possible_field_types.push_back(ServerFieldTypeSet()); 2582 possible_field_types.push_back(ServerFieldTypeSet());
2583 possible_field_types.back().insert(NAME_FIRST); 2583 possible_field_types.back().insert(NAME_FIRST);
2584 2584
2585 field.label = ASCIIToUTF16("Last Name"); 2585 field.label = ASCIIToUTF16("Last Name");
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
2702 } 2702 }
2703 2703
2704 // Test that the form name is sent in the upload request. 2704 // Test that the form name is sent in the upload request.
2705 TEST_F(FormStructureTest, EncodeUploadRequest_WithFormName) { 2705 TEST_F(FormStructureTest, EncodeUploadRequest_WithFormName) {
2706 std::unique_ptr<FormStructure> form_structure; 2706 std::unique_ptr<FormStructure> form_structure;
2707 std::vector<ServerFieldTypeSet> possible_field_types; 2707 std::vector<ServerFieldTypeSet> possible_field_types;
2708 FormData form; 2708 FormData form;
2709 // Setting the form name which we expect to see in the upload. 2709 // Setting the form name which we expect to see in the upload.
2710 form.name = ASCIIToUTF16("myform"); 2710 form.name = ASCIIToUTF16("myform");
2711 form_structure.reset(new FormStructure(form)); 2711 form_structure.reset(new FormStructure(form));
2712 form_structure->DetermineHeuristicTypes(); 2712 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */, GURL());
2713 2713
2714 FormFieldData field; 2714 FormFieldData field;
2715 field.form_control_type = "text"; 2715 field.form_control_type = "text";
2716 2716
2717 form.fields.push_back(field); 2717 form.fields.push_back(field);
2718 possible_field_types.push_back(ServerFieldTypeSet()); 2718 possible_field_types.push_back(ServerFieldTypeSet());
2719 possible_field_types.back().insert(NAME_FIRST); 2719 possible_field_types.back().insert(NAME_FIRST);
2720 2720
2721 form.fields.push_back(field); 2721 form.fields.push_back(field);
2722 possible_field_types.push_back(ServerFieldTypeSet()); 2722 possible_field_types.push_back(ServerFieldTypeSet());
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
2764 std::string encoded_upload_string; 2764 std::string encoded_upload_string;
2765 encoded_upload.SerializeToString(&encoded_upload_string); 2765 encoded_upload.SerializeToString(&encoded_upload_string);
2766 EXPECT_EQ(expected_upload_string, encoded_upload_string); 2766 EXPECT_EQ(expected_upload_string, encoded_upload_string);
2767 } 2767 }
2768 2768
2769 TEST_F(FormStructureTest, EncodeUploadRequestPartialMetadata) { 2769 TEST_F(FormStructureTest, EncodeUploadRequestPartialMetadata) {
2770 std::unique_ptr<FormStructure> form_structure; 2770 std::unique_ptr<FormStructure> form_structure;
2771 std::vector<ServerFieldTypeSet> possible_field_types; 2771 std::vector<ServerFieldTypeSet> possible_field_types;
2772 FormData form; 2772 FormData form;
2773 form_structure.reset(new FormStructure(form)); 2773 form_structure.reset(new FormStructure(form));
2774 form_structure->DetermineHeuristicTypes(); 2774 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */, GURL());
2775 2775
2776 FormFieldData field; 2776 FormFieldData field;
2777 field.form_control_type = "text"; 2777 field.form_control_type = "text";
2778 2778
2779 // Some fields don't have "name" or "autocomplete" attributes, and some have 2779 // Some fields don't have "name" or "autocomplete" attributes, and some have
2780 // neither. 2780 // neither.
2781 // No label. 2781 // No label.
2782 form.fields.push_back(field); 2782 form.fields.push_back(field);
2783 possible_field_types.push_back(ServerFieldTypeSet()); 2783 possible_field_types.push_back(ServerFieldTypeSet());
2784 possible_field_types.back().insert(NAME_FIRST); 2784 possible_field_types.back().insert(NAME_FIRST);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
2837 } 2837 }
2838 2838
2839 // Sending field metadata to the server is disabled. 2839 // Sending field metadata to the server is disabled.
2840 TEST_F(FormStructureTest, EncodeUploadRequest_DisabledMetadataTrial) { 2840 TEST_F(FormStructureTest, EncodeUploadRequest_DisabledMetadataTrial) {
2841 DisableAutofillMetadataFieldTrial(); 2841 DisableAutofillMetadataFieldTrial();
2842 2842
2843 std::unique_ptr<FormStructure> form_structure; 2843 std::unique_ptr<FormStructure> form_structure;
2844 std::vector<ServerFieldTypeSet> possible_field_types; 2844 std::vector<ServerFieldTypeSet> possible_field_types;
2845 FormData form; 2845 FormData form;
2846 form_structure.reset(new FormStructure(form)); 2846 form_structure.reset(new FormStructure(form));
2847 form_structure->DetermineHeuristicTypes(); 2847 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */, GURL());
2848 2848
2849 FormFieldData field; 2849 FormFieldData field;
2850 field.form_control_type = "text"; 2850 field.form_control_type = "text";
2851 2851
2852 field.label = ASCIIToUTF16("First Name"); 2852 field.label = ASCIIToUTF16("First Name");
2853 field.name = ASCIIToUTF16("firstname"); 2853 field.name = ASCIIToUTF16("firstname");
2854 field.id = ASCIIToUTF16("first_name"); 2854 field.id = ASCIIToUTF16("first_name");
2855 field.autocomplete_attribute = "given-name"; 2855 field.autocomplete_attribute = "given-name";
2856 field.css_classes = ASCIIToUTF16("class1 class2"); 2856 field.css_classes = ASCIIToUTF16("class1 class2");
2857 form.fields.push_back(field); 2857 form.fields.push_back(field);
(...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after
3765 3765
3766 field.label = ASCIIToUTF16("password"); 3766 field.label = ASCIIToUTF16("password");
3767 field.name = ASCIIToUTF16("password"); 3767 field.name = ASCIIToUTF16("password");
3768 field.form_control_type = "password"; 3768 field.form_control_type = "password";
3769 field.autocomplete_attribute = "new-password"; 3769 field.autocomplete_attribute = "new-password";
3770 form.fields.push_back(field); 3770 form.fields.push_back(field);
3771 3771
3772 FormStructure form_structure(form); 3772 FormStructure form_structure(form);
3773 std::vector<FormStructure*> forms; 3773 std::vector<FormStructure*> forms;
3774 forms.push_back(&form_structure); 3774 forms.push_back(&form_structure);
3775 forms.front()->DetermineHeuristicTypes(); 3775 forms.front()->DetermineHeuristicTypes(nullptr /* ukm_service */, GURL());
3776 3776
3777 AutofillQueryResponseContents response; 3777 AutofillQueryResponseContents response;
3778 response.add_field()->set_autofill_type(EMAIL_ADDRESS); 3778 response.add_field()->set_autofill_type(EMAIL_ADDRESS);
3779 response.add_field()->set_autofill_type(ACCOUNT_CREATION_PASSWORD); 3779 response.add_field()->set_autofill_type(ACCOUNT_CREATION_PASSWORD);
3780 3780
3781 std::string response_string; 3781 std::string response_string;
3782 ASSERT_TRUE(response.SerializeToString(&response_string)); 3782 ASSERT_TRUE(response.SerializeToString(&response_string));
3783 FormStructure::ParseQueryResponse(response_string, forms, nullptr); 3783 FormStructure::ParseQueryResponse(response_string, forms, nullptr);
3784 3784
3785 ASSERT_GE(forms[0]->field_count(), 2U); 3785 ASSERT_GE(forms[0]->field_count(), 2U);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
3826 prefix = FormStructure::FindLongestCommonPrefix(strings); 3826 prefix = FormStructure::FindLongestCommonPrefix(strings);
3827 EXPECT_EQ(ASCIIToUTF16("1234567890123456"), prefix); 3827 EXPECT_EQ(ASCIIToUTF16("1234567890123456"), prefix);
3828 3828
3829 // Empty vector. 3829 // Empty vector.
3830 strings.clear(); 3830 strings.clear();
3831 prefix = FormStructure::FindLongestCommonPrefix(strings); 3831 prefix = FormStructure::FindLongestCommonPrefix(strings);
3832 EXPECT_EQ(ASCIIToUTF16(""), prefix); 3832 EXPECT_EQ(ASCIIToUTF16(""), prefix);
3833 } 3833 }
3834 3834
3835 } // namespace autofill 3835 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698