OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "base/scoped_ptr.h" | 5 #include "base/scoped_ptr.h" |
6 #include "base/string_util.h" | 6 #include "base/string_util.h" |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/browser/autofill/form_structure.h" | 8 #include "chrome/browser/autofill/form_structure.h" |
9 #include "googleurl/src/gurl.h" | 9 #include "googleurl/src/gurl.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 ASCIIToUTF16("password"), | 192 ASCIIToUTF16("password"), |
193 string16(), | 193 string16(), |
194 ASCIIToUTF16("password"), | 194 ASCIIToUTF16("password"), |
195 0)); | 195 0)); |
196 form.fields.push_back(webkit_glue::FormField(string16(), | 196 form.fields.push_back(webkit_glue::FormField(string16(), |
197 ASCIIToUTF16("Submit"), | 197 ASCIIToUTF16("Submit"), |
198 string16(), | 198 string16(), |
199 ASCIIToUTF16("submit"), | 199 ASCIIToUTF16("submit"), |
200 0)); | 200 0)); |
201 form_structure.reset(new FormStructure(form)); | 201 form_structure.reset(new FormStructure(form)); |
202 EXPECT_FALSE(form_structure->IsAutoFillable(true)); | 202 EXPECT_FALSE(form_structure->IsAutoFillable()); |
203 | 203 |
204 // We now have three text fields, but only two auto-fillable fields. | 204 // We now have three text fields, but only two auto-fillable fields. |
205 form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("First Name"), | 205 form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("First Name"), |
206 ASCIIToUTF16("firstname"), | 206 ASCIIToUTF16("firstname"), |
207 string16(), | 207 string16(), |
208 ASCIIToUTF16("text"), | 208 ASCIIToUTF16("text"), |
209 0)); | 209 0)); |
210 form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Last Name"), | 210 form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Last Name"), |
211 ASCIIToUTF16("lastname"), | 211 ASCIIToUTF16("lastname"), |
212 string16(), | 212 string16(), |
213 ASCIIToUTF16("text"), | 213 ASCIIToUTF16("text"), |
214 0)); | 214 0)); |
215 form_structure.reset(new FormStructure(form)); | 215 form_structure.reset(new FormStructure(form)); |
216 EXPECT_FALSE(form_structure->IsAutoFillable(true)); | 216 EXPECT_FALSE(form_structure->IsAutoFillable()); |
217 | 217 |
218 // We now have three auto-fillable fields. | 218 // We now have three auto-fillable fields. |
219 form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Email"), | 219 form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Email"), |
220 ASCIIToUTF16("email"), | 220 ASCIIToUTF16("email"), |
221 string16(), | 221 string16(), |
222 ASCIIToUTF16("text"), | 222 ASCIIToUTF16("text"), |
223 0)); | 223 0)); |
224 form_structure.reset(new FormStructure(form)); | 224 form_structure.reset(new FormStructure(form)); |
225 EXPECT_TRUE(form_structure->IsAutoFillable(true)); | 225 EXPECT_TRUE(form_structure->IsAutoFillable()); |
226 | 226 |
227 // The method must be 'post', though we can intentionally ignore this | 227 // The method must be 'post'. |
228 // criterion for the sake of providing a helpful warning message to the user. | |
229 form.method = ASCIIToUTF16("get"); | 228 form.method = ASCIIToUTF16("get"); |
230 form_structure.reset(new FormStructure(form)); | 229 form_structure.reset(new FormStructure(form)); |
231 EXPECT_FALSE(form_structure->IsAutoFillable(true)); | 230 EXPECT_FALSE(form_structure->IsAutoFillable()); |
232 EXPECT_TRUE(form_structure->IsAutoFillable(false)); | |
233 | 231 |
234 // The target cannot include http(s)://*/search... | 232 // The target cannot include http(s)://*/search... |
235 form.method = ASCIIToUTF16("post"); | 233 form.method = ASCIIToUTF16("post"); |
236 form.action = GURL("http://google.com/search?q=hello"); | 234 form.action = GURL("http://google.com/search?q=hello"); |
237 form_structure.reset(new FormStructure(form)); | 235 form_structure.reset(new FormStructure(form)); |
238 EXPECT_FALSE(form_structure->IsAutoFillable(true)); | 236 EXPECT_FALSE(form_structure->IsAutoFillable()); |
239 | 237 |
240 // But search can be in the URL. | 238 // But search can be in the URL. |
241 form.action = GURL("http://search.com/?q=hello"); | 239 form.action = GURL("http://search.com/?q=hello"); |
242 form_structure.reset(new FormStructure(form)); | 240 form_structure.reset(new FormStructure(form)); |
243 EXPECT_TRUE(form_structure->IsAutoFillable(true)); | 241 EXPECT_TRUE(form_structure->IsAutoFillable()); |
244 } | 242 } |
245 | 243 |
246 TEST(FormStructureTest, HeuristicsContactInfo) { | 244 TEST(FormStructureTest, HeuristicsContactInfo) { |
247 scoped_ptr<FormStructure> form_structure; | 245 scoped_ptr<FormStructure> form_structure; |
248 FormData form; | 246 FormData form; |
249 | 247 |
250 form.method = ASCIIToUTF16("post"); | 248 form.method = ASCIIToUTF16("post"); |
251 form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("First Name"), | 249 form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("First Name"), |
252 ASCIIToUTF16("firstname"), | 250 ASCIIToUTF16("firstname"), |
253 string16(), | 251 string16(), |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 ASCIIToUTF16("zipcode"), | 285 ASCIIToUTF16("zipcode"), |
288 string16(), | 286 string16(), |
289 ASCIIToUTF16("text"), | 287 ASCIIToUTF16("text"), |
290 0)); | 288 0)); |
291 form.fields.push_back(webkit_glue::FormField(string16(), | 289 form.fields.push_back(webkit_glue::FormField(string16(), |
292 ASCIIToUTF16("Submit"), | 290 ASCIIToUTF16("Submit"), |
293 string16(), | 291 string16(), |
294 ASCIIToUTF16("submit"), | 292 ASCIIToUTF16("submit"), |
295 0)); | 293 0)); |
296 form_structure.reset(new FormStructure(form)); | 294 form_structure.reset(new FormStructure(form)); |
297 EXPECT_TRUE(form_structure->IsAutoFillable(true)); | 295 EXPECT_TRUE(form_structure->IsAutoFillable()); |
298 | 296 |
299 // Expect the correct number of fields. | 297 // Expect the correct number of fields. |
300 ASSERT_EQ(9U, form_structure->field_count()); | 298 ASSERT_EQ(9U, form_structure->field_count()); |
301 ASSERT_EQ(8U, form_structure->autofill_count()); | 299 ASSERT_EQ(8U, form_structure->autofill_count()); |
302 | 300 |
303 // First name. | 301 // First name. |
304 EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type()); | 302 EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type()); |
305 // Last name. | 303 // Last name. |
306 EXPECT_EQ(NAME_LAST, form_structure->field(1)->heuristic_type()); | 304 EXPECT_EQ(NAME_LAST, form_structure->field(1)->heuristic_type()); |
307 // Email. | 305 // Email. |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 ASCIIToUTF16("hidden8"), | 403 ASCIIToUTF16("hidden8"), |
406 string16(), | 404 string16(), |
407 ASCIIToUTF16("hidden"), | 405 ASCIIToUTF16("hidden"), |
408 0)); | 406 0)); |
409 form.fields.push_back(webkit_glue::FormField(string16(), | 407 form.fields.push_back(webkit_glue::FormField(string16(), |
410 ASCIIToUTF16("Submit"), | 408 ASCIIToUTF16("Submit"), |
411 string16(), | 409 string16(), |
412 ASCIIToUTF16("submit"), | 410 ASCIIToUTF16("submit"), |
413 0)); | 411 0)); |
414 form_structure.reset(new FormStructure(form)); | 412 form_structure.reset(new FormStructure(form)); |
415 EXPECT_TRUE(form_structure->IsAutoFillable(true)); | 413 EXPECT_TRUE(form_structure->IsAutoFillable()); |
416 | 414 |
417 // Expect the correct number of fields. | 415 // Expect the correct number of fields. |
418 ASSERT_EQ(17U, form_structure->field_count()); | 416 ASSERT_EQ(17U, form_structure->field_count()); |
419 ASSERT_EQ(8U, form_structure->autofill_count()); | 417 ASSERT_EQ(8U, form_structure->autofill_count()); |
420 | 418 |
421 // First name. | 419 // First name. |
422 EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type()); | 420 EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type()); |
423 // Last name. | 421 // Last name. |
424 EXPECT_EQ(NAME_LAST, form_structure->field(2)->heuristic_type()); | 422 EXPECT_EQ(NAME_LAST, form_structure->field(2)->heuristic_type()); |
425 // Email. | 423 // Email. |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 string16(), | 496 string16(), |
499 ASCIIToUTF16("text"), | 497 ASCIIToUTF16("text"), |
500 0)); | 498 0)); |
501 form.fields.push_back( | 499 form.fields.push_back( |
502 webkit_glue::FormField(string16(), | 500 webkit_glue::FormField(string16(), |
503 ASCIIToUTF16("Submit"), | 501 ASCIIToUTF16("Submit"), |
504 string16(), | 502 string16(), |
505 ASCIIToUTF16("submit"), | 503 ASCIIToUTF16("submit"), |
506 0)); | 504 0)); |
507 form_structure.reset(new FormStructure(form)); | 505 form_structure.reset(new FormStructure(form)); |
508 EXPECT_TRUE(form_structure->IsAutoFillable(true)); | 506 EXPECT_TRUE(form_structure->IsAutoFillable()); |
509 ASSERT_EQ(10U, form_structure->field_count()); | 507 ASSERT_EQ(10U, form_structure->field_count()); |
510 ASSERT_EQ(9U, form_structure->autofill_count()); | 508 ASSERT_EQ(9U, form_structure->autofill_count()); |
511 | 509 |
512 // First name. | 510 // First name. |
513 EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type()); | 511 EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type()); |
514 // Last name. | 512 // Last name. |
515 EXPECT_EQ(NAME_LAST, form_structure->field(1)->heuristic_type()); | 513 EXPECT_EQ(NAME_LAST, form_structure->field(1)->heuristic_type()); |
516 // Address. | 514 // Address. |
517 EXPECT_EQ(ADDRESS_BILLING_LINE1, form_structure->field(2)->heuristic_type()); | 515 EXPECT_EQ(ADDRESS_BILLING_LINE1, form_structure->field(2)->heuristic_type()); |
518 // Address. | 516 // Address. |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
576 ASCIIToUTF16("text"), | 574 ASCIIToUTF16("text"), |
577 0)); | 575 0)); |
578 // TODO(jhawkins): Phone number. | 576 // TODO(jhawkins): Phone number. |
579 form.fields.push_back( | 577 form.fields.push_back( |
580 webkit_glue::FormField(string16(), | 578 webkit_glue::FormField(string16(), |
581 ASCIIToUTF16("Submit"), | 579 ASCIIToUTF16("Submit"), |
582 ASCIIToUTF16("continue"), | 580 ASCIIToUTF16("continue"), |
583 ASCIIToUTF16("submit"), | 581 ASCIIToUTF16("submit"), |
584 0)); | 582 0)); |
585 form_structure.reset(new FormStructure(form)); | 583 form_structure.reset(new FormStructure(form)); |
586 EXPECT_TRUE(form_structure->IsAutoFillable(true)); | 584 EXPECT_TRUE(form_structure->IsAutoFillable()); |
587 ASSERT_EQ(7U, form_structure->field_count()); | 585 ASSERT_EQ(7U, form_structure->field_count()); |
588 ASSERT_EQ(6U, form_structure->autofill_count()); | 586 ASSERT_EQ(6U, form_structure->autofill_count()); |
589 | 587 |
590 // Email. | 588 // Email. |
591 EXPECT_EQ(EMAIL_ADDRESS, form_structure->field(0)->heuristic_type()); | 589 EXPECT_EQ(EMAIL_ADDRESS, form_structure->field(0)->heuristic_type()); |
592 // Full name. | 590 // Full name. |
593 EXPECT_EQ(NAME_FULL, form_structure->field(1)->heuristic_type()); | 591 EXPECT_EQ(NAME_FULL, form_structure->field(1)->heuristic_type()); |
594 // Company | 592 // Company |
595 EXPECT_EQ(COMPANY_NAME, form_structure->field(2)->heuristic_type()); | 593 EXPECT_EQ(COMPANY_NAME, form_structure->field(2)->heuristic_type()); |
596 // Address. | 594 // Address. |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
650 string16(), | 648 string16(), |
651 string16(), | 649 string16(), |
652 ASCIIToUTF16("text"), | 650 ASCIIToUTF16("text"), |
653 0)); | 651 0)); |
654 form.fields.push_back(webkit_glue::FormField(string16(), | 652 form.fields.push_back(webkit_glue::FormField(string16(), |
655 ASCIIToUTF16("Submit"), | 653 ASCIIToUTF16("Submit"), |
656 string16(), | 654 string16(), |
657 ASCIIToUTF16("submit"), | 655 ASCIIToUTF16("submit"), |
658 0)); | 656 0)); |
659 form_structure.reset(new FormStructure(form)); | 657 form_structure.reset(new FormStructure(form)); |
660 EXPECT_TRUE(form_structure->IsAutoFillable(true)); | 658 EXPECT_TRUE(form_structure->IsAutoFillable()); |
661 ASSERT_EQ(9U, form_structure->field_count()); | 659 ASSERT_EQ(9U, form_structure->field_count()); |
662 ASSERT_EQ(8U, form_structure->autofill_count()); | 660 ASSERT_EQ(8U, form_structure->autofill_count()); |
663 | 661 |
664 // First name. | 662 // First name. |
665 EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type()); | 663 EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type()); |
666 // Last name. | 664 // Last name. |
667 EXPECT_EQ(NAME_LAST, form_structure->field(1)->heuristic_type()); | 665 EXPECT_EQ(NAME_LAST, form_structure->field(1)->heuristic_type()); |
668 // Email. | 666 // Email. |
669 EXPECT_EQ(EMAIL_ADDRESS, form_structure->field(2)->heuristic_type()); | 667 EXPECT_EQ(EMAIL_ADDRESS, form_structure->field(2)->heuristic_type()); |
670 // Phone. | 668 // Phone. |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
711 ASCIIToUTF16("verification"), | 709 ASCIIToUTF16("verification"), |
712 string16(), | 710 string16(), |
713 ASCIIToUTF16("text"), | 711 ASCIIToUTF16("text"), |
714 0)); | 712 0)); |
715 form.fields.push_back(webkit_glue::FormField(string16(), | 713 form.fields.push_back(webkit_glue::FormField(string16(), |
716 ASCIIToUTF16("Submit"), | 714 ASCIIToUTF16("Submit"), |
717 string16(), | 715 string16(), |
718 ASCIIToUTF16("submit"), | 716 ASCIIToUTF16("submit"), |
719 0)); | 717 0)); |
720 form_structure.reset(new FormStructure(form)); | 718 form_structure.reset(new FormStructure(form)); |
721 EXPECT_TRUE(form_structure->IsAutoFillable(true)); | 719 EXPECT_TRUE(form_structure->IsAutoFillable()); |
722 ASSERT_EQ(6U, form_structure->field_count()); | 720 ASSERT_EQ(6U, form_structure->field_count()); |
723 ASSERT_EQ(4U, form_structure->autofill_count()); | 721 ASSERT_EQ(4U, form_structure->autofill_count()); |
724 | 722 |
725 // Credit card name. | 723 // Credit card name. |
726 EXPECT_EQ(CREDIT_CARD_NAME, form_structure->field(0)->heuristic_type()); | 724 EXPECT_EQ(CREDIT_CARD_NAME, form_structure->field(0)->heuristic_type()); |
727 // Credit card number. | 725 // Credit card number. |
728 EXPECT_EQ(CREDIT_CARD_NUMBER, form_structure->field(1)->heuristic_type()); | 726 EXPECT_EQ(CREDIT_CARD_NUMBER, form_structure->field(1)->heuristic_type()); |
729 // Credit card expiration month. | 727 // Credit card expiration month. |
730 EXPECT_EQ(CREDIT_CARD_EXP_MONTH, form_structure->field(2)->heuristic_type()); | 728 EXPECT_EQ(CREDIT_CARD_EXP_MONTH, form_structure->field(2)->heuristic_type()); |
731 // Credit card expiration year. | 729 // Credit card expiration year. |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
773 ASCIIToUTF16("verification"), | 771 ASCIIToUTF16("verification"), |
774 string16(), | 772 string16(), |
775 ASCIIToUTF16("text"), | 773 ASCIIToUTF16("text"), |
776 0)); | 774 0)); |
777 form.fields.push_back(webkit_glue::FormField(string16(), | 775 form.fields.push_back(webkit_glue::FormField(string16(), |
778 ASCIIToUTF16("Submit"), | 776 ASCIIToUTF16("Submit"), |
779 string16(), | 777 string16(), |
780 ASCIIToUTF16("submit"), | 778 ASCIIToUTF16("submit"), |
781 0)); | 779 0)); |
782 form_structure.reset(new FormStructure(form)); | 780 form_structure.reset(new FormStructure(form)); |
783 EXPECT_TRUE(form_structure->IsAutoFillable(true)); | 781 EXPECT_TRUE(form_structure->IsAutoFillable()); |
784 ASSERT_EQ(7U, form_structure->field_count()); | 782 ASSERT_EQ(7U, form_structure->field_count()); |
785 ASSERT_EQ(4U, form_structure->autofill_count()); | 783 ASSERT_EQ(4U, form_structure->autofill_count()); |
786 | 784 |
787 // Credit card name. | 785 // Credit card name. |
788 EXPECT_EQ(CREDIT_CARD_NAME, form_structure->field(0)->heuristic_type()); | 786 EXPECT_EQ(CREDIT_CARD_NAME, form_structure->field(0)->heuristic_type()); |
789 // Credit card type. This is an unknown type but related to the credit card. | 787 // Credit card type. This is an unknown type but related to the credit card. |
790 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(1)->heuristic_type()); | 788 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(1)->heuristic_type()); |
791 // Credit card number. | 789 // Credit card number. |
792 EXPECT_EQ(CREDIT_CARD_NUMBER, form_structure->field(2)->heuristic_type()); | 790 EXPECT_EQ(CREDIT_CARD_NUMBER, form_structure->field(2)->heuristic_type()); |
793 // Credit card expiration month. | 791 // Credit card expiration month. |
(...skipping 30 matching lines...) Expand all Loading... |
824 string16(), | 822 string16(), |
825 ASCIIToUTF16("text"), | 823 ASCIIToUTF16("text"), |
826 0)); | 824 0)); |
827 form.fields.push_back( | 825 form.fields.push_back( |
828 webkit_glue::FormField(ASCIIToUTF16("City"), | 826 webkit_glue::FormField(ASCIIToUTF16("City"), |
829 ASCIIToUTF16("city"), | 827 ASCIIToUTF16("city"), |
830 string16(), | 828 string16(), |
831 ASCIIToUTF16("text"), | 829 ASCIIToUTF16("text"), |
832 0)); | 830 0)); |
833 form_structure.reset(new FormStructure(form)); | 831 form_structure.reset(new FormStructure(form)); |
834 EXPECT_TRUE(form_structure->IsAutoFillable(true)); | 832 EXPECT_TRUE(form_structure->IsAutoFillable()); |
835 ASSERT_EQ(4U, form_structure->field_count()); | 833 ASSERT_EQ(4U, form_structure->field_count()); |
836 ASSERT_EQ(3U, form_structure->autofill_count()); | 834 ASSERT_EQ(3U, form_structure->autofill_count()); |
837 | 835 |
838 // Address Line 1. | 836 // Address Line 1. |
839 EXPECT_EQ(ADDRESS_HOME_LINE1, form_structure->field(0)->heuristic_type()); | 837 EXPECT_EQ(ADDRESS_HOME_LINE1, form_structure->field(0)->heuristic_type()); |
840 // Address Line 2. | 838 // Address Line 2. |
841 EXPECT_EQ(ADDRESS_HOME_LINE2, form_structure->field(1)->heuristic_type()); | 839 EXPECT_EQ(ADDRESS_HOME_LINE2, form_structure->field(1)->heuristic_type()); |
842 // Address Line 3. | 840 // Address Line 3. |
843 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(2)->heuristic_type()); | 841 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(2)->heuristic_type()); |
844 // City. | 842 // City. |
(...skipping 25 matching lines...) Expand all Loading... |
870 string16(), | 868 string16(), |
871 ASCIIToUTF16("text"), | 869 ASCIIToUTF16("text"), |
872 0)); | 870 0)); |
873 form.fields.push_back( | 871 form.fields.push_back( |
874 webkit_glue::FormField(ASCIIToUTF16("Address Line2"), | 872 webkit_glue::FormField(ASCIIToUTF16("Address Line2"), |
875 ASCIIToUTF16("billing.address.addressLine2"), | 873 ASCIIToUTF16("billing.address.addressLine2"), |
876 string16(), | 874 string16(), |
877 ASCIIToUTF16("text"), | 875 ASCIIToUTF16("text"), |
878 0)); | 876 0)); |
879 form_structure.reset(new FormStructure(form)); | 877 form_structure.reset(new FormStructure(form)); |
880 EXPECT_TRUE(form_structure->IsAutoFillable(true)); | 878 EXPECT_TRUE(form_structure->IsAutoFillable()); |
881 ASSERT_EQ(4U, form_structure->field_count()); | 879 ASSERT_EQ(4U, form_structure->field_count()); |
882 ASSERT_EQ(4U, form_structure->autofill_count()); | 880 ASSERT_EQ(4U, form_structure->autofill_count()); |
883 | 881 |
884 // Address Line 1. | 882 // Address Line 1. |
885 EXPECT_EQ(ADDRESS_HOME_LINE1, form_structure->field(0)->heuristic_type()); | 883 EXPECT_EQ(ADDRESS_HOME_LINE1, form_structure->field(0)->heuristic_type()); |
886 // Address Line 2. | 884 // Address Line 2. |
887 EXPECT_EQ(ADDRESS_HOME_LINE2, form_structure->field(1)->heuristic_type()); | 885 EXPECT_EQ(ADDRESS_HOME_LINE2, form_structure->field(1)->heuristic_type()); |
888 // Address Line 1. | 886 // Address Line 1. |
889 EXPECT_EQ(ADDRESS_BILLING_LINE1, form_structure->field(2)->heuristic_type()); | 887 EXPECT_EQ(ADDRESS_BILLING_LINE1, form_structure->field(2)->heuristic_type()); |
890 // Address Line 2. | 888 // Address Line 2. |
(...skipping 29 matching lines...) Expand all Loading... |
920 string16(), | 918 string16(), |
921 ASCIIToUTF16("text"), | 919 ASCIIToUTF16("text"), |
922 0)); | 920 0)); |
923 form.fields.push_back( | 921 form.fields.push_back( |
924 webkit_glue::FormField(ASCIIToUTF16("City:"), | 922 webkit_glue::FormField(ASCIIToUTF16("City:"), |
925 ASCIIToUTF16("FOPIH_RgWebCC_0_IHAddress_adct"), | 923 ASCIIToUTF16("FOPIH_RgWebCC_0_IHAddress_adct"), |
926 string16(), | 924 string16(), |
927 ASCIIToUTF16("text"), | 925 ASCIIToUTF16("text"), |
928 0)); | 926 0)); |
929 form_structure.reset(new FormStructure(form)); | 927 form_structure.reset(new FormStructure(form)); |
930 EXPECT_TRUE(form_structure->IsAutoFillable(true)); | 928 EXPECT_TRUE(form_structure->IsAutoFillable()); |
931 ASSERT_EQ(4U, form_structure->field_count()); | 929 ASSERT_EQ(4U, form_structure->field_count()); |
932 ASSERT_EQ(3U, form_structure->autofill_count()); | 930 ASSERT_EQ(3U, form_structure->autofill_count()); |
933 | 931 |
934 // Address Line 1. | 932 // Address Line 1. |
935 EXPECT_EQ(ADDRESS_HOME_LINE1, form_structure->field(0)->heuristic_type()); | 933 EXPECT_EQ(ADDRESS_HOME_LINE1, form_structure->field(0)->heuristic_type()); |
936 // Suite / Apt. | 934 // Suite / Apt. |
937 EXPECT_EQ(ADDRESS_HOME_LINE2, form_structure->field(1)->heuristic_type()); | 935 EXPECT_EQ(ADDRESS_HOME_LINE2, form_structure->field(1)->heuristic_type()); |
938 // Address Line 3. | 936 // Address Line 3. |
939 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(2)->heuristic_type()); | 937 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(2)->heuristic_type()); |
940 // City. | 938 // City. |
(...skipping 20 matching lines...) Expand all Loading... |
961 string16(), | 959 string16(), |
962 ASCIIToUTF16("text"), | 960 ASCIIToUTF16("text"), |
963 0)); | 961 0)); |
964 form.fields.push_back( | 962 form.fields.push_back( |
965 webkit_glue::FormField(ASCIIToUTF16("City"), | 963 webkit_glue::FormField(ASCIIToUTF16("City"), |
966 ASCIIToUTF16("city"), | 964 ASCIIToUTF16("city"), |
967 string16(), | 965 string16(), |
968 ASCIIToUTF16("text"), | 966 ASCIIToUTF16("text"), |
969 0)); | 967 0)); |
970 form_structure.reset(new FormStructure(form)); | 968 form_structure.reset(new FormStructure(form)); |
971 EXPECT_TRUE(form_structure->IsAutoFillable(true)); | 969 EXPECT_TRUE(form_structure->IsAutoFillable()); |
972 ASSERT_EQ(3U, form_structure->field_count()); | 970 ASSERT_EQ(3U, form_structure->field_count()); |
973 ASSERT_EQ(3U, form_structure->autofill_count()); | 971 ASSERT_EQ(3U, form_structure->autofill_count()); |
974 | 972 |
975 // Address Line 1. | 973 // Address Line 1. |
976 EXPECT_EQ(ADDRESS_HOME_LINE1, form_structure->field(0)->heuristic_type()); | 974 EXPECT_EQ(ADDRESS_HOME_LINE1, form_structure->field(0)->heuristic_type()); |
977 // Address Line 2. | 975 // Address Line 2. |
978 EXPECT_EQ(ADDRESS_HOME_LINE2, form_structure->field(1)->heuristic_type()); | 976 EXPECT_EQ(ADDRESS_HOME_LINE2, form_structure->field(1)->heuristic_type()); |
979 // City. | 977 // City. |
980 EXPECT_EQ(ADDRESS_HOME_CITY, form_structure->field(2)->heuristic_type()); | 978 EXPECT_EQ(ADDRESS_HOME_CITY, form_structure->field(2)->heuristic_type()); |
981 } | 979 } |
(...skipping 15 matching lines...) Expand all Loading... |
997 string16(), | 995 string16(), |
998 ASCIIToUTF16("text"), | 996 ASCIIToUTF16("text"), |
999 0)); | 997 0)); |
1000 form.fields.push_back( | 998 form.fields.push_back( |
1001 webkit_glue::FormField(ASCIIToUTF16("State/Province/Region"), | 999 webkit_glue::FormField(ASCIIToUTF16("State/Province/Region"), |
1002 ASCIIToUTF16("State"), | 1000 ASCIIToUTF16("State"), |
1003 string16(), | 1001 string16(), |
1004 ASCIIToUTF16("text"), | 1002 ASCIIToUTF16("text"), |
1005 0)); | 1003 0)); |
1006 form_structure.reset(new FormStructure(form)); | 1004 form_structure.reset(new FormStructure(form)); |
1007 EXPECT_TRUE(form_structure->IsAutoFillable(true)); | 1005 EXPECT_TRUE(form_structure->IsAutoFillable()); |
1008 ASSERT_EQ(3U, form_structure->field_count()); | 1006 ASSERT_EQ(3U, form_structure->field_count()); |
1009 ASSERT_EQ(3U, form_structure->autofill_count()); | 1007 ASSERT_EQ(3U, form_structure->autofill_count()); |
1010 | 1008 |
1011 // Address Line 1. | 1009 // Address Line 1. |
1012 EXPECT_EQ(ADDRESS_HOME_LINE1, form_structure->field(0)->heuristic_type()); | 1010 EXPECT_EQ(ADDRESS_HOME_LINE1, form_structure->field(0)->heuristic_type()); |
1013 // Address Line 2. | 1011 // Address Line 2. |
1014 EXPECT_EQ(ADDRESS_HOME_LINE2, form_structure->field(1)->heuristic_type()); | 1012 EXPECT_EQ(ADDRESS_HOME_LINE2, form_structure->field(1)->heuristic_type()); |
1015 // State. | 1013 // State. |
1016 EXPECT_EQ(ADDRESS_HOME_STATE, form_structure->field(2)->heuristic_type()); | 1014 EXPECT_EQ(ADDRESS_HOME_STATE, form_structure->field(2)->heuristic_type()); |
1017 } | 1015 } |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1082 string16(), | 1080 string16(), |
1083 ASCIIToUTF16("text"), | 1081 ASCIIToUTF16("text"), |
1084 0)); | 1082 0)); |
1085 form.fields.push_back( | 1083 form.fields.push_back( |
1086 webkit_glue::FormField(ASCIIToUTF16("Email Address*:"), | 1084 webkit_glue::FormField(ASCIIToUTF16("Email Address*:"), |
1087 ASCIIToUTF16("email$emailBox"), | 1085 ASCIIToUTF16("email$emailBox"), |
1088 string16(), | 1086 string16(), |
1089 ASCIIToUTF16("text"), | 1087 ASCIIToUTF16("text"), |
1090 0)); | 1088 0)); |
1091 form_structure.reset(new FormStructure(form)); | 1089 form_structure.reset(new FormStructure(form)); |
1092 EXPECT_TRUE(form_structure->IsAutoFillable(true)); | 1090 EXPECT_TRUE(form_structure->IsAutoFillable()); |
1093 ASSERT_EQ(11U, form_structure->field_count()); | 1091 ASSERT_EQ(11U, form_structure->field_count()); |
1094 ASSERT_EQ(11U, form_structure->autofill_count()); | 1092 ASSERT_EQ(11U, form_structure->autofill_count()); |
1095 | 1093 |
1096 EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type()); | 1094 EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type()); |
1097 EXPECT_EQ(NAME_LAST, form_structure->field(1)->heuristic_type()); | 1095 EXPECT_EQ(NAME_LAST, form_structure->field(1)->heuristic_type()); |
1098 EXPECT_EQ(COMPANY_NAME, form_structure->field(2)->heuristic_type()); | 1096 EXPECT_EQ(COMPANY_NAME, form_structure->field(2)->heuristic_type()); |
1099 EXPECT_EQ(ADDRESS_BILLING_LINE1, form_structure->field(3)->heuristic_type()); | 1097 EXPECT_EQ(ADDRESS_BILLING_LINE1, form_structure->field(3)->heuristic_type()); |
1100 EXPECT_EQ(ADDRESS_BILLING_LINE2, form_structure->field(4)->heuristic_type()); | 1098 EXPECT_EQ(ADDRESS_BILLING_LINE2, form_structure->field(4)->heuristic_type()); |
1101 EXPECT_EQ(ADDRESS_BILLING_CITY, form_structure->field(5)->heuristic_type()); | 1099 EXPECT_EQ(ADDRESS_BILLING_CITY, form_structure->field(5)->heuristic_type()); |
1102 EXPECT_EQ(ADDRESS_BILLING_STATE, form_structure->field(6)->heuristic_type()); | 1100 EXPECT_EQ(ADDRESS_BILLING_STATE, form_structure->field(6)->heuristic_type()); |
(...skipping 28 matching lines...) Expand all Loading... |
1131 string16(), | 1129 string16(), |
1132 ASCIIToUTF16("text"), | 1130 ASCIIToUTF16("text"), |
1133 0)); | 1131 0)); |
1134 form.fields.push_back( | 1132 form.fields.push_back( |
1135 webkit_glue::FormField(ASCIIToUTF16("ext.:"), | 1133 webkit_glue::FormField(ASCIIToUTF16("ext.:"), |
1136 ASCIIToUTF16("dayphone4"), | 1134 ASCIIToUTF16("dayphone4"), |
1137 string16(), | 1135 string16(), |
1138 ASCIIToUTF16("text"), | 1136 ASCIIToUTF16("text"), |
1139 0)); | 1137 0)); |
1140 form_structure.reset(new FormStructure(form)); | 1138 form_structure.reset(new FormStructure(form)); |
1141 EXPECT_TRUE(form_structure->IsAutoFillable(true)); | 1139 EXPECT_TRUE(form_structure->IsAutoFillable()); |
1142 ASSERT_EQ(4U, form_structure->field_count()); | 1140 ASSERT_EQ(4U, form_structure->field_count()); |
1143 ASSERT_EQ(3U, form_structure->autofill_count()); | 1141 ASSERT_EQ(3U, form_structure->autofill_count()); |
1144 | 1142 |
1145 // Area code. | 1143 // Area code. |
1146 EXPECT_EQ(PHONE_HOME_CITY_CODE, form_structure->field(0)->heuristic_type()); | 1144 EXPECT_EQ(PHONE_HOME_CITY_CODE, form_structure->field(0)->heuristic_type()); |
1147 // Phone number suffix. | 1145 // Phone number suffix. |
1148 EXPECT_EQ(PHONE_HOME_NUMBER, | 1146 EXPECT_EQ(PHONE_HOME_NUMBER, |
1149 form_structure->field(1)->heuristic_type()); | 1147 form_structure->field(1)->heuristic_type()); |
1150 // Phone number suffix. | 1148 // Phone number suffix. |
1151 EXPECT_EQ(PHONE_HOME_NUMBER, | 1149 EXPECT_EQ(PHONE_HOME_NUMBER, |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1202 ASCIIToUTF16("state"), | 1200 ASCIIToUTF16("state"), |
1203 string16(), | 1201 string16(), |
1204 ASCIIToUTF16("hidden"), | 1202 ASCIIToUTF16("hidden"), |
1205 0)); | 1203 0)); |
1206 form.fields.push_back(webkit_glue::FormField(string16(), | 1204 form.fields.push_back(webkit_glue::FormField(string16(), |
1207 ASCIIToUTF16("Submit"), | 1205 ASCIIToUTF16("Submit"), |
1208 string16(), | 1206 string16(), |
1209 ASCIIToUTF16("submit"), | 1207 ASCIIToUTF16("submit"), |
1210 0)); | 1208 0)); |
1211 form_structure.reset(new FormStructure(form)); | 1209 form_structure.reset(new FormStructure(form)); |
1212 EXPECT_TRUE(form_structure->IsAutoFillable(true)); | 1210 EXPECT_TRUE(form_structure->IsAutoFillable()); |
1213 | 1211 |
1214 // Expect the correct number of fields. | 1212 // Expect the correct number of fields. |
1215 ASSERT_EQ(10U, form_structure->field_count()); | 1213 ASSERT_EQ(10U, form_structure->field_count()); |
1216 ASSERT_EQ(6U, form_structure->autofill_count()); | 1214 ASSERT_EQ(6U, form_structure->autofill_count()); |
1217 | 1215 |
1218 // First name. | 1216 // First name. |
1219 EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type()); | 1217 EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type()); |
1220 // Last name. | 1218 // Last name. |
1221 EXPECT_EQ(NAME_LAST, form_structure->field(1)->heuristic_type()); | 1219 EXPECT_EQ(NAME_LAST, form_structure->field(1)->heuristic_type()); |
1222 // Email. | 1220 // Email. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1261 ASCIIToUTF16("expiration_month"), | 1259 ASCIIToUTF16("expiration_month"), |
1262 string16(), | 1260 string16(), |
1263 ASCIIToUTF16("text"), | 1261 ASCIIToUTF16("text"), |
1264 0)); | 1262 0)); |
1265 form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Expiration Year"), | 1263 form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Expiration Year"), |
1266 ASCIIToUTF16("expiration_year"), | 1264 ASCIIToUTF16("expiration_year"), |
1267 string16(), | 1265 string16(), |
1268 ASCIIToUTF16("text"), | 1266 ASCIIToUTF16("text"), |
1269 0)); | 1267 0)); |
1270 form_structure.reset(new FormStructure(form)); | 1268 form_structure.reset(new FormStructure(form)); |
1271 EXPECT_TRUE(form_structure->IsAutoFillable(true)); | 1269 EXPECT_TRUE(form_structure->IsAutoFillable()); |
1272 | 1270 |
1273 // Expect the correct number of fields. | 1271 // Expect the correct number of fields. |
1274 ASSERT_EQ(5U, form_structure->field_count()); | 1272 ASSERT_EQ(5U, form_structure->field_count()); |
1275 ASSERT_EQ(5U, form_structure->autofill_count()); | 1273 ASSERT_EQ(5U, form_structure->autofill_count()); |
1276 | 1274 |
1277 // Name on Card. | 1275 // Name on Card. |
1278 EXPECT_EQ(CREDIT_CARD_NAME, form_structure->field(0)->heuristic_type()); | 1276 EXPECT_EQ(CREDIT_CARD_NAME, form_structure->field(0)->heuristic_type()); |
1279 // Address. | 1277 // Address. |
1280 EXPECT_EQ(ADDRESS_BILLING_LINE1, form_structure->field(1)->heuristic_type()); | 1278 EXPECT_EQ(ADDRESS_BILLING_LINE1, form_structure->field(1)->heuristic_type()); |
1281 // Card Number. | 1279 // Card Number. |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1541 } | 1539 } |
1542 form_structure.reset(new FormStructure(form)); | 1540 form_structure.reset(new FormStructure(form)); |
1543 ASSERT_EQ(form_structure->field_count(), possible_field_types.size()); | 1541 ASSERT_EQ(form_structure->field_count(), possible_field_types.size()); |
1544 for (size_t i = 0; i < form_structure->field_count(); ++i) | 1542 for (size_t i = 0; i < form_structure->field_count(); ++i) |
1545 form_structure->set_possible_types(i, possible_field_types[i]); | 1543 form_structure->set_possible_types(i, possible_field_types[i]); |
1546 EXPECT_FALSE(form_structure->EncodeUploadRequest(false, &encoded_xml)); | 1544 EXPECT_FALSE(form_structure->EncodeUploadRequest(false, &encoded_xml)); |
1547 EXPECT_EQ(encoded_xml, ""); | 1545 EXPECT_EQ(encoded_xml, ""); |
1548 } | 1546 } |
1549 | 1547 |
1550 } // namespace | 1548 } // namespace |
OLD | NEW |