OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/memory/scoped_ptr.h" | 5 #include "base/memory/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 "chrome/common/form_data.h" | 9 #include "chrome/common/form_data.h" |
10 #include "chrome/common/form_field_data.h" | 10 #include "chrome/common/form_field_data.h" |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
322 // Address. | 322 // Address. |
323 EXPECT_EQ(ADDRESS_HOME_LINE1, form_structure->field(4)->heuristic_type()); | 323 EXPECT_EQ(ADDRESS_HOME_LINE1, form_structure->field(4)->heuristic_type()); |
324 // City. | 324 // City. |
325 EXPECT_EQ(ADDRESS_HOME_CITY, form_structure->field(5)->heuristic_type()); | 325 EXPECT_EQ(ADDRESS_HOME_CITY, form_structure->field(5)->heuristic_type()); |
326 // Zip. | 326 // Zip. |
327 EXPECT_EQ(ADDRESS_HOME_ZIP, form_structure->field(6)->heuristic_type()); | 327 EXPECT_EQ(ADDRESS_HOME_ZIP, form_structure->field(6)->heuristic_type()); |
328 // Submit. | 328 // Submit. |
329 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(7)->heuristic_type()); | 329 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(7)->heuristic_type()); |
330 } | 330 } |
331 | 331 |
332 // Verify that we can correctly process the |autocompletetype| attribute. | 332 // Verify that we can correctly process the |autocomplete| attribute. |
333 TEST(FormStructureTest, HeuristicsAutocompletetype) { | 333 TEST(FormStructureTest, HeuristicsAutocompleteAttribute) { |
334 scoped_ptr<FormStructure> form_structure; | 334 scoped_ptr<FormStructure> form_structure; |
335 FormData form; | 335 FormData form; |
336 form.method = ASCIIToUTF16("post"); | 336 form.method = ASCIIToUTF16("post"); |
337 | 337 |
338 FormFieldData field; | 338 FormFieldData field; |
339 field.form_control_type = ASCIIToUTF16("text"); | 339 field.form_control_type = ASCIIToUTF16("text"); |
340 | 340 |
341 field.label = string16(); | 341 field.label = string16(); |
342 field.name = ASCIIToUTF16("field1"); | 342 field.name = ASCIIToUTF16("field1"); |
343 field.autocomplete_type = ASCIIToUTF16("given-name"); | 343 field.autocomplete_attribute = ASCIIToUTF16("given-name"); |
344 form.fields.push_back(field); | 344 form.fields.push_back(field); |
345 | 345 |
346 field.label = string16(); | 346 field.label = string16(); |
347 field.name = ASCIIToUTF16("field2"); | 347 field.name = ASCIIToUTF16("field2"); |
348 field.autocomplete_type = ASCIIToUTF16("surname"); | 348 field.autocomplete_attribute = ASCIIToUTF16("family-name"); |
349 form.fields.push_back(field); | 349 form.fields.push_back(field); |
350 | 350 |
351 field.label = string16(); | 351 field.label = string16(); |
352 field.name = ASCIIToUTF16("field3"); | 352 field.name = ASCIIToUTF16("field3"); |
353 field.autocomplete_type = ASCIIToUTF16("email"); | 353 field.autocomplete_attribute = ASCIIToUTF16("email"); |
354 form.fields.push_back(field); | 354 form.fields.push_back(field); |
355 | 355 |
356 form_structure.reset(new FormStructure(form)); | 356 form_structure.reset(new FormStructure(form)); |
357 form_structure->DetermineHeuristicTypes(); | 357 form_structure->DetermineHeuristicTypes(); |
358 EXPECT_TRUE(form_structure->IsAutofillable(true)); | 358 EXPECT_TRUE(form_structure->IsAutofillable(true)); |
359 | 359 |
360 // Expect the correct number of fields. | 360 // Expect the correct number of fields. |
361 ASSERT_EQ(3U, form_structure->field_count()); | 361 ASSERT_EQ(3U, form_structure->field_count()); |
362 ASSERT_EQ(3U, form_structure->autofill_count()); | 362 ASSERT_EQ(3U, form_structure->autofill_count()); |
363 | 363 |
364 EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type()); | 364 EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type()); |
365 EXPECT_EQ(NAME_LAST, form_structure->field(1)->heuristic_type()); | 365 EXPECT_EQ(NAME_LAST, form_structure->field(1)->heuristic_type()); |
366 EXPECT_EQ(EMAIL_ADDRESS, form_structure->field(2)->heuristic_type()); | 366 EXPECT_EQ(EMAIL_ADDRESS, form_structure->field(2)->heuristic_type()); |
367 } | 367 } |
368 | 368 |
369 // Verify that we can correctly process the |autocompletetype| attribute for | 369 // Verify that we can correctly process the |autocompletetype| attribute for |
370 // phone number types (especially phone prefixes and suffixes). | 370 // phone number types (especially phone prefixes and suffixes). |
371 TEST(FormStructureTest, HeuristicsAutocompletetypePhones) { | 371 TEST(FormStructureTest, HeuristicsAutocompleteAttributePhoneTypes) { |
372 scoped_ptr<FormStructure> form_structure; | 372 scoped_ptr<FormStructure> form_structure; |
373 FormData form; | 373 FormData form; |
374 form.method = ASCIIToUTF16("post"); | 374 form.method = ASCIIToUTF16("post"); |
375 | 375 |
376 FormFieldData field; | 376 FormFieldData field; |
377 field.form_control_type = ASCIIToUTF16("text"); | 377 field.form_control_type = ASCIIToUTF16("text"); |
378 | 378 |
379 field.label = string16(); | 379 field.label = string16(); |
380 field.name = ASCIIToUTF16("field1"); | 380 field.name = ASCIIToUTF16("field1"); |
381 field.autocomplete_type = ASCIIToUTF16("phone-local"); | 381 field.autocomplete_attribute = ASCIIToUTF16("tel-local"); |
382 form.fields.push_back(field); | 382 form.fields.push_back(field); |
383 | 383 |
384 field.label = string16(); | 384 field.label = string16(); |
385 field.name = ASCIIToUTF16("field2"); | 385 field.name = ASCIIToUTF16("field2"); |
386 field.autocomplete_type = ASCIIToUTF16("phone-local-prefix"); | 386 field.autocomplete_attribute = ASCIIToUTF16("tel-local-prefix"); |
387 form.fields.push_back(field); | 387 form.fields.push_back(field); |
388 | 388 |
389 field.label = string16(); | 389 field.label = string16(); |
390 field.name = ASCIIToUTF16("field3"); | 390 field.name = ASCIIToUTF16("field3"); |
391 field.autocomplete_type = ASCIIToUTF16("phone-local-suffix"); | 391 field.autocomplete_attribute = ASCIIToUTF16("tel-local-suffix"); |
392 form.fields.push_back(field); | 392 form.fields.push_back(field); |
393 | 393 |
394 form_structure.reset(new FormStructure(form)); | 394 form_structure.reset(new FormStructure(form)); |
395 form_structure->DetermineHeuristicTypes(); | 395 form_structure->DetermineHeuristicTypes(); |
396 EXPECT_TRUE(form_structure->IsAutofillable(true)); | 396 EXPECT_TRUE(form_structure->IsAutofillable(true)); |
397 | 397 |
398 // Expect the correct number of fields. | 398 // Expect the correct number of fields. |
399 ASSERT_EQ(3U, form_structure->field_count()); | 399 ASSERT_EQ(3U, form_structure->field_count()); |
400 EXPECT_EQ(3U, form_structure->autofill_count()); | 400 EXPECT_EQ(3U, form_structure->autofill_count()); |
401 | 401 |
402 EXPECT_EQ(PHONE_HOME_NUMBER, form_structure->field(0)->heuristic_type()); | 402 EXPECT_EQ(PHONE_HOME_NUMBER, form_structure->field(0)->heuristic_type()); |
403 EXPECT_EQ(AutofillField::IGNORED, form_structure->field(0)->phone_part()); | 403 EXPECT_EQ(AutofillField::IGNORED, form_structure->field(0)->phone_part()); |
404 EXPECT_EQ(PHONE_HOME_NUMBER, form_structure->field(1)->heuristic_type()); | 404 EXPECT_EQ(PHONE_HOME_NUMBER, form_structure->field(1)->heuristic_type()); |
405 EXPECT_EQ(AutofillField::PHONE_PREFIX, | 405 EXPECT_EQ(AutofillField::PHONE_PREFIX, |
406 form_structure->field(1)->phone_part()); | 406 form_structure->field(1)->phone_part()); |
407 EXPECT_EQ(PHONE_HOME_NUMBER, form_structure->field(2)->heuristic_type()); | 407 EXPECT_EQ(PHONE_HOME_NUMBER, form_structure->field(2)->heuristic_type()); |
408 EXPECT_EQ(AutofillField::PHONE_SUFFIX, | 408 EXPECT_EQ(AutofillField::PHONE_SUFFIX, |
409 form_structure->field(2)->phone_part()); | 409 form_structure->field(2)->phone_part()); |
410 } | 410 } |
411 | 411 |
412 // If at least one field includes the |autocompletetype| attribute, we should | 412 // If at least one field includes the |autocompletetype| attribute, we should |
Dan Beam
2012/10/19 00:12:44
|autocompletetype| -> |autocomplete| probably, rig
Ilya Sherman
2012/10/19 04:19:32
Done.
| |
413 // not try to apply any other heuristics. | 413 // not try to apply any other heuristics. |
414 TEST(FormStructureTest, AutocompletetypeOverridesOtherHeuristics) { | 414 TEST(FormStructureTest, AutocompleteAttributeOverridesOtherHeuristics) { |
415 scoped_ptr<FormStructure> form_structure; | 415 scoped_ptr<FormStructure> form_structure; |
416 FormData form; | 416 FormData form; |
417 form.method = ASCIIToUTF16("post"); | 417 form.method = ASCIIToUTF16("post"); |
418 | 418 |
419 // Start with a regular contact form. | 419 // Start with a regular contact form. |
420 FormFieldData field; | 420 FormFieldData field; |
421 field.form_control_type = ASCIIToUTF16("text"); | 421 field.form_control_type = ASCIIToUTF16("text"); |
422 | 422 |
423 field.label = ASCIIToUTF16("First Name"); | 423 field.label = ASCIIToUTF16("First Name"); |
424 field.name = ASCIIToUTF16("firstname"); | 424 field.name = ASCIIToUTF16("firstname"); |
(...skipping 13 matching lines...) Expand all Loading... | |
438 EXPECT_TRUE(form_structure->ShouldBeCrowdsourced()); | 438 EXPECT_TRUE(form_structure->ShouldBeCrowdsourced()); |
439 | 439 |
440 ASSERT_EQ(3U, form_structure->field_count()); | 440 ASSERT_EQ(3U, form_structure->field_count()); |
441 ASSERT_EQ(3U, form_structure->autofill_count()); | 441 ASSERT_EQ(3U, form_structure->autofill_count()); |
442 | 442 |
443 EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type()); | 443 EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type()); |
444 EXPECT_EQ(NAME_LAST, form_structure->field(1)->heuristic_type()); | 444 EXPECT_EQ(NAME_LAST, form_structure->field(1)->heuristic_type()); |
445 EXPECT_EQ(EMAIL_ADDRESS, form_structure->field(2)->heuristic_type()); | 445 EXPECT_EQ(EMAIL_ADDRESS, form_structure->field(2)->heuristic_type()); |
446 | 446 |
447 // Now update the first form field to include an 'autocompletetype' attribute. | 447 // Now update the first form field to include an 'autocompletetype' attribute. |
448 form.fields.front().autocomplete_type = ASCIIToUTF16("x-other"); | 448 form.fields.front().autocomplete_attribute = ASCIIToUTF16("x-other"); |
449 form_structure.reset(new FormStructure(form)); | 449 form_structure.reset(new FormStructure(form)); |
450 form_structure->DetermineHeuristicTypes(); | 450 form_structure->DetermineHeuristicTypes(); |
451 EXPECT_FALSE(form_structure->IsAutofillable(true)); | 451 EXPECT_FALSE(form_structure->IsAutofillable(true)); |
452 EXPECT_FALSE(form_structure->ShouldBeCrowdsourced()); | 452 EXPECT_FALSE(form_structure->ShouldBeCrowdsourced()); |
453 | 453 |
454 ASSERT_EQ(3U, form_structure->field_count()); | 454 ASSERT_EQ(3U, form_structure->field_count()); |
455 ASSERT_EQ(0U, form_structure->autofill_count()); | 455 ASSERT_EQ(0U, form_structure->autofill_count()); |
456 | 456 |
457 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(0)->heuristic_type()); | 457 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(0)->heuristic_type()); |
458 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(1)->heuristic_type()); | 458 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(1)->heuristic_type()); |
459 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(2)->heuristic_type()); | 459 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(2)->heuristic_type()); |
460 } | 460 } |
461 | 461 |
462 // Verify that we can correctly process sections listed in the |autocomplete| | 462 // Verify that we can correctly process sections listed in the |autocomplete| |
463 // attribute. | 463 // attribute. |
464 TEST(FormStructureTest, HeuristicsAutocompletetypeWithSections) { | 464 TEST(FormStructureTest, HeuristicsAutocompleteAttributeWithSections) { |
465 scoped_ptr<FormStructure> form_structure; | 465 scoped_ptr<FormStructure> form_structure; |
466 FormData form; | 466 FormData form; |
467 form.method = ASCIIToUTF16("post"); | 467 form.method = ASCIIToUTF16("post"); |
468 | 468 |
469 FormFieldData field; | 469 FormFieldData field; |
470 field.form_control_type = ASCIIToUTF16("text"); | 470 field.form_control_type = ASCIIToUTF16("text"); |
471 | 471 |
472 // We expect "shipping" and "billing" to be the most common sections. | 472 // Some fields will have no section specified. These fall into the default |
473 // section, with an empty name. | |
473 field.label = string16(); | 474 field.label = string16(); |
474 field.name = ASCIIToUTF16("field1"); | 475 field.name = ASCIIToUTF16("field1"); |
475 field.autocomplete_type = ASCIIToUTF16("section-shipping given-name"); | 476 field.autocomplete_attribute = ASCIIToUTF16("given-name"); |
476 form.fields.push_back(field); | |
477 | |
478 // Some field will have no section specified. These fall into the default | |
479 // section, with an empty name. | |
480 field.label = string16(); | |
481 field.name = ASCIIToUTF16("field2"); | |
482 field.autocomplete_type = ASCIIToUTF16("surname"); | |
483 form.fields.push_back(field); | 477 form.fields.push_back(field); |
484 | 478 |
485 // We allow arbitrary section names. | 479 // We allow arbitrary section names. |
486 field.label = string16(); | 480 field.label = string16(); |
481 field.name = ASCIIToUTF16("field2"); | |
482 field.autocomplete_attribute = ASCIIToUTF16("section-foo family-name"); | |
483 form.fields.push_back(field); | |
484 | |
485 // "shipping" and "billing" are special section tokens that don't require the | |
486 // "section-" prefix. | |
487 field.label = string16(); | |
487 field.name = ASCIIToUTF16("field3"); | 488 field.name = ASCIIToUTF16("field3"); |
488 field.autocomplete_type = ASCIIToUTF16("section-foo address-line1"); | 489 field.autocomplete_attribute = ASCIIToUTF16("shipping address-line1"); |
490 form.fields.push_back(field); | |
491 | |
492 // "shipping" and "billing" can be combined with other section names. | |
493 field.label = string16(); | |
494 field.name = ASCIIToUTF16("field4"); | |
495 field.autocomplete_attribute = | |
496 ASCIIToUTF16("section-foo billing address-line2"); | |
489 form.fields.push_back(field); | 497 form.fields.push_back(field); |
490 | 498 |
491 // Specifying "section-" is equivalent to not specifying a section. | 499 // Specifying "section-" is equivalent to not specifying a section. |
492 field.label = string16(); | 500 field.label = string16(); |
493 field.name = ASCIIToUTF16("field4"); | 501 field.name = ASCIIToUTF16("field5"); |
494 field.autocomplete_type = ASCIIToUTF16("section- address-line2"); | 502 field.autocomplete_attribute = ASCIIToUTF16("section- locality"); |
495 form.fields.push_back(field); | 503 form.fields.push_back(field); |
496 | 504 |
497 // We don't do anything clever to try to coalesce sections; it's up to site | 505 // We don't do anything clever to try to coalesce sections; it's up to site |
498 // authors to avoid typos. | 506 // authors to avoid typos. |
499 field.label = string16(); | 507 field.label = string16(); |
500 field.name = ASCIIToUTF16("field5"); | 508 field.name = ASCIIToUTF16("field6"); |
501 field.autocomplete_type = ASCIIToUTF16("section--shipping locality"); | 509 field.autocomplete_attribute = ASCIIToUTF16("section--foo region"); |
502 form.fields.push_back(field); | 510 form.fields.push_back(field); |
503 | 511 |
504 // Credit card fields are implicitly in a separate section from other fields. | 512 // Credit card fields are implicitly in a separate section from other fields. |
505 field.label = string16(); | 513 field.label = string16(); |
506 field.name = ASCIIToUTF16("field6"); | 514 field.name = ASCIIToUTF16("field7"); |
507 field.autocomplete_type = ASCIIToUTF16("section-shipping cc-number"); | 515 field.autocomplete_attribute = ASCIIToUTF16("section-foo cc-number"); |
508 form.fields.push_back(field); | 516 form.fields.push_back(field); |
509 | 517 |
510 form_structure.reset(new FormStructure(form)); | 518 form_structure.reset(new FormStructure(form)); |
511 form_structure->DetermineHeuristicTypes(); | |
512 EXPECT_TRUE(form_structure->IsAutofillable(true)); | |
513 | |
514 // Expect the correct number of fields. | |
515 ASSERT_EQ(6U, form_structure->field_count()); | |
516 ASSERT_EQ(6U, form_structure->autofill_count()); | |
517 | |
518 EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type()); | |
519 EXPECT_EQ(ASCIIToUTF16("shipping-default"), | |
520 form_structure->field(0)->section()); | |
521 EXPECT_EQ(NAME_LAST, form_structure->field(1)->heuristic_type()); | |
522 EXPECT_EQ(ASCIIToUTF16("-default"), form_structure->field(1)->section()); | |
523 EXPECT_EQ(ADDRESS_HOME_LINE1, form_structure->field(2)->heuristic_type()); | |
524 EXPECT_EQ(ASCIIToUTF16("foo-default"), form_structure->field(2)->section()); | |
525 EXPECT_EQ(ADDRESS_HOME_LINE2, form_structure->field(3)->heuristic_type()); | |
526 EXPECT_EQ(ASCIIToUTF16("-default"), form_structure->field(3)->section()); | |
527 EXPECT_EQ(ADDRESS_HOME_CITY, form_structure->field(4)->heuristic_type()); | |
528 EXPECT_EQ(ASCIIToUTF16("-shipping-default"), | |
529 form_structure->field(4)->section()); | |
530 EXPECT_EQ(CREDIT_CARD_NUMBER, form_structure->field(5)->heuristic_type()); | |
531 EXPECT_EQ(ASCIIToUTF16("shipping-cc"), form_structure->field(5)->section()); | |
532 } | |
533 | |
534 // Verify that we can correctly process fallback types listed in the | |
535 // |autocompletetype| attribute. | |
536 TEST(FormStructureTest, HeuristicsAutocompletetypeWithFallbacks) { | |
537 scoped_ptr<FormStructure> form_structure; | |
538 FormData form; | |
539 form.method = ASCIIToUTF16("post"); | |
540 | |
541 FormFieldData field; | |
542 field.form_control_type = ASCIIToUTF16("text"); | |
543 | |
544 // Skip over any sections and "x"-prefixed types. | |
545 field.label = string16(); | |
546 field.name = ASCIIToUTF16("field1"); | |
547 field.autocomplete_type = | |
548 ASCIIToUTF16("section-full-name x-given-name-initial given-name"); | |
549 form.fields.push_back(field); | |
550 | |
551 // Stop processing once we see a known type. | |
552 field.label = string16(); | |
553 field.name = ASCIIToUTF16("field2"); | |
554 field.autocomplete_type = ASCIIToUTF16("section-full-name surname full-name"); | |
555 form.fields.push_back(field); | |
556 | |
557 // Skip over unknown types even if they are not prefixed with "x-". | |
558 field.label = string16(); | |
559 field.name = ASCIIToUTF16("field3"); | |
560 field.autocomplete_type = | |
561 ASCIIToUTF16("section-shipping mobile-phone-full phone-full"); | |
562 form.fields.push_back(field); | |
563 | |
564 form_structure.reset(new FormStructure(form)); | |
565 form_structure->DetermineHeuristicTypes(); | 519 form_structure->DetermineHeuristicTypes(); |
Dan Beam
2012/10/19 00:12:44
nit: I think it'd be easier to read these tests if
Ilya Sherman
2012/10/19 04:19:32
It turns out that you can't do that, as Autofill w
| |
566 EXPECT_TRUE(form_structure->IsAutofillable(true)); | 520 EXPECT_TRUE(form_structure->IsAutofillable(true)); |
567 | 521 |
568 // Expect the correct number of fields. | 522 // Expect the correct number of fields. |
569 ASSERT_EQ(3U, form_structure->field_count()); | 523 ASSERT_EQ(7U, form_structure->field_count()); |
570 ASSERT_EQ(3U, form_structure->autofill_count()); | 524 EXPECT_EQ(7U, form_structure->autofill_count()); |
571 | 525 |
572 EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type()); | 526 EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type()); |
573 EXPECT_EQ(ASCIIToUTF16("full-name-default"), | 527 EXPECT_EQ(ASCIIToUTF16("-default-default"), |
574 form_structure->field(0)->section()); | 528 form_structure->field(0)->section()); |
575 EXPECT_EQ(NAME_LAST, form_structure->field(1)->heuristic_type()); | 529 EXPECT_EQ(NAME_LAST, form_structure->field(1)->heuristic_type()); |
576 EXPECT_EQ(ASCIIToUTF16("full-name-default"), | 530 EXPECT_EQ(ASCIIToUTF16("foo-default-default"), |
577 form_structure->field(1)->section()); | 531 form_structure->field(1)->section()); |
578 EXPECT_EQ(PHONE_HOME_WHOLE_NUMBER, | 532 EXPECT_EQ(ADDRESS_HOME_LINE1, form_structure->field(2)->heuristic_type()); |
579 form_structure->field(2)->heuristic_type()); | 533 EXPECT_EQ(ASCIIToUTF16("-shipping-default"), |
580 EXPECT_EQ(ASCIIToUTF16("shipping-default"), | |
581 form_structure->field(2)->section()); | 534 form_structure->field(2)->section()); |
535 EXPECT_EQ(ADDRESS_HOME_LINE2, form_structure->field(3)->heuristic_type()); | |
536 EXPECT_EQ(ASCIIToUTF16("foo-billing-default"), | |
537 form_structure->field(3)->section()); | |
538 EXPECT_EQ(ADDRESS_HOME_CITY, form_structure->field(4)->heuristic_type()); | |
539 EXPECT_EQ(ASCIIToUTF16("-default-default"), | |
540 form_structure->field(4)->section()); | |
541 EXPECT_EQ(ADDRESS_HOME_STATE, form_structure->field(5)->heuristic_type()); | |
542 EXPECT_EQ(ASCIIToUTF16("-foo-default-default"), | |
543 form_structure->field(5)->section()); | |
544 EXPECT_EQ(CREDIT_CARD_NUMBER, form_structure->field(6)->heuristic_type()); | |
545 EXPECT_EQ(ASCIIToUTF16("foo-default-cc"), | |
546 form_structure->field(6)->section()); | |
582 } | 547 } |
583 | 548 |
584 TEST(FormStructureTest, HeuristicsSample8) { | 549 TEST(FormStructureTest, HeuristicsSample8) { |
585 scoped_ptr<FormStructure> form_structure; | 550 scoped_ptr<FormStructure> form_structure; |
586 FormData form; | 551 FormData form; |
587 form.method = ASCIIToUTF16("post"); | 552 form.method = ASCIIToUTF16("post"); |
588 | 553 |
589 FormFieldData field; | 554 FormFieldData field; |
590 field.form_control_type = ASCIIToUTF16("text"); | 555 field.form_control_type = ASCIIToUTF16("text"); |
591 | 556 |
(...skipping 1391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1983 EXPECT_EQ(FormStructureTest::Hash64Bit( | 1948 EXPECT_EQ(FormStructureTest::Hash64Bit( |
1984 std::string("https://login.facebook.com&&email&first")), | 1949 std::string("https://login.facebook.com&&email&first")), |
1985 form_structure->FormSignature()); | 1950 form_structure->FormSignature()); |
1986 | 1951 |
1987 form.name = ASCIIToUTF16("login_form"); | 1952 form.name = ASCIIToUTF16("login_form"); |
1988 form_structure.reset(new FormStructure(form)); | 1953 form_structure.reset(new FormStructure(form)); |
1989 EXPECT_EQ(FormStructureTest::Hash64Bit( | 1954 EXPECT_EQ(FormStructureTest::Hash64Bit( |
1990 std::string("https://login.facebook.com&login_form&email&first")), | 1955 std::string("https://login.facebook.com&login_form&email&first")), |
1991 form_structure->FormSignature()); | 1956 form_structure->FormSignature()); |
1992 } | 1957 } |
OLD | NEW |