| OLD | NEW |
| 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 "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 1492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1503 checkable_field.is_checkable = true; | 1503 checkable_field.is_checkable = true; |
| 1504 checkable_field.label = ASCIIToUTF16("Checkable1"); | 1504 checkable_field.label = ASCIIToUTF16("Checkable1"); |
| 1505 checkable_field.name = ASCIIToUTF16("Checkable1"); | 1505 checkable_field.name = ASCIIToUTF16("Checkable1"); |
| 1506 form.fields.push_back(checkable_field); | 1506 form.fields.push_back(checkable_field); |
| 1507 | 1507 |
| 1508 ScopedVector<FormStructure> forms; | 1508 ScopedVector<FormStructure> forms; |
| 1509 forms.push_back(new FormStructure(form)); | 1509 forms.push_back(new FormStructure(form)); |
| 1510 std::vector<std::string> encoded_signatures; | 1510 std::vector<std::string> encoded_signatures; |
| 1511 std::string encoded_xml; | 1511 std::string encoded_xml; |
| 1512 const char kSignature1[] = "11337937696949187602"; | 1512 const char kSignature1[] = "11337937696949187602"; |
| 1513 const char kResponse1[] = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" | 1513 const char kResponse1[] = |
| 1514 "<?xml version=\"1.0\"?>\n" |
| 1514 "<autofillquery clientversion=\"6.1.1715.1442/en (GGLL)\">" | 1515 "<autofillquery clientversion=\"6.1.1715.1442/en (GGLL)\">" |
| 1515 "<form signature=\"11337937696949187602\">" | 1516 "<form signature=\"11337937696949187602\">" |
| 1516 "<field signature=\"412125936\" name=\"name_on_card\" type=\"text\"" | 1517 "<field signature=\"412125936\" name=\"name_on_card\" type=\"text\"" |
| 1517 " label=\"Name on Card\"/><field signature=\"1917667676\"" | 1518 " label=\"Name on Card\"/><field signature=\"1917667676\"" |
| 1518 " name=\"billing_address\" type=\"text\" label=\"Address\"/>" | 1519 " name=\"billing_address\" type=\"text\" label=\"Address\"/>" |
| 1519 "<field signature=\"2226358947\" name=\"card_number\" type=\"text\"" | 1520 "<field signature=\"2226358947\" name=\"card_number\" type=\"text\"" |
| 1520 " label=\"Card Number\"/><field signature=\"747221617\"" | 1521 " label=\"Card Number\"/><field signature=\"747221617\"" |
| 1521 " name=\"expiration_month\" type=\"text\" label=\"Expiration Date\"/>" | 1522 " name=\"expiration_month\" type=\"text\" label=\"Expiration Date\"/>" |
| 1522 "<field signature=\"4108155786\" name=\"expiration_year\" type=\"text\"" | 1523 "<field signature=\"4108155786\" name=\"expiration_year\" type=\"text\"" |
| 1523 " label=\"Expiration Year\"/></form></autofillquery>"; | 1524 " label=\"Expiration Year\"/></form></autofillquery>\n"; |
| 1524 ASSERT_TRUE(FormStructure::EncodeQueryRequest( | 1525 ASSERT_TRUE(FormStructure::EncodeQueryRequest( |
| 1525 forms.get(), &encoded_signatures, &encoded_xml)); | 1526 forms.get(), &encoded_signatures, &encoded_xml)); |
| 1526 ASSERT_EQ(1U, encoded_signatures.size()); | 1527 ASSERT_EQ(1U, encoded_signatures.size()); |
| 1527 EXPECT_EQ(kSignature1, encoded_signatures[0]); | 1528 EXPECT_EQ(kSignature1, encoded_signatures[0]); |
| 1528 EXPECT_EQ(kResponse1, encoded_xml); | 1529 EXPECT_EQ(kResponse1, encoded_xml); |
| 1529 | 1530 |
| 1530 // Add the same form, only one will be encoded, so EncodeQueryRequest() should | 1531 // Add the same form, only one will be encoded, so EncodeQueryRequest() should |
| 1531 // return the same data. | 1532 // return the same data. |
| 1532 forms.push_back(new FormStructure(form)); | 1533 forms.push_back(new FormStructure(form)); |
| 1533 ASSERT_TRUE(FormStructure::EncodeQueryRequest( | 1534 ASSERT_TRUE(FormStructure::EncodeQueryRequest( |
| 1534 forms.get(), &encoded_signatures, &encoded_xml)); | 1535 forms.get(), &encoded_signatures, &encoded_xml)); |
| 1535 ASSERT_EQ(1U, encoded_signatures.size()); | 1536 ASSERT_EQ(1U, encoded_signatures.size()); |
| 1536 EXPECT_EQ(kSignature1, encoded_signatures[0]); | 1537 EXPECT_EQ(kSignature1, encoded_signatures[0]); |
| 1537 EXPECT_EQ(kResponse1, encoded_xml); | 1538 EXPECT_EQ(kResponse1, encoded_xml); |
| 1538 // Add 5 address fields - this should be still a valid form. | 1539 // Add 5 address fields - this should be still a valid form. |
| 1539 for (size_t i = 0; i < 5; ++i) { | 1540 for (size_t i = 0; i < 5; ++i) { |
| 1540 field.label = ASCIIToUTF16("Address"); | 1541 field.label = ASCIIToUTF16("Address"); |
| 1541 field.name = ASCIIToUTF16("address"); | 1542 field.name = ASCIIToUTF16("address"); |
| 1542 form.fields.push_back(field); | 1543 form.fields.push_back(field); |
| 1543 } | 1544 } |
| 1544 | 1545 |
| 1545 forms.push_back(new FormStructure(form)); | 1546 forms.push_back(new FormStructure(form)); |
| 1546 ASSERT_TRUE(FormStructure::EncodeQueryRequest( | 1547 ASSERT_TRUE(FormStructure::EncodeQueryRequest( |
| 1547 forms.get(), &encoded_signatures, &encoded_xml)); | 1548 forms.get(), &encoded_signatures, &encoded_xml)); |
| 1548 ASSERT_EQ(2U, encoded_signatures.size()); | 1549 ASSERT_EQ(2U, encoded_signatures.size()); |
| 1549 EXPECT_EQ(kSignature1, encoded_signatures[0]); | 1550 EXPECT_EQ(kSignature1, encoded_signatures[0]); |
| 1550 const char kSignature2[] = "8308881815906226214"; | 1551 const char kSignature2[] = "8308881815906226214"; |
| 1551 EXPECT_EQ(kSignature2, encoded_signatures[1]); | 1552 EXPECT_EQ(kSignature2, encoded_signatures[1]); |
| 1552 const char kResponse2[] = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" | 1553 const char kResponse2[] = |
| 1553 "<autofillquery clientversion=\"6.1.1715.1442/en (GGLL)\">" | 1554 "<?xml version=\"1.0\"?>\n" |
| 1554 "<form signature=\"11337937696949187602\"><field signature=\"412125936\"" | 1555 "<autofillquery clientversion=\"6.1.1715.1442/en (GGLL)\">" |
| 1555 " name=\"name_on_card\" type=\"text\" label=\"Name on Card\"/>" | 1556 "<form signature=\"11337937696949187602\"><field signature=\"412125936\"" |
| 1556 "<field signature=\"1917667676\" name=\"billing_address\" type=\"text\"" | 1557 " name=\"name_on_card\" type=\"text\" label=\"Name on Card\"/>" |
| 1557 " label=\"Address\"/><field signature=\"2226358947\" name=\"card_number\"" | 1558 "<field signature=\"1917667676\" name=\"billing_address\" type=\"text\"" |
| 1558 " type=\"text\" label=\"Card Number\"/>" | 1559 " label=\"Address\"/><field signature=\"2226358947\" name=\"card_number\"" |
| 1559 "<field signature=\"747221617\" name=\"expiration_month\" type=\"text\"" | 1560 " type=\"text\" label=\"Card Number\"/>" |
| 1560 " label=\"Expiration Date\"/>" | 1561 "<field signature=\"747221617\" name=\"expiration_month\" type=\"text\"" |
| 1561 "<field signature=\"4108155786\" name=\"expiration_year\" type=\"text\"" | 1562 " label=\"Expiration Date\"/>" |
| 1562 " label=\"Expiration Year\"/></form>" | 1563 "<field signature=\"4108155786\" name=\"expiration_year\" type=\"text\"" |
| 1563 "<form signature=\"8308881815906226214\">" | 1564 " label=\"Expiration Year\"/></form>" |
| 1564 "<field signature=\"412125936\" name=\"name_on_card\" type=\"text\"" | 1565 "<form signature=\"8308881815906226214\">" |
| 1565 " label=\"Name on Card\"/><field signature=\"1917667676\"" | 1566 "<field signature=\"412125936\" name=\"name_on_card\" type=\"text\"" |
| 1566 " name=\"billing_address\" type=\"text\" label=\"Address\"/>" | 1567 " label=\"Name on Card\"/><field signature=\"1917667676\"" |
| 1567 "<field signature=\"2226358947\" name=\"card_number\" type=\"text\"" | 1568 " name=\"billing_address\" type=\"text\" label=\"Address\"/>" |
| 1568 " label=\"Card Number\"/><field signature=\"747221617\"" | 1569 "<field signature=\"2226358947\" name=\"card_number\" type=\"text\"" |
| 1569 " name=\"expiration_month\" type=\"text\" label=\"Expiration Date\"/>" | 1570 " label=\"Card Number\"/><field signature=\"747221617\"" |
| 1570 "<field signature=\"4108155786\" name=\"expiration_year\" type=\"text\"" | 1571 " name=\"expiration_month\" type=\"text\" label=\"Expiration Date\"/>" |
| 1571 " label=\"Expiration Year\"/><field signature=\"509334676\" name=\"address\"" | 1572 "<field signature=\"4108155786\" name=\"expiration_year\" type=\"text\"" |
| 1572 " type=\"text\" label=\"Address\"/><field signature=\"509334676\"" | 1573 " label=\"Expiration Year\"/><field signature=\"509334676\" " |
| 1573 " name=\"address\" type=\"text\" label=\"Address\"/>" | 1574 "name=\"address\"" |
| 1574 "<field signature=\"509334676\" name=\"address\" type=\"text\"" | 1575 " type=\"text\" label=\"Address\"/><field signature=\"509334676\"" |
| 1575 " label=\"Address\"/><field signature=\"509334676\" name=\"address\"" | 1576 " name=\"address\" type=\"text\" label=\"Address\"/>" |
| 1576 " type=\"text\" label=\"Address\"/><field signature=\"509334676\"" | 1577 "<field signature=\"509334676\" name=\"address\" type=\"text\"" |
| 1577 " name=\"address\" type=\"text\" label=\"Address\"/></form></autofillquery>"; | 1578 " label=\"Address\"/><field signature=\"509334676\" name=\"address\"" |
| 1579 " type=\"text\" label=\"Address\"/><field signature=\"509334676\"" |
| 1580 " name=\"address\" type=\"text\" " |
| 1581 "label=\"Address\"/></form></autofillquery>\n"; |
| 1578 EXPECT_EQ(kResponse2, encoded_xml); | 1582 EXPECT_EQ(kResponse2, encoded_xml); |
| 1579 | 1583 |
| 1580 FormData malformed_form(form); | 1584 FormData malformed_form(form); |
| 1581 // Add 50 address fields - the form is not valid anymore, but previous ones | 1585 // Add 50 address fields - the form is not valid anymore, but previous ones |
| 1582 // are. The result should be the same as in previous test. | 1586 // are. The result should be the same as in previous test. |
| 1583 for (size_t i = 0; i < 50; ++i) { | 1587 for (size_t i = 0; i < 50; ++i) { |
| 1584 field.label = ASCIIToUTF16("Address"); | 1588 field.label = ASCIIToUTF16("Address"); |
| 1585 field.name = ASCIIToUTF16("address"); | 1589 field.name = ASCIIToUTF16("address"); |
| 1586 malformed_form.fields.push_back(field); | 1590 malformed_form.fields.push_back(field); |
| 1587 } | 1591 } |
| 1588 | 1592 |
| 1589 forms.push_back(new FormStructure(malformed_form)); | 1593 forms.push_back(new FormStructure(malformed_form)); |
| 1590 ASSERT_TRUE(FormStructure::EncodeQueryRequest( | 1594 ASSERT_TRUE(FormStructure::EncodeQueryRequest( |
| 1591 forms.get(), &encoded_signatures, &encoded_xml)); | 1595 forms.get(), &encoded_signatures, &encoded_xml)); |
| 1592 ASSERT_EQ(2U, encoded_signatures.size()); | 1596 ASSERT_EQ(2U, encoded_signatures.size()); |
| 1593 EXPECT_EQ(kSignature1, encoded_signatures[0]); | 1597 EXPECT_EQ(kSignature1, encoded_signatures[0]); |
| 1594 EXPECT_EQ(kSignature2, encoded_signatures[1]); | 1598 EXPECT_EQ(kSignature2, encoded_signatures[1]); |
| 1595 EXPECT_EQ(kResponse2, encoded_xml); | 1599 EXPECT_EQ(kResponse2, encoded_xml); |
| 1596 | 1600 |
| 1597 // Check that we fail if there are only bad form(s). | 1601 // Check that we fail if there are only bad form(s). |
| 1598 ScopedVector<FormStructure> bad_forms; | 1602 ScopedVector<FormStructure> bad_forms; |
| 1599 bad_forms.push_back(new FormStructure(malformed_form)); | 1603 bad_forms.push_back(new FormStructure(malformed_form)); |
| 1600 EXPECT_FALSE(FormStructure::EncodeQueryRequest( | 1604 EXPECT_FALSE(FormStructure::EncodeQueryRequest( |
| 1601 bad_forms.get(), &encoded_signatures, &encoded_xml)); | 1605 bad_forms.get(), &encoded_signatures, &encoded_xml)); |
| 1602 EXPECT_EQ(0U, encoded_signatures.size()); | |
| 1603 EXPECT_EQ("", encoded_xml); | |
| 1604 } | 1606 } |
| 1605 | 1607 |
| 1606 TEST_F(FormStructureTest, EncodeUploadRequest) { | 1608 TEST_F(FormStructureTest, EncodeUploadRequest) { |
| 1607 scoped_ptr<FormStructure> form_structure; | 1609 scoped_ptr<FormStructure> form_structure; |
| 1608 std::vector<ServerFieldTypeSet> possible_field_types; | 1610 std::vector<ServerFieldTypeSet> possible_field_types; |
| 1609 FormData form; | 1611 FormData form; |
| 1610 form_structure.reset(new FormStructure(form)); | 1612 form_structure.reset(new FormStructure(form)); |
| 1611 form_structure->DetermineHeuristicTypes(); | 1613 form_structure->DetermineHeuristicTypes(); |
| 1612 | 1614 |
| 1613 FormFieldData field; | 1615 FormFieldData field; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1668 available_field_types.insert(ADDRESS_HOME_LINE2); | 1670 available_field_types.insert(ADDRESS_HOME_LINE2); |
| 1669 available_field_types.insert(ADDRESS_HOME_COUNTRY); | 1671 available_field_types.insert(ADDRESS_HOME_COUNTRY); |
| 1670 available_field_types.insert(ADDRESS_BILLING_LINE1); | 1672 available_field_types.insert(ADDRESS_BILLING_LINE1); |
| 1671 available_field_types.insert(ADDRESS_BILLING_LINE2); | 1673 available_field_types.insert(ADDRESS_BILLING_LINE2); |
| 1672 available_field_types.insert(EMAIL_ADDRESS); | 1674 available_field_types.insert(EMAIL_ADDRESS); |
| 1673 available_field_types.insert(PHONE_HOME_WHOLE_NUMBER); | 1675 available_field_types.insert(PHONE_HOME_WHOLE_NUMBER); |
| 1674 | 1676 |
| 1675 std::string encoded_xml; | 1677 std::string encoded_xml; |
| 1676 EXPECT_TRUE(form_structure->EncodeUploadRequest(available_field_types, false, | 1678 EXPECT_TRUE(form_structure->EncodeUploadRequest(available_field_types, false, |
| 1677 std::string(), &encoded_xml)); | 1679 std::string(), &encoded_xml)); |
| 1678 EXPECT_EQ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" | 1680 EXPECT_EQ( |
| 1679 "<autofillupload clientversion=\"6.1.1715.1442/en (GGLL)\"" | 1681 "<?xml version=\"1.0\"?>\n" |
| 1680 " formsignature=\"8736493185895608956\" autofillused=\"false\"" | 1682 "<autofillupload clientversion=\"6.1.1715.1442/en (GGLL)\"" |
| 1681 " datapresent=\"144200030e\"" | 1683 " formsignature=\"8736493185895608956\" autofillused=\"false\"" |
| 1682 " actionsignature=\"15724779818122431245\">" | 1684 " datapresent=\"144200030e\"" |
| 1683 "<field signature=\"3763331450\" name=\"firstname\" type=\"text\"" | 1685 " actionsignature=\"15724779818122431245\">" |
| 1684 " label=\"First Name\" autofilltype=\"3\"/>" | 1686 "<field signature=\"3763331450\" name=\"firstname\" type=\"text\"" |
| 1685 "<field signature=\"3494530716\" name=\"lastname\" type=\"text\"" | 1687 " label=\"First Name\" autofilltype=\"3\"/>" |
| 1686 " label=\"Last Name\" autofilltype=\"5\"/>" | 1688 "<field signature=\"3494530716\" name=\"lastname\" type=\"text\"" |
| 1687 "<field signature=\"1029417091\" name=\"email\" type=\"email\"" | 1689 " label=\"Last Name\" autofilltype=\"5\"/>" |
| 1688 " label=\"Email\" autofilltype=\"9\"/>" | 1690 "<field signature=\"1029417091\" name=\"email\" type=\"email\"" |
| 1689 "<field signature=\"466116101\" name=\"phone\" type=\"number\"" | 1691 " label=\"Email\" autofilltype=\"9\"/>" |
| 1690 " label=\"Phone\" autofilltype=\"14\"/>" | 1692 "<field signature=\"466116101\" name=\"phone\" type=\"number\"" |
| 1691 "<field signature=\"2799270304\" name=\"country\"" | 1693 " label=\"Phone\" autofilltype=\"14\"/>" |
| 1692 " type=\"select-one\" label=\"Country\" autofilltype=\"36\"/>" | 1694 "<field signature=\"2799270304\" name=\"country\"" |
| 1693 "</autofillupload>", | 1695 " type=\"select-one\" label=\"Country\" autofilltype=\"36\"/>" |
| 1694 encoded_xml); | 1696 "</autofillupload>\n", |
| 1697 encoded_xml); |
| 1695 EXPECT_TRUE(form_structure->EncodeUploadRequest(available_field_types, true, | 1698 EXPECT_TRUE(form_structure->EncodeUploadRequest(available_field_types, true, |
| 1696 std::string(), &encoded_xml)); | 1699 std::string(), &encoded_xml)); |
| 1697 EXPECT_EQ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" | 1700 EXPECT_EQ( |
| 1698 "<autofillupload clientversion=\"6.1.1715.1442/en (GGLL)\"" | 1701 "<?xml version=\"1.0\"?>\n" |
| 1699 " formsignature=\"8736493185895608956\"" | 1702 "<autofillupload clientversion=\"6.1.1715.1442/en (GGLL)\"" |
| 1700 " autofillused=\"true\" datapresent=\"144200030e\"" | 1703 " formsignature=\"8736493185895608956\"" |
| 1701 " actionsignature=\"15724779818122431245\">" | 1704 " autofillused=\"true\" datapresent=\"144200030e\"" |
| 1702 "<field signature=\"3763331450\" name=\"firstname\" type=\"text\"" | 1705 " actionsignature=\"15724779818122431245\">" |
| 1703 " label=\"First Name\" autofilltype=\"3\"/>" | 1706 "<field signature=\"3763331450\" name=\"firstname\" type=\"text\"" |
| 1704 "<field signature=\"3494530716\" name=\"lastname\" type=\"text\"" | 1707 " label=\"First Name\" autofilltype=\"3\"/>" |
| 1705 " label=\"Last Name\" autofilltype=\"5\"/>" | 1708 "<field signature=\"3494530716\" name=\"lastname\" type=\"text\"" |
| 1706 "<field signature=\"1029417091\" name=\"email\" type=\"email\"" | 1709 " label=\"Last Name\" autofilltype=\"5\"/>" |
| 1707 " label=\"Email\" autofilltype=\"9\"/>" | 1710 "<field signature=\"1029417091\" name=\"email\" type=\"email\"" |
| 1708 "<field signature=\"466116101\" name=\"phone\" type=\"number\"" | 1711 " label=\"Email\" autofilltype=\"9\"/>" |
| 1709 " label=\"Phone\" autofilltype=\"14\"/>" | 1712 "<field signature=\"466116101\" name=\"phone\" type=\"number\"" |
| 1710 "<field signature=\"2799270304\" name=\"country\"" | 1713 " label=\"Phone\" autofilltype=\"14\"/>" |
| 1711 " type=\"select-one\" label=\"Country\" autofilltype=\"36\"/>" | 1714 "<field signature=\"2799270304\" name=\"country\"" |
| 1712 "</autofillupload>", | 1715 " type=\"select-one\" label=\"Country\" autofilltype=\"36\"/>" |
| 1713 encoded_xml); | 1716 "</autofillupload>\n", |
| 1717 encoded_xml); |
| 1714 | 1718 |
| 1715 // Add 2 address fields - this should be still a valid form. | 1719 // Add 2 address fields - this should be still a valid form. |
| 1716 for (size_t i = 0; i < 2; ++i) { | 1720 for (size_t i = 0; i < 2; ++i) { |
| 1717 field.label = ASCIIToUTF16("Address"); | 1721 field.label = ASCIIToUTF16("Address"); |
| 1718 field.name = ASCIIToUTF16("address"); | 1722 field.name = ASCIIToUTF16("address"); |
| 1719 field.form_control_type = "text"; | 1723 field.form_control_type = "text"; |
| 1720 form.fields.push_back(field); | 1724 form.fields.push_back(field); |
| 1721 possible_field_types.push_back(ServerFieldTypeSet()); | 1725 possible_field_types.push_back(ServerFieldTypeSet()); |
| 1722 possible_field_types.back().insert(ADDRESS_HOME_LINE1); | 1726 possible_field_types.back().insert(ADDRESS_HOME_LINE1); |
| 1723 possible_field_types.back().insert(ADDRESS_HOME_LINE2); | 1727 possible_field_types.back().insert(ADDRESS_HOME_LINE2); |
| 1724 possible_field_types.back().insert(ADDRESS_BILLING_LINE1); | 1728 possible_field_types.back().insert(ADDRESS_BILLING_LINE1); |
| 1725 possible_field_types.back().insert(ADDRESS_BILLING_LINE2); | 1729 possible_field_types.back().insert(ADDRESS_BILLING_LINE2); |
| 1726 } | 1730 } |
| 1727 | 1731 |
| 1728 form_structure.reset(new FormStructure(form)); | 1732 form_structure.reset(new FormStructure(form)); |
| 1729 ASSERT_EQ(form_structure->field_count(), possible_field_types.size()); | 1733 ASSERT_EQ(form_structure->field_count(), possible_field_types.size()); |
| 1730 for (size_t i = 0; i < form_structure->field_count(); ++i) | 1734 for (size_t i = 0; i < form_structure->field_count(); ++i) |
| 1731 form_structure->field(i)->set_possible_types(possible_field_types[i]); | 1735 form_structure->field(i)->set_possible_types(possible_field_types[i]); |
| 1732 | 1736 |
| 1733 EXPECT_TRUE(form_structure->EncodeUploadRequest(available_field_types, false, | 1737 EXPECT_TRUE(form_structure->EncodeUploadRequest(available_field_types, false, |
| 1734 std::string(), &encoded_xml)); | 1738 std::string(), &encoded_xml)); |
| 1735 EXPECT_EQ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" | 1739 EXPECT_EQ( |
| 1736 "<autofillupload clientversion=\"6.1.1715.1442/en (GGLL)\"" | 1740 "<?xml version=\"1.0\"?>\n" |
| 1737 " formsignature=\"7816485729218079147\" autofillused=\"false\"" | 1741 "<autofillupload clientversion=\"6.1.1715.1442/en (GGLL)\"" |
| 1738 " datapresent=\"144200030e\"" | 1742 " formsignature=\"7816485729218079147\" autofillused=\"false\"" |
| 1739 " actionsignature=\"15724779818122431245\">" | 1743 " datapresent=\"144200030e\"" |
| 1740 "<field signature=\"3763331450\" name=\"firstname\" type=\"text\"" | 1744 " actionsignature=\"15724779818122431245\">" |
| 1741 " label=\"First Name\" autofilltype=\"3\"/>" | 1745 "<field signature=\"3763331450\" name=\"firstname\" type=\"text\"" |
| 1742 "<field signature=\"3494530716\" name=\"lastname\" type=\"text\"" | 1746 " label=\"First Name\" autofilltype=\"3\"/>" |
| 1743 " label=\"Last Name\" autofilltype=\"5\"/>" | 1747 "<field signature=\"3494530716\" name=\"lastname\" type=\"text\"" |
| 1744 "<field signature=\"1029417091\" name=\"email\" type=\"email\"" | 1748 " label=\"Last Name\" autofilltype=\"5\"/>" |
| 1745 " label=\"Email\" autofilltype=\"9\"/>" | 1749 "<field signature=\"1029417091\" name=\"email\" type=\"email\"" |
| 1746 "<field signature=\"466116101\" name=\"phone\" type=\"number\"" | 1750 " label=\"Email\" autofilltype=\"9\"/>" |
| 1747 " label=\"Phone\" autofilltype=\"14\"/>" | 1751 "<field signature=\"466116101\" name=\"phone\" type=\"number\"" |
| 1748 "<field signature=\"2799270304\" name=\"country\"" | 1752 " label=\"Phone\" autofilltype=\"14\"/>" |
| 1749 " type=\"select-one\" label=\"Country\" autofilltype=\"36\"/>" | 1753 "<field signature=\"2799270304\" name=\"country\"" |
| 1750 "<field signature=\"509334676\" name=\"address\" type=\"text\"" | 1754 " type=\"select-one\" label=\"Country\" autofilltype=\"36\"/>" |
| 1751 " label=\"Address\" autofilltype=\"30\"/>" | 1755 "<field signature=\"509334676\" name=\"address\" type=\"text\"" |
| 1752 "<field signature=\"509334676\" name=\"address\" type=\"text\"" | 1756 " label=\"Address\" autofilltype=\"30\"/>" |
| 1753 " label=\"Address\" autofilltype=\"31\"/>" | 1757 "<field signature=\"509334676\" name=\"address\" type=\"text\"" |
| 1754 "<field signature=\"509334676\" name=\"address\" type=\"text\"" | 1758 " label=\"Address\" autofilltype=\"31\"/>" |
| 1755 " label=\"Address\" autofilltype=\"37\"/>" | 1759 "<field signature=\"509334676\" name=\"address\" type=\"text\"" |
| 1756 "<field signature=\"509334676\" name=\"address\" type=\"text\"" | 1760 " label=\"Address\" autofilltype=\"37\"/>" |
| 1757 " label=\"Address\" autofilltype=\"38\"/>" | 1761 "<field signature=\"509334676\" name=\"address\" type=\"text\"" |
| 1758 "<field signature=\"509334676\" name=\"address\" type=\"text\"" | 1762 " label=\"Address\" autofilltype=\"38\"/>" |
| 1759 " label=\"Address\" autofilltype=\"30\"/>" | 1763 "<field signature=\"509334676\" name=\"address\" type=\"text\"" |
| 1760 "<field signature=\"509334676\" name=\"address\" type=\"text\"" | 1764 " label=\"Address\" autofilltype=\"30\"/>" |
| 1761 " label=\"Address\" autofilltype=\"31\"/>" | 1765 "<field signature=\"509334676\" name=\"address\" type=\"text\"" |
| 1762 "<field signature=\"509334676\" name=\"address\" type=\"text\"" | 1766 " label=\"Address\" autofilltype=\"31\"/>" |
| 1763 " label=\"Address\" autofilltype=\"37\"/>" | 1767 "<field signature=\"509334676\" name=\"address\" type=\"text\"" |
| 1764 "<field signature=\"509334676\" name=\"address\" type=\"text\"" | 1768 " label=\"Address\" autofilltype=\"37\"/>" |
| 1765 " label=\"Address\" autofilltype=\"38\"/></autofillupload>", | 1769 "<field signature=\"509334676\" name=\"address\" type=\"text\"" |
| 1766 encoded_xml); | 1770 " label=\"Address\" autofilltype=\"38\"/></autofillupload>\n", |
| 1771 encoded_xml); |
| 1767 | 1772 |
| 1768 // Add 50 address fields - now the form is invalid, as it has too many fields. | 1773 // Add 50 address fields - now the form is invalid, as it has too many fields. |
| 1769 for (size_t i = 0; i < 50; ++i) { | 1774 for (size_t i = 0; i < 50; ++i) { |
| 1770 field.label = ASCIIToUTF16("Address"); | 1775 field.label = ASCIIToUTF16("Address"); |
| 1771 field.name = ASCIIToUTF16("address"); | 1776 field.name = ASCIIToUTF16("address"); |
| 1772 field.form_control_type = "text"; | 1777 field.form_control_type = "text"; |
| 1773 form.fields.push_back(field); | 1778 form.fields.push_back(field); |
| 1774 possible_field_types.push_back(ServerFieldTypeSet()); | 1779 possible_field_types.push_back(ServerFieldTypeSet()); |
| 1775 possible_field_types.back().insert(ADDRESS_HOME_LINE1); | 1780 possible_field_types.back().insert(ADDRESS_HOME_LINE1); |
| 1776 possible_field_types.back().insert(ADDRESS_HOME_LINE2); | 1781 possible_field_types.back().insert(ADDRESS_HOME_LINE2); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1840 available_field_types.insert(NAME_FIRST); | 1845 available_field_types.insert(NAME_FIRST); |
| 1841 available_field_types.insert(NAME_LAST); | 1846 available_field_types.insert(NAME_LAST); |
| 1842 available_field_types.insert(EMAIL_ADDRESS); | 1847 available_field_types.insert(EMAIL_ADDRESS); |
| 1843 available_field_types.insert(USERNAME); | 1848 available_field_types.insert(USERNAME); |
| 1844 available_field_types.insert(ACCOUNT_CREATION_PASSWORD); | 1849 available_field_types.insert(ACCOUNT_CREATION_PASSWORD); |
| 1845 | 1850 |
| 1846 std::string encoded_xml; | 1851 std::string encoded_xml; |
| 1847 EXPECT_TRUE(form_structure->EncodeUploadRequest(available_field_types, true, | 1852 EXPECT_TRUE(form_structure->EncodeUploadRequest(available_field_types, true, |
| 1848 "42", &encoded_xml)); | 1853 "42", &encoded_xml)); |
| 1849 EXPECT_EQ( | 1854 EXPECT_EQ( |
| 1850 "<?xml version=\"1.0\" encoding=\"UTF-8\"?><autofillupload " | 1855 "<?xml version=\"1.0\"?>\n<autofillupload " |
| 1851 "clientversion=\"6.1.1715.1442/en (GGLL)\" " | 1856 "clientversion=\"6.1.1715.1442/en (GGLL)\" " |
| 1852 "formsignature=\"5810032074788446513\" autofillused=\"true\" " | 1857 "formsignature=\"5810032074788446513\" autofillused=\"true\" " |
| 1853 "datapresent=\"1440000000000000000802\" " | 1858 "datapresent=\"1440000000000000000802\" " |
| 1854 "actionsignature=\"15724779818122431245\" " | 1859 "actionsignature=\"15724779818122431245\" " |
| 1855 "loginformsignature=\"42\"><field signature=\"4224610201\" " | 1860 "loginformsignature=\"42\"><field signature=\"4224610201\" " |
| 1856 "name=\"firstname\" type=\"\" label=\"First Name\" " | 1861 "name=\"firstname\" type=\"\" label=\"First Name\" " |
| 1857 "autocomplete=\"given-name\" autofilltype=\"3\"/><field " | 1862 "autocomplete=\"given-name\" autofilltype=\"3\"/><field " |
| 1858 "signature=\"2786066110\" name=\"lastname\" type=\"\" label=\"Last " | 1863 "signature=\"2786066110\" name=\"lastname\" type=\"\" label=\"Last " |
| 1859 "Name\" autocomplete=\"family-name\" autofilltype=\"5\"/><field " | 1864 "Name\" autocomplete=\"family-name\" autofilltype=\"5\"/><field " |
| 1860 "signature=\"1029417091\" name=\"email\" type=\"email\" label=\"Email\" " | 1865 "signature=\"1029417091\" name=\"email\" type=\"email\" label=\"Email\" " |
| 1861 "autocomplete=\"email\" autofilltype=\"9\"/><field " | 1866 "autocomplete=\"email\" autofilltype=\"9\"/><field " |
| 1862 "signature=\"239111655\" name=\"username\" type=\"text\" " | 1867 "signature=\"239111655\" name=\"username\" type=\"text\" " |
| 1863 "label=\"username\" autocomplete=\"email\" autofilltype=\"86\"/><field " | 1868 "label=\"username\" autocomplete=\"email\" autofilltype=\"86\"/><field " |
| 1864 "signature=\"2051817934\" name=\"password\" type=\"password\" " | 1869 "signature=\"2051817934\" name=\"password\" type=\"password\" " |
| 1865 "label=\"password\" autocomplete=\"email\" " | 1870 "label=\"password\" autocomplete=\"email\" " |
| 1866 "autofilltype=\"76\"/></autofillupload>", | 1871 "autofilltype=\"76\"/></autofillupload>\n", |
| 1867 encoded_xml); | 1872 encoded_xml); |
| 1868 } | 1873 } |
| 1869 | 1874 |
| 1870 TEST_F(FormStructureTest, EncodeUploadRequest_WithAutocomplete) { | 1875 TEST_F(FormStructureTest, EncodeUploadRequest_WithAutocomplete) { |
| 1871 scoped_ptr<FormStructure> form_structure; | 1876 scoped_ptr<FormStructure> form_structure; |
| 1872 std::vector<ServerFieldTypeSet> possible_field_types; | 1877 std::vector<ServerFieldTypeSet> possible_field_types; |
| 1873 FormData form; | 1878 FormData form; |
| 1874 form_structure.reset(new FormStructure(form)); | 1879 form_structure.reset(new FormStructure(form)); |
| 1875 form_structure->DetermineHeuristicTypes(); | 1880 form_structure->DetermineHeuristicTypes(); |
| 1876 | 1881 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1906 form_structure->field(i)->set_possible_types(possible_field_types[i]); | 1911 form_structure->field(i)->set_possible_types(possible_field_types[i]); |
| 1907 | 1912 |
| 1908 ServerFieldTypeSet available_field_types; | 1913 ServerFieldTypeSet available_field_types; |
| 1909 available_field_types.insert(NAME_FIRST); | 1914 available_field_types.insert(NAME_FIRST); |
| 1910 available_field_types.insert(NAME_LAST); | 1915 available_field_types.insert(NAME_LAST); |
| 1911 available_field_types.insert(EMAIL_ADDRESS); | 1916 available_field_types.insert(EMAIL_ADDRESS); |
| 1912 | 1917 |
| 1913 std::string encoded_xml; | 1918 std::string encoded_xml; |
| 1914 EXPECT_TRUE(form_structure->EncodeUploadRequest(available_field_types, true, | 1919 EXPECT_TRUE(form_structure->EncodeUploadRequest(available_field_types, true, |
| 1915 std::string(), &encoded_xml)); | 1920 std::string(), &encoded_xml)); |
| 1916 EXPECT_EQ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" | 1921 EXPECT_EQ( |
| 1917 "<autofillupload clientversion=\"6.1.1715.1442/en (GGLL)\"" | 1922 "<?xml version=\"1.0\"?>\n" |
| 1918 " formsignature=\"14746822798145140279\" autofillused=\"true\"" | 1923 "<autofillupload clientversion=\"6.1.1715.1442/en (GGLL)\"" |
| 1919 " datapresent=\"1440\" actionsignature=\"15724779818122431245\">" | 1924 " formsignature=\"14746822798145140279\" autofillused=\"true\"" |
| 1920 "<field signature=\"3763331450\" name=\"firstname\" type=\"text\"" | 1925 " datapresent=\"1440\" actionsignature=\"15724779818122431245\">" |
| 1921 " label=\"First Name\" autocomplete=\"given-name\"" | 1926 "<field signature=\"3763331450\" name=\"firstname\" type=\"text\"" |
| 1922 " autofilltype=\"3\"/>" | 1927 " label=\"First Name\" autocomplete=\"given-name\"" |
| 1923 "<field signature=\"3494530716\" name=\"lastname\" type=\"text\"" | 1928 " autofilltype=\"3\"/>" |
| 1924 " label=\"Last Name\" autocomplete=\"family-name\"" | 1929 "<field signature=\"3494530716\" name=\"lastname\" type=\"text\"" |
| 1925 " autofilltype=\"5\"/><field signature=\"1029417091\"" | 1930 " label=\"Last Name\" autocomplete=\"family-name\"" |
| 1926 " name=\"email\" type=\"email\" label=\"Email\"" | 1931 " autofilltype=\"5\"/><field signature=\"1029417091\"" |
| 1927 " autocomplete=\"email\" autofilltype=\"9\"/></autofillupload>", | 1932 " name=\"email\" type=\"email\" label=\"Email\"" |
| 1928 encoded_xml); | 1933 " autocomplete=\"email\" autofilltype=\"9\"/></autofillupload>\n", |
| 1934 encoded_xml); |
| 1929 } | 1935 } |
| 1930 | 1936 |
| 1931 TEST_F(FormStructureTest, EncodeUploadRequest_WithLabels) { | 1937 TEST_F(FormStructureTest, EncodeUploadRequest_WithLabels) { |
| 1932 scoped_ptr<FormStructure> form_structure; | 1938 scoped_ptr<FormStructure> form_structure; |
| 1933 std::vector<ServerFieldTypeSet> possible_field_types; | 1939 std::vector<ServerFieldTypeSet> possible_field_types; |
| 1934 FormData form; | 1940 FormData form; |
| 1935 form_structure.reset(new FormStructure(form)); | 1941 form_structure.reset(new FormStructure(form)); |
| 1936 form_structure->DetermineHeuristicTypes(); | 1942 form_structure->DetermineHeuristicTypes(); |
| 1937 | 1943 |
| 1938 FormFieldData field; | 1944 FormFieldData field; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1961 | 1967 |
| 1962 ServerFieldTypeSet available_field_types; | 1968 ServerFieldTypeSet available_field_types; |
| 1963 available_field_types.insert(NAME_FIRST); | 1969 available_field_types.insert(NAME_FIRST); |
| 1964 available_field_types.insert(NAME_LAST); | 1970 available_field_types.insert(NAME_LAST); |
| 1965 available_field_types.insert(EMAIL_ADDRESS); | 1971 available_field_types.insert(EMAIL_ADDRESS); |
| 1966 | 1972 |
| 1967 std::string encoded_xml; | 1973 std::string encoded_xml; |
| 1968 EXPECT_TRUE(form_structure->EncodeUploadRequest(available_field_types, true, | 1974 EXPECT_TRUE(form_structure->EncodeUploadRequest(available_field_types, true, |
| 1969 std::string(), &encoded_xml)); | 1975 std::string(), &encoded_xml)); |
| 1970 // Expected that the first field does not send the label but others do. | 1976 // Expected that the first field does not send the label but others do. |
| 1971 EXPECT_EQ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" | 1977 EXPECT_EQ( |
| 1972 "<autofillupload clientversion=\"6.1.1715.1442/en (GGLL)\"" | 1978 "<?xml version=\"1.0\"?>\n" |
| 1973 " formsignature=\"6949133589768631292\" autofillused=\"true\"" | 1979 "<autofillupload clientversion=\"6.1.1715.1442/en (GGLL)\"" |
| 1974 " datapresent=\"1440\"" | 1980 " formsignature=\"6949133589768631292\" autofillused=\"true\"" |
| 1975 " actionsignature=\"15724779818122431245\">" | 1981 " datapresent=\"1440\"" |
| 1976 "<field signature=\"1318412689\" type=\"text\" autofilltype=\"3\"/>" | 1982 " actionsignature=\"15724779818122431245\">" |
| 1977 "<field signature=\"1318412689\" type=\"text\" label=\"Last Name\"" | 1983 "<field signature=\"1318412689\" type=\"text\" autofilltype=\"3\"/>" |
| 1978 " autofilltype=\"5\"/><field signature=\"1318412689\" type=\"text\"" | 1984 "<field signature=\"1318412689\" type=\"text\" label=\"Last Name\"" |
| 1979 " label=\"Email\" autofilltype=\"9\"/></autofillupload>", | 1985 " autofilltype=\"5\"/><field signature=\"1318412689\" type=\"text\"" |
| 1980 encoded_xml); | 1986 " label=\"Email\" autofilltype=\"9\"/></autofillupload>\n", |
| 1987 encoded_xml); |
| 1981 } | 1988 } |
| 1982 | 1989 |
| 1983 // Test that the form name is sent in the upload request. | 1990 // Test that the form name is sent in the upload request. |
| 1984 TEST_F(FormStructureTest, EncodeUploadRequest_WithFormName) { | 1991 TEST_F(FormStructureTest, EncodeUploadRequest_WithFormName) { |
| 1985 scoped_ptr<FormStructure> form_structure; | 1992 scoped_ptr<FormStructure> form_structure; |
| 1986 std::vector<ServerFieldTypeSet> possible_field_types; | 1993 std::vector<ServerFieldTypeSet> possible_field_types; |
| 1987 FormData form; | 1994 FormData form; |
| 1988 // Setting the form name which we expect to see in the upload. | 1995 // Setting the form name which we expect to see in the upload. |
| 1989 form.name = base::ASCIIToUTF16("myform"); | 1996 form.name = base::ASCIIToUTF16("myform"); |
| 1990 form_structure.reset(new FormStructure(form)); | 1997 form_structure.reset(new FormStructure(form)); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2012 form_structure->field(i)->set_possible_types(possible_field_types[i]); | 2019 form_structure->field(i)->set_possible_types(possible_field_types[i]); |
| 2013 | 2020 |
| 2014 ServerFieldTypeSet available_field_types; | 2021 ServerFieldTypeSet available_field_types; |
| 2015 available_field_types.insert(NAME_FIRST); | 2022 available_field_types.insert(NAME_FIRST); |
| 2016 available_field_types.insert(NAME_LAST); | 2023 available_field_types.insert(NAME_LAST); |
| 2017 available_field_types.insert(EMAIL_ADDRESS); | 2024 available_field_types.insert(EMAIL_ADDRESS); |
| 2018 | 2025 |
| 2019 std::string encoded_xml; | 2026 std::string encoded_xml; |
| 2020 EXPECT_TRUE(form_structure->EncodeUploadRequest(available_field_types, true, | 2027 EXPECT_TRUE(form_structure->EncodeUploadRequest(available_field_types, true, |
| 2021 std::string(), &encoded_xml)); | 2028 std::string(), &encoded_xml)); |
| 2022 EXPECT_EQ("<?xml version=\"1.0\" encoding=\"UTF-8\"?><autofillupload" | 2029 EXPECT_EQ( |
| 2023 " clientversion=\"6.1.1715.1442/en (GGLL)\"" | 2030 "<?xml version=\"1.0\"?>\n<autofillupload" |
| 2024 " formsignature=\"2345951786066580868\" autofillused=\"true\"" | 2031 " clientversion=\"6.1.1715.1442/en (GGLL)\"" |
| 2025 " datapresent=\"1440\" actionsignature=\"15724779818122431245\"" | 2032 " formsignature=\"2345951786066580868\" autofillused=\"true\"" |
| 2026 " formname=\"myform\"><field signature=\"1318412689\" type=\"text\"" | 2033 " datapresent=\"1440\" actionsignature=\"15724779818122431245\"" |
| 2027 " autofilltype=\"3\"/><field signature=\"1318412689\" type=\"text\"" | 2034 " formname=\"myform\"><field signature=\"1318412689\" type=\"text\"" |
| 2028 " autofilltype=\"5\"/><field signature=\"1318412689\" type=\"text\"" | 2035 " autofilltype=\"3\"/><field signature=\"1318412689\" type=\"text\"" |
| 2029 " autofilltype=\"9\"/></autofillupload>", | 2036 " autofilltype=\"5\"/><field signature=\"1318412689\" type=\"text\"" |
| 2030 encoded_xml); | 2037 " autofilltype=\"9\"/></autofillupload>\n", |
| 2038 encoded_xml); |
| 2031 } | 2039 } |
| 2032 | 2040 |
| 2033 TEST_F(FormStructureTest, EncodeUploadRequestPartialMetadata) { | 2041 TEST_F(FormStructureTest, EncodeUploadRequestPartialMetadata) { |
| 2034 scoped_ptr<FormStructure> form_structure; | 2042 scoped_ptr<FormStructure> form_structure; |
| 2035 std::vector<ServerFieldTypeSet> possible_field_types; | 2043 std::vector<ServerFieldTypeSet> possible_field_types; |
| 2036 FormData form; | 2044 FormData form; |
| 2037 form_structure.reset(new FormStructure(form)); | 2045 form_structure.reset(new FormStructure(form)); |
| 2038 form_structure->DetermineHeuristicTypes(); | 2046 form_structure->DetermineHeuristicTypes(); |
| 2039 | 2047 |
| 2040 FormFieldData field; | 2048 FormFieldData field; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 2068 form_structure->field(i)->set_possible_types(possible_field_types[i]); | 2076 form_structure->field(i)->set_possible_types(possible_field_types[i]); |
| 2069 | 2077 |
| 2070 ServerFieldTypeSet available_field_types; | 2078 ServerFieldTypeSet available_field_types; |
| 2071 available_field_types.insert(NAME_FIRST); | 2079 available_field_types.insert(NAME_FIRST); |
| 2072 available_field_types.insert(NAME_LAST); | 2080 available_field_types.insert(NAME_LAST); |
| 2073 available_field_types.insert(EMAIL_ADDRESS); | 2081 available_field_types.insert(EMAIL_ADDRESS); |
| 2074 | 2082 |
| 2075 std::string encoded_xml; | 2083 std::string encoded_xml; |
| 2076 EXPECT_TRUE(form_structure->EncodeUploadRequest(available_field_types, true, | 2084 EXPECT_TRUE(form_structure->EncodeUploadRequest(available_field_types, true, |
| 2077 std::string(), &encoded_xml)); | 2085 std::string(), &encoded_xml)); |
| 2078 EXPECT_EQ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" | 2086 EXPECT_EQ( |
| 2079 "<autofillupload clientversion=\"6.1.1715.1442/en (GGLL)\"" | 2087 "<?xml version=\"1.0\"?>\n" |
| 2080 " formsignature=\"13043654279838250996\" autofillused=\"true\"" | 2088 "<autofillupload clientversion=\"6.1.1715.1442/en (GGLL)\"" |
| 2081 " datapresent=\"1440\" actionsignature=\"15724779818122431245\">" | 2089 " formsignature=\"13043654279838250996\" autofillused=\"true\"" |
| 2082 "<field signature=\"1318412689\" type=\"text\" autofilltype=\"3\"/>" | 2090 " datapresent=\"1440\" actionsignature=\"15724779818122431245\">" |
| 2083 "<field signature=\"3494530716\" name=\"lastname\" type=\"text\"" | 2091 "<field signature=\"1318412689\" type=\"text\" autofilltype=\"3\"/>" |
| 2084 " label=\"Last Name\" autocomplete=\"family-name\"" | 2092 "<field signature=\"3494530716\" name=\"lastname\" type=\"text\"" |
| 2085 " autofilltype=\"5\"/>" | 2093 " label=\"Last Name\" autocomplete=\"family-name\"" |
| 2086 "<field signature=\"1545468175\" name=\"lastname\" type=\"email\"" | 2094 " autofilltype=\"5\"/>" |
| 2087 " label=\"Email\" autocomplete=\"email\" autofilltype=\"9\"/>" | 2095 "<field signature=\"1545468175\" name=\"lastname\" type=\"email\"" |
| 2088 "</autofillupload>", | 2096 " label=\"Email\" autocomplete=\"email\" autofilltype=\"9\"/>" |
| 2089 encoded_xml); | 2097 "</autofillupload>\n", |
| 2098 encoded_xml); |
| 2090 } | 2099 } |
| 2091 | 2100 |
| 2092 // Sending field metadata to the server is disabled. | 2101 // Sending field metadata to the server is disabled. |
| 2093 TEST_F(FormStructureTest, EncodeUploadRequest_DisabledMetadataTrial) { | 2102 TEST_F(FormStructureTest, EncodeUploadRequest_DisabledMetadataTrial) { |
| 2094 DisableAutofillMetadataFieldTrial(); | 2103 DisableAutofillMetadataFieldTrial(); |
| 2095 | 2104 |
| 2096 scoped_ptr<FormStructure> form_structure; | 2105 scoped_ptr<FormStructure> form_structure; |
| 2097 std::vector<ServerFieldTypeSet> possible_field_types; | 2106 std::vector<ServerFieldTypeSet> possible_field_types; |
| 2098 FormData form; | 2107 FormData form; |
| 2099 form_structure.reset(new FormStructure(form)); | 2108 form_structure.reset(new FormStructure(form)); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2131 form_structure->field(i)->set_possible_types(possible_field_types[i]); | 2140 form_structure->field(i)->set_possible_types(possible_field_types[i]); |
| 2132 | 2141 |
| 2133 ServerFieldTypeSet available_field_types; | 2142 ServerFieldTypeSet available_field_types; |
| 2134 available_field_types.insert(NAME_FIRST); | 2143 available_field_types.insert(NAME_FIRST); |
| 2135 available_field_types.insert(NAME_LAST); | 2144 available_field_types.insert(NAME_LAST); |
| 2136 available_field_types.insert(EMAIL_ADDRESS); | 2145 available_field_types.insert(EMAIL_ADDRESS); |
| 2137 | 2146 |
| 2138 std::string encoded_xml; | 2147 std::string encoded_xml; |
| 2139 EXPECT_TRUE(form_structure->EncodeUploadRequest(available_field_types, true, | 2148 EXPECT_TRUE(form_structure->EncodeUploadRequest(available_field_types, true, |
| 2140 std::string(), &encoded_xml)); | 2149 std::string(), &encoded_xml)); |
| 2141 EXPECT_EQ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" | 2150 EXPECT_EQ( |
| 2142 "<autofillupload clientversion=\"6.1.1715.1442/en (GGLL)\"" | 2151 "<?xml version=\"1.0\"?>\n" |
| 2143 " formsignature=\"14746822798145140279\" autofillused=\"true\"" | 2152 "<autofillupload clientversion=\"6.1.1715.1442/en (GGLL)\"" |
| 2144 " datapresent=\"1440\"><field signature=\"3763331450\"" | 2153 " formsignature=\"14746822798145140279\" autofillused=\"true\"" |
| 2145 " autofilltype=\"3\"/><field signature=\"3494530716\"" | 2154 " datapresent=\"1440\"><field signature=\"3763331450\"" |
| 2146 " autofilltype=\"5\"/><field signature=\"1029417091\"" | 2155 " autofilltype=\"3\"/><field signature=\"3494530716\"" |
| 2147 " autofilltype=\"9\"/></autofillupload>", | 2156 " autofilltype=\"5\"/><field signature=\"1029417091\"" |
| 2148 encoded_xml); | 2157 " autofilltype=\"9\"/></autofillupload>\n", |
| 2158 encoded_xml); |
| 2149 } | 2159 } |
| 2150 | 2160 |
| 2151 TEST_F(FormStructureTest, EncodeFieldAssignments) { | 2161 TEST_F(FormStructureTest, EncodeFieldAssignments) { |
| 2152 scoped_ptr<FormStructure> form_structure; | 2162 scoped_ptr<FormStructure> form_structure; |
| 2153 std::vector<ServerFieldTypeSet> possible_field_types; | 2163 std::vector<ServerFieldTypeSet> possible_field_types; |
| 2154 FormData form; | 2164 FormData form; |
| 2155 form_structure.reset(new FormStructure(form)); | 2165 form_structure.reset(new FormStructure(form)); |
| 2156 form_structure->DetermineHeuristicTypes(); | 2166 form_structure->DetermineHeuristicTypes(); |
| 2157 | 2167 |
| 2158 FormFieldData field; | 2168 FormFieldData field; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2214 available_field_types.insert(ADDRESS_HOME_COUNTRY); | 2224 available_field_types.insert(ADDRESS_HOME_COUNTRY); |
| 2215 available_field_types.insert(ADDRESS_BILLING_LINE1); | 2225 available_field_types.insert(ADDRESS_BILLING_LINE1); |
| 2216 available_field_types.insert(ADDRESS_BILLING_LINE2); | 2226 available_field_types.insert(ADDRESS_BILLING_LINE2); |
| 2217 available_field_types.insert(EMAIL_ADDRESS); | 2227 available_field_types.insert(EMAIL_ADDRESS); |
| 2218 available_field_types.insert(PHONE_HOME_WHOLE_NUMBER); | 2228 available_field_types.insert(PHONE_HOME_WHOLE_NUMBER); |
| 2219 | 2229 |
| 2220 std::string encoded_xml; | 2230 std::string encoded_xml; |
| 2221 EXPECT_TRUE(form_structure->EncodeFieldAssignments( | 2231 EXPECT_TRUE(form_structure->EncodeFieldAssignments( |
| 2222 available_field_types, &encoded_xml)); | 2232 available_field_types, &encoded_xml)); |
| 2223 EXPECT_EQ( | 2233 EXPECT_EQ( |
| 2224 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" | 2234 "<?xml version=\"1.0\"?>\n" |
| 2225 "<fieldassignments formsignature=\"8736493185895608956\">" | 2235 "<fieldassignments formsignature=\"8736493185895608956\">" |
| 2226 "<fields fieldid=\"3763331450\" fieldtype=\"3\" name=\"firstname\"/>" | 2236 "<fields fieldid=\"3763331450\" fieldtype=\"3\" name=\"firstname\"/>" |
| 2227 "<fields fieldid=\"3494530716\" fieldtype=\"5\" name=\"lastname\"/>" | 2237 "<fields fieldid=\"3494530716\" fieldtype=\"5\" name=\"lastname\"/>" |
| 2228 "<fields fieldid=\"1029417091\" fieldtype=\"9\" name=\"email\"/>" | 2238 "<fields fieldid=\"1029417091\" fieldtype=\"9\" name=\"email\"/>" |
| 2229 "<fields fieldid=\"466116101\" fieldtype=\"14\" name=\"phone\"/>" | 2239 "<fields fieldid=\"466116101\" fieldtype=\"14\" name=\"phone\"/>" |
| 2230 "<fields fieldid=\"2799270304\" fieldtype=\"36\" name=\"country\"/>" | 2240 "<fields fieldid=\"2799270304\" fieldtype=\"36\" name=\"country\"/>" |
| 2231 "<fields fieldid=\"3410250678\" fieldtype=\"36\" name=\"Checkable1\"/>" | 2241 "<fields fieldid=\"3410250678\" fieldtype=\"36\" name=\"Checkable1\"/>" |
| 2232 "</fieldassignments>", | 2242 "</fieldassignments>\n", |
| 2233 encoded_xml); | 2243 encoded_xml); |
| 2234 | 2244 |
| 2235 // Add 2 address fields - this should be still a valid form. | 2245 // Add 2 address fields - this should be still a valid form. |
| 2236 for (size_t i = 0; i < 2; ++i) { | 2246 for (size_t i = 0; i < 2; ++i) { |
| 2237 field.label = ASCIIToUTF16("Address"); | 2247 field.label = ASCIIToUTF16("Address"); |
| 2238 field.name = ASCIIToUTF16("address"); | 2248 field.name = ASCIIToUTF16("address"); |
| 2239 field.form_control_type = "text"; | 2249 field.form_control_type = "text"; |
| 2240 form.fields.push_back(field); | 2250 form.fields.push_back(field); |
| 2241 possible_field_types.push_back(ServerFieldTypeSet()); | 2251 possible_field_types.push_back(ServerFieldTypeSet()); |
| 2242 possible_field_types.back().insert(ADDRESS_HOME_LINE1); | 2252 possible_field_types.back().insert(ADDRESS_HOME_LINE1); |
| 2243 possible_field_types.back().insert(ADDRESS_HOME_LINE2); | 2253 possible_field_types.back().insert(ADDRESS_HOME_LINE2); |
| 2244 possible_field_types.back().insert(ADDRESS_BILLING_LINE1); | 2254 possible_field_types.back().insert(ADDRESS_BILLING_LINE1); |
| 2245 possible_field_types.back().insert(ADDRESS_BILLING_LINE2); | 2255 possible_field_types.back().insert(ADDRESS_BILLING_LINE2); |
| 2246 } | 2256 } |
| 2247 | 2257 |
| 2248 form_structure.reset(new FormStructure(form)); | 2258 form_structure.reset(new FormStructure(form)); |
| 2249 ASSERT_EQ(form_structure->field_count(), possible_field_types.size()); | 2259 ASSERT_EQ(form_structure->field_count(), possible_field_types.size()); |
| 2250 for (size_t i = 0; i < form_structure->field_count(); ++i) | 2260 for (size_t i = 0; i < form_structure->field_count(); ++i) |
| 2251 form_structure->field(i)->set_possible_types(possible_field_types[i]); | 2261 form_structure->field(i)->set_possible_types(possible_field_types[i]); |
| 2252 | 2262 |
| 2253 EXPECT_TRUE(form_structure->EncodeFieldAssignments( | 2263 EXPECT_TRUE(form_structure->EncodeFieldAssignments( |
| 2254 available_field_types, &encoded_xml)); | 2264 available_field_types, &encoded_xml)); |
| 2255 EXPECT_EQ( | 2265 EXPECT_EQ( |
| 2256 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" | 2266 "<?xml version=\"1.0\"?>\n" |
| 2257 "<fieldassignments formsignature=\"7816485729218079147\">" | 2267 "<fieldassignments formsignature=\"7816485729218079147\">" |
| 2258 "<fields fieldid=\"3763331450\" fieldtype=\"3\" name=\"firstname\"/>" | 2268 "<fields fieldid=\"3763331450\" fieldtype=\"3\" name=\"firstname\"/>" |
| 2259 "<fields fieldid=\"3494530716\" fieldtype=\"5\" name=\"lastname\"/>" | 2269 "<fields fieldid=\"3494530716\" fieldtype=\"5\" name=\"lastname\"/>" |
| 2260 "<fields fieldid=\"1029417091\" fieldtype=\"9\" name=\"email\"/>" | 2270 "<fields fieldid=\"1029417091\" fieldtype=\"9\" name=\"email\"/>" |
| 2261 "<fields fieldid=\"466116101\" fieldtype=\"14\" name=\"phone\"/>" | 2271 "<fields fieldid=\"466116101\" fieldtype=\"14\" name=\"phone\"/>" |
| 2262 "<fields fieldid=\"2799270304\" fieldtype=\"36\" name=\"country\"/>" | 2272 "<fields fieldid=\"2799270304\" fieldtype=\"36\" name=\"country\"/>" |
| 2263 "<fields fieldid=\"3410250678\" fieldtype=\"36\" name=\"Checkable1\"/>" | 2273 "<fields fieldid=\"3410250678\" fieldtype=\"36\" name=\"Checkable1\"/>" |
| 2264 "<fields fieldid=\"509334676\" fieldtype=\"30\" name=\"address\"/>" | 2274 "<fields fieldid=\"509334676\" fieldtype=\"30\" name=\"address\"/>" |
| 2265 "<fields fieldid=\"509334676\" fieldtype=\"31\" name=\"address\"/>" | 2275 "<fields fieldid=\"509334676\" fieldtype=\"31\" name=\"address\"/>" |
| 2266 "<fields fieldid=\"509334676\" fieldtype=\"37\" name=\"address\"/>" | 2276 "<fields fieldid=\"509334676\" fieldtype=\"37\" name=\"address\"/>" |
| 2267 "<fields fieldid=\"509334676\" fieldtype=\"38\" name=\"address\"/>" | 2277 "<fields fieldid=\"509334676\" fieldtype=\"38\" name=\"address\"/>" |
| 2268 "<fields fieldid=\"509334676\" fieldtype=\"30\" name=\"address\"/>" | 2278 "<fields fieldid=\"509334676\" fieldtype=\"30\" name=\"address\"/>" |
| 2269 "<fields fieldid=\"509334676\" fieldtype=\"31\" name=\"address\"/>" | 2279 "<fields fieldid=\"509334676\" fieldtype=\"31\" name=\"address\"/>" |
| 2270 "<fields fieldid=\"509334676\" fieldtype=\"37\" name=\"address\"/>" | 2280 "<fields fieldid=\"509334676\" fieldtype=\"37\" name=\"address\"/>" |
| 2271 "<fields fieldid=\"509334676\" fieldtype=\"38\" name=\"address\"/>" | 2281 "<fields fieldid=\"509334676\" fieldtype=\"38\" name=\"address\"/>" |
| 2272 "</fieldassignments>", | 2282 "</fieldassignments>\n", |
| 2273 encoded_xml); | 2283 encoded_xml); |
| 2274 } | 2284 } |
| 2275 | 2285 |
| 2276 // Check that we compute the "datapresent" string correctly for the given | 2286 // Check that we compute the "datapresent" string correctly for the given |
| 2277 // |available_types|. | 2287 // |available_types|. |
| 2278 TEST_F(FormStructureTest, CheckDataPresence) { | 2288 TEST_F(FormStructureTest, CheckDataPresence) { |
| 2279 FormData form; | 2289 FormData form; |
| 2280 | 2290 |
| 2281 FormFieldData field; | 2291 FormFieldData field; |
| 2282 field.form_control_type = "text"; | 2292 field.form_control_type = "text"; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 2301 form_structure.field(i)->set_possible_types(unknown_type); | 2311 form_structure.field(i)->set_possible_types(unknown_type); |
| 2302 | 2312 |
| 2303 // No available types. | 2313 // No available types. |
| 2304 // datapresent should be "" == trimmmed(0x0000000000000000) == | 2314 // datapresent should be "" == trimmmed(0x0000000000000000) == |
| 2305 // 0b0000000000000000000000000000000000000000000000000000000000000000 | 2315 // 0b0000000000000000000000000000000000000000000000000000000000000000 |
| 2306 ServerFieldTypeSet available_field_types; | 2316 ServerFieldTypeSet available_field_types; |
| 2307 | 2317 |
| 2308 std::string encoded_xml; | 2318 std::string encoded_xml; |
| 2309 EXPECT_TRUE(form_structure.EncodeUploadRequest(available_field_types, false, | 2319 EXPECT_TRUE(form_structure.EncodeUploadRequest(available_field_types, false, |
| 2310 std::string(), &encoded_xml)); | 2320 std::string(), &encoded_xml)); |
| 2311 EXPECT_EQ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" | 2321 EXPECT_EQ( |
| 2312 "<autofillupload clientversion=\"6.1.1715.1442/en (GGLL)\"" | 2322 "<?xml version=\"1.0\"?>\n" |
| 2313 " formsignature=\"6402244543831589061\" autofillused=\"false\"" | 2323 "<autofillupload clientversion=\"6.1.1715.1442/en (GGLL)\"" |
| 2314 " datapresent=\"\" actionsignature=\"15724779818122431245\">" | 2324 " formsignature=\"6402244543831589061\" autofillused=\"false\"" |
| 2315 "<field signature=\"1089846351\" name=\"first\" type=\"text\"" | 2325 " datapresent=\"\" actionsignature=\"15724779818122431245\">" |
| 2316 " label=\"First Name\" autofilltype=\"1\"/>" | 2326 "<field signature=\"1089846351\" name=\"first\" type=\"text\"" |
| 2317 "<field signature=\"2404144663\" name=\"last\" type=\"text\"" | 2327 " label=\"First Name\" autofilltype=\"1\"/>" |
| 2318 " label=\"Last Name\" autofilltype=\"1\"/>" | 2328 "<field signature=\"2404144663\" name=\"last\" type=\"text\"" |
| 2319 "<field signature=\"420638584\" name=\"email\" type=\"text\"" | 2329 " label=\"Last Name\" autofilltype=\"1\"/>" |
| 2320 " label=\"Email\" autofilltype=\"1\"/></autofillupload>", | 2330 "<field signature=\"420638584\" name=\"email\" type=\"text\"" |
| 2321 encoded_xml); | 2331 " label=\"Email\" autofilltype=\"1\"/></autofillupload>\n", |
| 2332 encoded_xml); |
| 2322 | 2333 |
| 2323 // Only a few types available. | 2334 // Only a few types available. |
| 2324 // datapresent should be "1540000240" == trimmmed(0x1540000240000000) == | 2335 // datapresent should be "1540000240" == trimmmed(0x1540000240000000) == |
| 2325 // 0b0001010101000000000000000000001001000000000000000000000000000000 | 2336 // 0b0001010101000000000000000000001001000000000000000000000000000000 |
| 2326 // The set bits are: | 2337 // The set bits are: |
| 2327 // 3 == NAME_FIRST | 2338 // 3 == NAME_FIRST |
| 2328 // 5 == NAME_LAST | 2339 // 5 == NAME_LAST |
| 2329 // 7 == NAME_FULL | 2340 // 7 == NAME_FULL |
| 2330 // 9 == EMAIL_ADDRESS | 2341 // 9 == EMAIL_ADDRESS |
| 2331 // 30 == ADDRESS_HOME_LINE1 | 2342 // 30 == ADDRESS_HOME_LINE1 |
| 2332 // 33 == ADDRESS_HOME_CITY | 2343 // 33 == ADDRESS_HOME_CITY |
| 2333 available_field_types.clear(); | 2344 available_field_types.clear(); |
| 2334 available_field_types.insert(NAME_FIRST); | 2345 available_field_types.insert(NAME_FIRST); |
| 2335 available_field_types.insert(NAME_LAST); | 2346 available_field_types.insert(NAME_LAST); |
| 2336 available_field_types.insert(NAME_FULL); | 2347 available_field_types.insert(NAME_FULL); |
| 2337 available_field_types.insert(EMAIL_ADDRESS); | 2348 available_field_types.insert(EMAIL_ADDRESS); |
| 2338 available_field_types.insert(ADDRESS_HOME_LINE1); | 2349 available_field_types.insert(ADDRESS_HOME_LINE1); |
| 2339 available_field_types.insert(ADDRESS_HOME_CITY); | 2350 available_field_types.insert(ADDRESS_HOME_CITY); |
| 2340 | 2351 |
| 2341 EXPECT_TRUE(form_structure.EncodeUploadRequest(available_field_types, false, | 2352 EXPECT_TRUE(form_structure.EncodeUploadRequest(available_field_types, false, |
| 2342 std::string(), &encoded_xml)); | 2353 std::string(), &encoded_xml)); |
| 2343 EXPECT_EQ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" | 2354 EXPECT_EQ( |
| 2344 "<autofillupload clientversion=\"6.1.1715.1442/en (GGLL)\"" | 2355 "<?xml version=\"1.0\"?>\n" |
| 2345 " formsignature=\"6402244543831589061\" autofillused=\"false\"" | 2356 "<autofillupload clientversion=\"6.1.1715.1442/en (GGLL)\"" |
| 2346 " datapresent=\"1540000240\"" | 2357 " formsignature=\"6402244543831589061\" autofillused=\"false\"" |
| 2347 " actionsignature=\"15724779818122431245\">" | 2358 " datapresent=\"1540000240\"" |
| 2348 "<field signature=\"1089846351\" name=\"first\" type=\"text\"" | 2359 " actionsignature=\"15724779818122431245\">" |
| 2349 " label=\"First Name\" autofilltype=\"1\"/>" | 2360 "<field signature=\"1089846351\" name=\"first\" type=\"text\"" |
| 2350 "<field signature=\"2404144663\" name=\"last\" type=\"text\"" | 2361 " label=\"First Name\" autofilltype=\"1\"/>" |
| 2351 " label=\"Last Name\" autofilltype=\"1\"/>" | 2362 "<field signature=\"2404144663\" name=\"last\" type=\"text\"" |
| 2352 "<field signature=\"420638584\" name=\"email\" type=\"text\"" | 2363 " label=\"Last Name\" autofilltype=\"1\"/>" |
| 2353 " label=\"Email\" autofilltype=\"1\"/></autofillupload>", | 2364 "<field signature=\"420638584\" name=\"email\" type=\"text\"" |
| 2354 encoded_xml); | 2365 " label=\"Email\" autofilltype=\"1\"/></autofillupload>\n", |
| 2366 encoded_xml); |
| 2355 | 2367 |
| 2356 // All supported non-credit card types available. | 2368 // All supported non-credit card types available. |
| 2357 // datapresent should be "1f7e000378000008" == trimmmed(0x1f7e000378000008) == | 2369 // datapresent should be "1f7e000378000008" == trimmmed(0x1f7e000378000008) == |
| 2358 // 0b0001111101111110000000000000001101111000000000000000000000001000 | 2370 // 0b0001111101111110000000000000001101111000000000000000000000001000 |
| 2359 // The set bits are: | 2371 // The set bits are: |
| 2360 // 3 == NAME_FIRST | 2372 // 3 == NAME_FIRST |
| 2361 // 4 == NAME_MIDDLE | 2373 // 4 == NAME_MIDDLE |
| 2362 // 5 == NAME_LAST | 2374 // 5 == NAME_LAST |
| 2363 // 6 == NAME_MIDDLE_INITIAL | 2375 // 6 == NAME_MIDDLE_INITIAL |
| 2364 // 7 == NAME_FULL | 2376 // 7 == NAME_FULL |
| (...skipping 25 matching lines...) Expand all Loading... |
| 2390 available_field_types.insert(ADDRESS_HOME_LINE1); | 2402 available_field_types.insert(ADDRESS_HOME_LINE1); |
| 2391 available_field_types.insert(ADDRESS_HOME_LINE2); | 2403 available_field_types.insert(ADDRESS_HOME_LINE2); |
| 2392 available_field_types.insert(ADDRESS_HOME_CITY); | 2404 available_field_types.insert(ADDRESS_HOME_CITY); |
| 2393 available_field_types.insert(ADDRESS_HOME_STATE); | 2405 available_field_types.insert(ADDRESS_HOME_STATE); |
| 2394 available_field_types.insert(ADDRESS_HOME_ZIP); | 2406 available_field_types.insert(ADDRESS_HOME_ZIP); |
| 2395 available_field_types.insert(ADDRESS_HOME_COUNTRY); | 2407 available_field_types.insert(ADDRESS_HOME_COUNTRY); |
| 2396 available_field_types.insert(COMPANY_NAME); | 2408 available_field_types.insert(COMPANY_NAME); |
| 2397 | 2409 |
| 2398 EXPECT_TRUE(form_structure.EncodeUploadRequest(available_field_types, false, | 2410 EXPECT_TRUE(form_structure.EncodeUploadRequest(available_field_types, false, |
| 2399 std::string(), &encoded_xml)); | 2411 std::string(), &encoded_xml)); |
| 2400 EXPECT_EQ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" | 2412 EXPECT_EQ( |
| 2401 "<autofillupload clientversion=\"6.1.1715.1442/en (GGLL)\"" | 2413 "<?xml version=\"1.0\"?>\n" |
| 2402 " formsignature=\"6402244543831589061\" autofillused=\"false\"" | 2414 "<autofillupload clientversion=\"6.1.1715.1442/en (GGLL)\"" |
| 2403 " datapresent=\"1f7e000378000008\"" | 2415 " formsignature=\"6402244543831589061\" autofillused=\"false\"" |
| 2404 " actionsignature=\"15724779818122431245\">" | 2416 " datapresent=\"1f7e000378000008\"" |
| 2405 "<field signature=\"1089846351\" name=\"first\" type=\"text\"" | 2417 " actionsignature=\"15724779818122431245\">" |
| 2406 " label=\"First Name\" autofilltype=\"1\"/>" | 2418 "<field signature=\"1089846351\" name=\"first\" type=\"text\"" |
| 2407 "<field signature=\"2404144663\" name=\"last\" type=\"text\"" | 2419 " label=\"First Name\" autofilltype=\"1\"/>" |
| 2408 " label=\"Last Name\" autofilltype=\"1\"/>" | 2420 "<field signature=\"2404144663\" name=\"last\" type=\"text\"" |
| 2409 "<field signature=\"420638584\" name=\"email\" type=\"text\"" | 2421 " label=\"Last Name\" autofilltype=\"1\"/>" |
| 2410 " label=\"Email\" autofilltype=\"1\"/></autofillupload>", | 2422 "<field signature=\"420638584\" name=\"email\" type=\"text\"" |
| 2411 encoded_xml); | 2423 " label=\"Email\" autofilltype=\"1\"/></autofillupload>\n", |
| 2424 encoded_xml); |
| 2412 | 2425 |
| 2413 // All supported credit card types available. | 2426 // All supported credit card types available. |
| 2414 // datapresent should be "0000000000001fc0" == trimmmed(0x0000000000001fc0) == | 2427 // datapresent should be "0000000000001fc0" == trimmmed(0x0000000000001fc0) == |
| 2415 // 0b0000000000000000000000000000000000000000000000000001111111000000 | 2428 // 0b0000000000000000000000000000000000000000000000000001111111000000 |
| 2416 // The set bits are: | 2429 // The set bits are: |
| 2417 // 51 == CREDIT_CARD_NAME | 2430 // 51 == CREDIT_CARD_NAME |
| 2418 // 52 == CREDIT_CARD_NUMBER | 2431 // 52 == CREDIT_CARD_NUMBER |
| 2419 // 53 == CREDIT_CARD_EXP_MONTH | 2432 // 53 == CREDIT_CARD_EXP_MONTH |
| 2420 // 54 == CREDIT_CARD_EXP_2_DIGIT_YEAR | 2433 // 54 == CREDIT_CARD_EXP_2_DIGIT_YEAR |
| 2421 // 55 == CREDIT_CARD_EXP_4_DIGIT_YEAR | 2434 // 55 == CREDIT_CARD_EXP_4_DIGIT_YEAR |
| 2422 // 56 == CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR | 2435 // 56 == CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR |
| 2423 // 57 == CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR | 2436 // 57 == CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR |
| 2424 available_field_types.clear(); | 2437 available_field_types.clear(); |
| 2425 available_field_types.insert(CREDIT_CARD_NAME); | 2438 available_field_types.insert(CREDIT_CARD_NAME); |
| 2426 available_field_types.insert(CREDIT_CARD_NUMBER); | 2439 available_field_types.insert(CREDIT_CARD_NUMBER); |
| 2427 available_field_types.insert(CREDIT_CARD_EXP_MONTH); | 2440 available_field_types.insert(CREDIT_CARD_EXP_MONTH); |
| 2428 available_field_types.insert(CREDIT_CARD_EXP_2_DIGIT_YEAR); | 2441 available_field_types.insert(CREDIT_CARD_EXP_2_DIGIT_YEAR); |
| 2429 available_field_types.insert(CREDIT_CARD_EXP_4_DIGIT_YEAR); | 2442 available_field_types.insert(CREDIT_CARD_EXP_4_DIGIT_YEAR); |
| 2430 available_field_types.insert(CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR); | 2443 available_field_types.insert(CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR); |
| 2431 available_field_types.insert(CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR); | 2444 available_field_types.insert(CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR); |
| 2432 | 2445 |
| 2433 EXPECT_TRUE(form_structure.EncodeUploadRequest(available_field_types, false, | 2446 EXPECT_TRUE(form_structure.EncodeUploadRequest(available_field_types, false, |
| 2434 std::string(), &encoded_xml)); | 2447 std::string(), &encoded_xml)); |
| 2435 EXPECT_EQ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" | 2448 EXPECT_EQ( |
| 2436 "<autofillupload clientversion=\"6.1.1715.1442/en (GGLL)\"" | 2449 "<?xml version=\"1.0\"?>\n" |
| 2437 " formsignature=\"6402244543831589061\" autofillused=\"false\"" | 2450 "<autofillupload clientversion=\"6.1.1715.1442/en (GGLL)\"" |
| 2438 " datapresent=\"0000000000001fc0\"" | 2451 " formsignature=\"6402244543831589061\" autofillused=\"false\"" |
| 2439 " actionsignature=\"15724779818122431245\">" | 2452 " datapresent=\"0000000000001fc0\"" |
| 2440 "<field signature=\"1089846351\" name=\"first\" type=\"text\"" | 2453 " actionsignature=\"15724779818122431245\">" |
| 2441 " label=\"First Name\" autofilltype=\"1\"/>" | 2454 "<field signature=\"1089846351\" name=\"first\" type=\"text\"" |
| 2442 "<field signature=\"2404144663\" name=\"last\" type=\"text\"" | 2455 " label=\"First Name\" autofilltype=\"1\"/>" |
| 2443 " label=\"Last Name\" autofilltype=\"1\"/>" | 2456 "<field signature=\"2404144663\" name=\"last\" type=\"text\"" |
| 2444 "<field signature=\"420638584\" name=\"email\" type=\"text\"" | 2457 " label=\"Last Name\" autofilltype=\"1\"/>" |
| 2445 " label=\"Email\" autofilltype=\"1\"/></autofillupload>", | 2458 "<field signature=\"420638584\" name=\"email\" type=\"text\"" |
| 2446 encoded_xml); | 2459 " label=\"Email\" autofilltype=\"1\"/></autofillupload>\n", |
| 2460 encoded_xml); |
| 2447 | 2461 |
| 2448 // All supported types available. | 2462 // All supported types available. |
| 2449 // datapresent should be "1f7e000378001fc8" == trimmmed(0x1f7e000378001fc8) == | 2463 // datapresent should be "1f7e000378001fc8" == trimmmed(0x1f7e000378001fc8) == |
| 2450 // 0b0001111101111110000000000000001101111000000000000001111111001000 | 2464 // 0b0001111101111110000000000000001101111000000000000001111111001000 |
| 2451 // The set bits are: | 2465 // The set bits are: |
| 2452 // 3 == NAME_FIRST | 2466 // 3 == NAME_FIRST |
| 2453 // 4 == NAME_MIDDLE | 2467 // 4 == NAME_MIDDLE |
| 2454 // 5 == NAME_LAST | 2468 // 5 == NAME_LAST |
| 2455 // 6 == NAME_MIDDLE_INITIAL | 2469 // 6 == NAME_MIDDLE_INITIAL |
| 2456 // 7 == NAME_FULL | 2470 // 7 == NAME_FULL |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2496 available_field_types.insert(CREDIT_CARD_NUMBER); | 2510 available_field_types.insert(CREDIT_CARD_NUMBER); |
| 2497 available_field_types.insert(CREDIT_CARD_EXP_MONTH); | 2511 available_field_types.insert(CREDIT_CARD_EXP_MONTH); |
| 2498 available_field_types.insert(CREDIT_CARD_EXP_2_DIGIT_YEAR); | 2512 available_field_types.insert(CREDIT_CARD_EXP_2_DIGIT_YEAR); |
| 2499 available_field_types.insert(CREDIT_CARD_EXP_4_DIGIT_YEAR); | 2513 available_field_types.insert(CREDIT_CARD_EXP_4_DIGIT_YEAR); |
| 2500 available_field_types.insert(CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR); | 2514 available_field_types.insert(CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR); |
| 2501 available_field_types.insert(CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR); | 2515 available_field_types.insert(CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR); |
| 2502 available_field_types.insert(COMPANY_NAME); | 2516 available_field_types.insert(COMPANY_NAME); |
| 2503 | 2517 |
| 2504 EXPECT_TRUE(form_structure.EncodeUploadRequest(available_field_types, false, | 2518 EXPECT_TRUE(form_structure.EncodeUploadRequest(available_field_types, false, |
| 2505 std::string(), &encoded_xml)); | 2519 std::string(), &encoded_xml)); |
| 2506 EXPECT_EQ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" | 2520 EXPECT_EQ( |
| 2507 "<autofillupload clientversion=\"6.1.1715.1442/en (GGLL)\"" | 2521 "<?xml version=\"1.0\"?>\n" |
| 2508 " formsignature=\"6402244543831589061\" autofillused=\"false\"" | 2522 "<autofillupload clientversion=\"6.1.1715.1442/en (GGLL)\"" |
| 2509 " datapresent=\"1f7e000378001fc8\"" | 2523 " formsignature=\"6402244543831589061\" autofillused=\"false\"" |
| 2510 " actionsignature=\"15724779818122431245\">" | 2524 " datapresent=\"1f7e000378001fc8\"" |
| 2511 "<field signature=\"1089846351\" name=\"first\" type=\"text\"" | 2525 " actionsignature=\"15724779818122431245\">" |
| 2512 " label=\"First Name\" autofilltype=\"1\"/>" | 2526 "<field signature=\"1089846351\" name=\"first\" type=\"text\"" |
| 2513 "<field signature=\"2404144663\" name=\"last\" type=\"text\"" | 2527 " label=\"First Name\" autofilltype=\"1\"/>" |
| 2514 " label=\"Last Name\" autofilltype=\"1\"/>" | 2528 "<field signature=\"2404144663\" name=\"last\" type=\"text\"" |
| 2515 "<field signature=\"420638584\" name=\"email\" type=\"text\"" | 2529 " label=\"Last Name\" autofilltype=\"1\"/>" |
| 2516 " label=\"Email\" autofilltype=\"1\"/></autofillupload>", | 2530 "<field signature=\"420638584\" name=\"email\" type=\"text\"" |
| 2517 encoded_xml); | 2531 " label=\"Email\" autofilltype=\"1\"/></autofillupload>\n", |
| 2532 encoded_xml); |
| 2518 } | 2533 } |
| 2519 | 2534 |
| 2520 TEST_F(FormStructureTest, CheckMultipleTypes) { | 2535 TEST_F(FormStructureTest, CheckMultipleTypes) { |
| 2521 // Throughout this test, datapresent should be | 2536 // Throughout this test, datapresent should be |
| 2522 // 0x1440000360000008 == | 2537 // 0x1440000360000008 == |
| 2523 // 0b0001010001000000000000000000001101100000000000000000000000001000 | 2538 // 0b0001010001000000000000000000001101100000000000000000000000001000 |
| 2524 // The set bits are: | 2539 // The set bits are: |
| 2525 // 3 == NAME_FIRST | 2540 // 3 == NAME_FIRST |
| 2526 // 5 == NAME_LAST | 2541 // 5 == NAME_LAST |
| 2527 // 9 == EMAIL_ADDRESS | 2542 // 9 == EMAIL_ADDRESS |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2574 | 2589 |
| 2575 form_structure.reset(new FormStructure(form)); | 2590 form_structure.reset(new FormStructure(form)); |
| 2576 | 2591 |
| 2577 for (size_t i = 0; i < form_structure->field_count(); ++i) | 2592 for (size_t i = 0; i < form_structure->field_count(); ++i) |
| 2578 form_structure->field(i)->set_possible_types(possible_field_types[i]); | 2593 form_structure->field(i)->set_possible_types(possible_field_types[i]); |
| 2579 std::string encoded_xml; | 2594 std::string encoded_xml; |
| 2580 | 2595 |
| 2581 // Now we matched both fields singularly. | 2596 // Now we matched both fields singularly. |
| 2582 EXPECT_TRUE(form_structure->EncodeUploadRequest(available_field_types, false, | 2597 EXPECT_TRUE(form_structure->EncodeUploadRequest(available_field_types, false, |
| 2583 std::string(), &encoded_xml)); | 2598 std::string(), &encoded_xml)); |
| 2584 EXPECT_EQ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" | 2599 EXPECT_EQ( |
| 2585 "<autofillupload clientversion=\"6.1.1715.1442/en (GGLL)\"" | 2600 "<?xml version=\"1.0\"?>\n" |
| 2586 " formsignature=\"18062476096658145866\" autofillused=\"false\"" | 2601 "<autofillupload clientversion=\"6.1.1715.1442/en (GGLL)\"" |
| 2587 " datapresent=\"1440000360000008\"" | 2602 " formsignature=\"18062476096658145866\" autofillused=\"false\"" |
| 2588 " actionsignature=\"15724779818122431245\">" | 2603 " datapresent=\"1440000360000008\"" |
| 2589 "<field signature=\"420638584\" name=\"email\" type=\"text\"" | 2604 " actionsignature=\"15724779818122431245\">" |
| 2590 " label=\"email\" autofilltype=\"9\"/>" | 2605 "<field signature=\"420638584\" name=\"email\" type=\"text\"" |
| 2591 "<field signature=\"1089846351\" name=\"first\" type=\"text\"" | 2606 " label=\"email\" autofilltype=\"9\"/>" |
| 2592 " label=\"First Name\" autofilltype=\"3\"/>" | 2607 "<field signature=\"1089846351\" name=\"first\" type=\"text\"" |
| 2593 "<field signature=\"2404144663\" name=\"last\" type=\"text\"" | 2608 " label=\"First Name\" autofilltype=\"3\"/>" |
| 2594 " label=\"Last Name\" autofilltype=\"5\"/>" | 2609 "<field signature=\"2404144663\" name=\"last\" type=\"text\"" |
| 2595 "<field signature=\"509334676\" name=\"address\" type=\"text\"" | 2610 " label=\"Last Name\" autofilltype=\"5\"/>" |
| 2596 " label=\"Address\" autofilltype=\"30\"/></autofillupload>", | 2611 "<field signature=\"509334676\" name=\"address\" type=\"text\"" |
| 2597 encoded_xml); | 2612 " label=\"Address\" autofilltype=\"30\"/></autofillupload>\n", |
| 2613 encoded_xml); |
| 2598 // Match third field as both first and last. | 2614 // Match third field as both first and last. |
| 2599 possible_field_types[2].insert(NAME_FIRST); | 2615 possible_field_types[2].insert(NAME_FIRST); |
| 2600 form_structure->field(2)->set_possible_types(possible_field_types[2]); | 2616 form_structure->field(2)->set_possible_types(possible_field_types[2]); |
| 2601 EXPECT_TRUE(form_structure->EncodeUploadRequest(available_field_types, false, | 2617 EXPECT_TRUE(form_structure->EncodeUploadRequest(available_field_types, false, |
| 2602 std::string(), &encoded_xml)); | 2618 std::string(), &encoded_xml)); |
| 2603 EXPECT_EQ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" | 2619 EXPECT_EQ( |
| 2604 "<autofillupload clientversion=\"6.1.1715.1442/en (GGLL)\"" | 2620 "<?xml version=\"1.0\"?>\n" |
| 2605 " formsignature=\"18062476096658145866\" autofillused=\"false\"" | 2621 "<autofillupload clientversion=\"6.1.1715.1442/en (GGLL)\"" |
| 2606 " datapresent=\"1440000360000008\"" | 2622 " formsignature=\"18062476096658145866\" autofillused=\"false\"" |
| 2607 " actionsignature=\"15724779818122431245\">" | 2623 " datapresent=\"1440000360000008\"" |
| 2608 "<field signature=\"420638584\" name=\"email\" type=\"text\"" | 2624 " actionsignature=\"15724779818122431245\">" |
| 2609 " label=\"email\" autofilltype=\"9\"/>" | 2625 "<field signature=\"420638584\" name=\"email\" type=\"text\"" |
| 2610 "<field signature=\"1089846351\" name=\"first\" type=\"text\"" | 2626 " label=\"email\" autofilltype=\"9\"/>" |
| 2611 " label=\"First Name\" autofilltype=\"3\"/>" | 2627 "<field signature=\"1089846351\" name=\"first\" type=\"text\"" |
| 2612 "<field signature=\"2404144663\" name=\"last\" type=\"text\"" | 2628 " label=\"First Name\" autofilltype=\"3\"/>" |
| 2613 " label=\"Last Name\" autofilltype=\"3\"/>" | 2629 "<field signature=\"2404144663\" name=\"last\" type=\"text\"" |
| 2614 "<field signature=\"2404144663\" name=\"last\" type=\"text\"" | 2630 " label=\"Last Name\" autofilltype=\"3\"/>" |
| 2615 " label=\"Last Name\" autofilltype=\"5\"/>" | 2631 "<field signature=\"2404144663\" name=\"last\" type=\"text\"" |
| 2616 "<field signature=\"509334676\" name=\"address\" type=\"text\"" | 2632 " label=\"Last Name\" autofilltype=\"5\"/>" |
| 2617 " label=\"Address\" autofilltype=\"30\"/></autofillupload>", | 2633 "<field signature=\"509334676\" name=\"address\" type=\"text\"" |
| 2618 encoded_xml); | 2634 " label=\"Address\" autofilltype=\"30\"/></autofillupload>\n", |
| 2635 encoded_xml); |
| 2619 possible_field_types[3].insert(ADDRESS_HOME_LINE2); | 2636 possible_field_types[3].insert(ADDRESS_HOME_LINE2); |
| 2620 form_structure->field(form_structure->field_count() - 1)->set_possible_types( | 2637 form_structure->field(form_structure->field_count() - 1)->set_possible_types( |
| 2621 possible_field_types[form_structure->field_count() - 1]); | 2638 possible_field_types[form_structure->field_count() - 1]); |
| 2622 EXPECT_TRUE(form_structure->EncodeUploadRequest(available_field_types, false, | 2639 EXPECT_TRUE(form_structure->EncodeUploadRequest(available_field_types, false, |
| 2623 std::string(), &encoded_xml)); | 2640 std::string(), &encoded_xml)); |
| 2624 EXPECT_EQ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" | 2641 EXPECT_EQ( |
| 2625 "<autofillupload clientversion=\"6.1.1715.1442/en (GGLL)\"" | 2642 "<?xml version=\"1.0\"?>\n" |
| 2626 " formsignature=\"18062476096658145866\" autofillused=\"false\"" | 2643 "<autofillupload clientversion=\"6.1.1715.1442/en (GGLL)\"" |
| 2627 " datapresent=\"1440000360000008\"" | 2644 " formsignature=\"18062476096658145866\" autofillused=\"false\"" |
| 2628 " actionsignature=\"15724779818122431245\">" | 2645 " datapresent=\"1440000360000008\"" |
| 2629 "<field signature=\"420638584\" name=\"email\" type=\"text\"" | 2646 " actionsignature=\"15724779818122431245\">" |
| 2630 " label=\"email\" autofilltype=\"9\"/>" | 2647 "<field signature=\"420638584\" name=\"email\" type=\"text\"" |
| 2631 "<field signature=\"1089846351\" name=\"first\" type=\"text\"" | 2648 " label=\"email\" autofilltype=\"9\"/>" |
| 2632 " label=\"First Name\" autofilltype=\"3\"/>" | 2649 "<field signature=\"1089846351\" name=\"first\" type=\"text\"" |
| 2633 "<field signature=\"2404144663\" name=\"last\" type=\"text\"" | 2650 " label=\"First Name\" autofilltype=\"3\"/>" |
| 2634 " label=\"Last Name\" autofilltype=\"3\"/>" | 2651 "<field signature=\"2404144663\" name=\"last\" type=\"text\"" |
| 2635 "<field signature=\"2404144663\" name=\"last\" type=\"text\"" | 2652 " label=\"Last Name\" autofilltype=\"3\"/>" |
| 2636 " label=\"Last Name\" autofilltype=\"5\"/>" | 2653 "<field signature=\"2404144663\" name=\"last\" type=\"text\"" |
| 2637 "<field signature=\"509334676\" name=\"address\" type=\"text\"" | 2654 " label=\"Last Name\" autofilltype=\"5\"/>" |
| 2638 " label=\"Address\" autofilltype=\"30\"/>" | 2655 "<field signature=\"509334676\" name=\"address\" type=\"text\"" |
| 2639 "<field signature=\"509334676\" name=\"address\" type=\"text\"" | 2656 " label=\"Address\" autofilltype=\"30\"/>" |
| 2640 " label=\"Address\" autofilltype=\"31\"/></autofillupload>", | 2657 "<field signature=\"509334676\" name=\"address\" type=\"text\"" |
| 2641 encoded_xml); | 2658 " label=\"Address\" autofilltype=\"31\"/></autofillupload>\n", |
| 2659 encoded_xml); |
| 2642 possible_field_types[3].clear(); | 2660 possible_field_types[3].clear(); |
| 2643 possible_field_types[3].insert(ADDRESS_HOME_LINE1); | 2661 possible_field_types[3].insert(ADDRESS_HOME_LINE1); |
| 2644 possible_field_types[3].insert(COMPANY_NAME); | 2662 possible_field_types[3].insert(COMPANY_NAME); |
| 2645 form_structure->field(form_structure->field_count() - 1)->set_possible_types( | 2663 form_structure->field(form_structure->field_count() - 1)->set_possible_types( |
| 2646 possible_field_types[form_structure->field_count() - 1]); | 2664 possible_field_types[form_structure->field_count() - 1]); |
| 2647 EXPECT_TRUE(form_structure->EncodeUploadRequest(available_field_types, false, | 2665 EXPECT_TRUE(form_structure->EncodeUploadRequest(available_field_types, false, |
| 2648 std::string(), &encoded_xml)); | 2666 std::string(), &encoded_xml)); |
| 2649 EXPECT_EQ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" | 2667 EXPECT_EQ( |
| 2650 "<autofillupload clientversion=\"6.1.1715.1442/en (GGLL)\"" | 2668 "<?xml version=\"1.0\"?>\n" |
| 2651 " formsignature=\"18062476096658145866\" autofillused=\"false\"" | 2669 "<autofillupload clientversion=\"6.1.1715.1442/en (GGLL)\"" |
| 2652 " datapresent=\"1440000360000008\"" | 2670 " formsignature=\"18062476096658145866\" autofillused=\"false\"" |
| 2653 " actionsignature=\"15724779818122431245\">" | 2671 " datapresent=\"1440000360000008\"" |
| 2654 "<field signature=\"420638584\" name=\"email\" type=\"text\"" | 2672 " actionsignature=\"15724779818122431245\">" |
| 2655 " label=\"email\" autofilltype=\"9\"/>" | 2673 "<field signature=\"420638584\" name=\"email\" type=\"text\"" |
| 2656 "<field signature=\"1089846351\" name=\"first\" type=\"text\"" | 2674 " label=\"email\" autofilltype=\"9\"/>" |
| 2657 " label=\"First Name\" autofilltype=\"3\"/>" | 2675 "<field signature=\"1089846351\" name=\"first\" type=\"text\"" |
| 2658 "<field signature=\"2404144663\" name=\"last\" type=\"text\"" | 2676 " label=\"First Name\" autofilltype=\"3\"/>" |
| 2659 " label=\"Last Name\" autofilltype=\"3\"/>" | 2677 "<field signature=\"2404144663\" name=\"last\" type=\"text\"" |
| 2660 "<field signature=\"2404144663\" name=\"last\" type=\"text\"" | 2678 " label=\"Last Name\" autofilltype=\"3\"/>" |
| 2661 " label=\"Last Name\" autofilltype=\"5\"/>" | 2679 "<field signature=\"2404144663\" name=\"last\" type=\"text\"" |
| 2662 "<field signature=\"509334676\" name=\"address\" type=\"text\"" | 2680 " label=\"Last Name\" autofilltype=\"5\"/>" |
| 2663 " label=\"Address\" autofilltype=\"30\"/>" | 2681 "<field signature=\"509334676\" name=\"address\" type=\"text\"" |
| 2664 "<field signature=\"509334676\" name=\"address\" type=\"text\"" | 2682 " label=\"Address\" autofilltype=\"30\"/>" |
| 2665 " label=\"Address\" autofilltype=\"60\"/></autofillupload>", | 2683 "<field signature=\"509334676\" name=\"address\" type=\"text\"" |
| 2666 encoded_xml); | 2684 " label=\"Address\" autofilltype=\"60\"/></autofillupload>\n", |
| 2685 encoded_xml); |
| 2667 } | 2686 } |
| 2668 | 2687 |
| 2669 TEST_F(FormStructureTest, CheckFormSignature) { | 2688 TEST_F(FormStructureTest, CheckFormSignature) { |
| 2670 // Check that form signature is created correctly. | 2689 // Check that form signature is created correctly. |
| 2671 scoped_ptr<FormStructure> form_structure; | 2690 scoped_ptr<FormStructure> form_structure; |
| 2672 FormData form; | 2691 FormData form; |
| 2673 | 2692 |
| 2674 FormFieldData field; | 2693 FormFieldData field; |
| 2675 field.form_control_type = "text"; | 2694 field.form_control_type = "text"; |
| 2676 | 2695 |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2782 field.form_control_type = "text"; | 2801 field.form_control_type = "text"; |
| 2783 field.is_checkable = false; | 2802 field.is_checkable = false; |
| 2784 form.fields.push_back(field); | 2803 form.fields.push_back(field); |
| 2785 | 2804 |
| 2786 ScopedVector<FormStructure> forms; | 2805 ScopedVector<FormStructure> forms; |
| 2787 forms.push_back(new FormStructure(form)); | 2806 forms.push_back(new FormStructure(form)); |
| 2788 std::vector<std::string> encoded_signatures; | 2807 std::vector<std::string> encoded_signatures; |
| 2789 std::string encoded_xml; | 2808 std::string encoded_xml; |
| 2790 | 2809 |
| 2791 const char kSignature[] = "18006745212084723782"; | 2810 const char kSignature[] = "18006745212084723782"; |
| 2792 const char kResponse[] = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" | 2811 const char kResponse[] = |
| 2812 "<?xml version=\"1.0\"?>\n" |
| 2793 "<autofillquery clientversion=\"6.1.1715.1442/en (GGLL)\">" | 2813 "<autofillquery clientversion=\"6.1.1715.1442/en (GGLL)\">" |
| 2794 "<form signature=\"18006745212084723782\">" | 2814 "<form signature=\"18006745212084723782\">" |
| 2795 "<field signature=\"239111655\" name=\"username\" type=\"text\"" | 2815 "<field signature=\"239111655\" name=\"username\" type=\"text\"" |
| 2796 " label=\"username\"/>" | 2816 " label=\"username\"/>" |
| 2797 "<field signature=\"420638584\" name=\"email\" type=\"text\"/>" | 2817 "<field signature=\"420638584\" name=\"email\" type=\"text\"/>" |
| 2798 "</form></autofillquery>"; | 2818 "</form></autofillquery>\n"; |
| 2799 ASSERT_TRUE(FormStructure::EncodeQueryRequest( | 2819 ASSERT_TRUE(FormStructure::EncodeQueryRequest( |
| 2800 forms.get(), &encoded_signatures, &encoded_xml)); | 2820 forms.get(), &encoded_signatures, &encoded_xml)); |
| 2801 ASSERT_EQ(1U, encoded_signatures.size()); | 2821 ASSERT_EQ(1U, encoded_signatures.size()); |
| 2802 EXPECT_EQ(kSignature, encoded_signatures[0]); | 2822 EXPECT_EQ(kSignature, encoded_signatures[0]); |
| 2803 EXPECT_EQ(kResponse, encoded_xml); | 2823 EXPECT_EQ(kResponse, encoded_xml); |
| 2804 } | 2824 } |
| 2805 | 2825 |
| 2806 TEST_F(FormStructureTest, EncodeQueryRequest_WithLabels) { | 2826 TEST_F(FormStructureTest, EncodeQueryRequest_WithLabels) { |
| 2807 FormData form; | 2827 FormData form; |
| 2808 form.name = ASCIIToUTF16("the-name"); | 2828 form.name = ASCIIToUTF16("the-name"); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2823 field.label = ASCIIToUTF16("Enter your Password"); | 2843 field.label = ASCIIToUTF16("Enter your Password"); |
| 2824 field.name = ASCIIToUTF16("password"); | 2844 field.name = ASCIIToUTF16("password"); |
| 2825 field.form_control_type = "password"; | 2845 field.form_control_type = "password"; |
| 2826 form.fields.push_back(field); | 2846 form.fields.push_back(field); |
| 2827 | 2847 |
| 2828 ScopedVector<FormStructure> forms; | 2848 ScopedVector<FormStructure> forms; |
| 2829 forms.push_back(new FormStructure(form)); | 2849 forms.push_back(new FormStructure(form)); |
| 2830 std::vector<std::string> encoded_signatures; | 2850 std::vector<std::string> encoded_signatures; |
| 2831 std::string encoded_xml; | 2851 std::string encoded_xml; |
| 2832 | 2852 |
| 2833 const char kRequest[] = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" | 2853 const char kRequest[] = |
| 2854 "<?xml version=\"1.0\"?>\n" |
| 2834 "<autofillquery clientversion=\"6.1.1715.1442/en (GGLL)\">" | 2855 "<autofillquery clientversion=\"6.1.1715.1442/en (GGLL)\">" |
| 2835 "<form signature=\"13906559713264665730\">" | 2856 "<form signature=\"13906559713264665730\">" |
| 2836 "<field signature=\"239111655\" name=\"username\" type=\"text\"/>" | 2857 "<field signature=\"239111655\" name=\"username\" type=\"text\"/>" |
| 2837 "<field signature=\"420638584\" name=\"email\" type=\"text\"" | 2858 "<field signature=\"420638584\" name=\"email\" type=\"text\"" |
| 2838 " label=\"Enter your Email address\"/>" | 2859 " label=\"Enter your Email address\"/>" |
| 2839 "<field signature=\"2051817934\" name=\"password\" type=\"password\"" | 2860 "<field signature=\"2051817934\" name=\"password\" type=\"password\"" |
| 2840 " label=\"Enter your Password\"/></form></autofillquery>"; | 2861 " label=\"Enter your Password\"/></form></autofillquery>\n"; |
| 2841 EXPECT_TRUE(FormStructure::EncodeQueryRequest( | 2862 EXPECT_TRUE(FormStructure::EncodeQueryRequest( |
| 2842 forms.get(), &encoded_signatures, &encoded_xml)); | 2863 forms.get(), &encoded_signatures, &encoded_xml)); |
| 2843 EXPECT_EQ(kRequest, encoded_xml); | 2864 EXPECT_EQ(kRequest, encoded_xml); |
| 2844 } | 2865 } |
| 2845 | 2866 |
| 2846 TEST_F(FormStructureTest, EncodeQueryRequest_WithLongLabels) { | 2867 TEST_F(FormStructureTest, EncodeQueryRequest_WithLongLabels) { |
| 2847 FormData form; | 2868 FormData form; |
| 2848 form.name = ASCIIToUTF16("the-name"); | 2869 form.name = ASCIIToUTF16("the-name"); |
| 2849 form.origin = GURL("http://cool.com"); | 2870 form.origin = GURL("http://cool.com"); |
| 2850 form.action = form.origin.Resolve("/login"); | 2871 form.action = form.origin.Resolve("/login"); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 2869 field.name = ASCIIToUTF16("password"); | 2890 field.name = ASCIIToUTF16("password"); |
| 2870 field.form_control_type = "password"; | 2891 field.form_control_type = "password"; |
| 2871 form.fields.push_back(field); | 2892 form.fields.push_back(field); |
| 2872 | 2893 |
| 2873 ScopedVector<FormStructure> forms; | 2894 ScopedVector<FormStructure> forms; |
| 2874 forms.push_back(new FormStructure(form)); | 2895 forms.push_back(new FormStructure(form)); |
| 2875 std::vector<std::string> encoded_signatures; | 2896 std::vector<std::string> encoded_signatures; |
| 2876 std::string encoded_xml; | 2897 std::string encoded_xml; |
| 2877 | 2898 |
| 2878 const char kRequest[] = | 2899 const char kRequest[] = |
| 2879 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" | 2900 "<?xml version=\"1.0\"?>\n" |
| 2880 "<autofillquery clientversion=\"6.1.1715.1442/en (GGLL)\">" | 2901 "<autofillquery clientversion=\"6.1.1715.1442/en (GGLL)\">" |
| 2881 "<form signature=\"13906559713264665730\">" | 2902 "<form signature=\"13906559713264665730\">" |
| 2882 "<field signature=\"239111655\" name=\"username\" type=\"text\"/>" | 2903 "<field signature=\"239111655\" name=\"username\" type=\"text\"/>" |
| 2883 "<field signature=\"420638584\" name=\"email\" type=\"text\"" | 2904 "<field signature=\"420638584\" name=\"email\" type=\"text\"" |
| 2884 " label=\"Enter Your Really Really Really (Really!) Long Email Address" | 2905 " label=\"Enter Your Really Really Really (Really!) Long Email Address" |
| 2885 " Which We Hope To Get In Order To Send You Unwanted Publicity Because" | 2906 " Which We Hope To Get In Order To Send You Unwanted Publicity Because" |
| 2886 " That's What Marketers Do! We Know That Your Email Address Has The" | 2907 " That's What Marketers Do! We Know That Your Email Address Has The" |
| 2887 " Poss\"/>" | 2908 " Poss\"/>" |
| 2888 "<field signature=\"2051817934\" name=\"password\" type=\"password\"" | 2909 "<field signature=\"2051817934\" name=\"password\" type=\"password\"" |
| 2889 " label=\"Enter your Password\"/></form></autofillquery>"; | 2910 " label=\"Enter your Password\"/></form></autofillquery>\n"; |
| 2890 EXPECT_TRUE(FormStructure::EncodeQueryRequest( | 2911 EXPECT_TRUE(FormStructure::EncodeQueryRequest( |
| 2891 forms.get(), &encoded_signatures, &encoded_xml)); | 2912 forms.get(), &encoded_signatures, &encoded_xml)); |
| 2892 EXPECT_EQ(kRequest, encoded_xml); | 2913 EXPECT_EQ(kRequest, encoded_xml); |
| 2893 } | 2914 } |
| 2894 | 2915 |
| 2895 // One name is missing from one field. | 2916 // One name is missing from one field. |
| 2896 TEST_F(FormStructureTest, EncodeQueryRequest_MissingNames) { | 2917 TEST_F(FormStructureTest, EncodeQueryRequest_MissingNames) { |
| 2897 FormData form; | 2918 FormData form; |
| 2898 // No name set for the form. | 2919 // No name set for the form. |
| 2899 form.origin = GURL("http://cool.com"); | 2920 form.origin = GURL("http://cool.com"); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2911 field.form_control_type = "text"; | 2932 field.form_control_type = "text"; |
| 2912 field.is_checkable = false; | 2933 field.is_checkable = false; |
| 2913 form.fields.push_back(field); | 2934 form.fields.push_back(field); |
| 2914 | 2935 |
| 2915 ScopedVector<FormStructure> forms; | 2936 ScopedVector<FormStructure> forms; |
| 2916 forms.push_back(new FormStructure(form)); | 2937 forms.push_back(new FormStructure(form)); |
| 2917 std::vector<std::string> encoded_signatures; | 2938 std::vector<std::string> encoded_signatures; |
| 2918 std::string encoded_xml; | 2939 std::string encoded_xml; |
| 2919 | 2940 |
| 2920 const char kSignature[] = "16416961345885087496"; | 2941 const char kSignature[] = "16416961345885087496"; |
| 2921 const char kResponse[] = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" | 2942 const char kResponse[] = |
| 2943 "<?xml version=\"1.0\"?>\n" |
| 2922 "<autofillquery clientversion=\"6.1.1715.1442/en (GGLL)\">" | 2944 "<autofillquery clientversion=\"6.1.1715.1442/en (GGLL)\">" |
| 2923 "<form signature=\"16416961345885087496\">" | 2945 "<form signature=\"16416961345885087496\">" |
| 2924 "<field signature=\"239111655\" name=\"username\" type=\"text\"" | 2946 "<field signature=\"239111655\" name=\"username\" type=\"text\"" |
| 2925 " label=\"username\"/><field signature=\"1318412689\" type=\"text\"/>" | 2947 " label=\"username\"/><field signature=\"1318412689\" type=\"text\"/>" |
| 2926 "</form></autofillquery>"; | 2948 "</form></autofillquery>\n"; |
| 2927 ASSERT_TRUE(FormStructure::EncodeQueryRequest( | 2949 ASSERT_TRUE(FormStructure::EncodeQueryRequest( |
| 2928 forms.get(), &encoded_signatures, &encoded_xml)); | 2950 forms.get(), &encoded_signatures, &encoded_xml)); |
| 2929 ASSERT_EQ(1U, encoded_signatures.size()); | 2951 ASSERT_EQ(1U, encoded_signatures.size()); |
| 2930 EXPECT_EQ(kSignature, encoded_signatures[0]); | 2952 EXPECT_EQ(kSignature, encoded_signatures[0]); |
| 2931 EXPECT_EQ(kResponse, encoded_xml); | 2953 EXPECT_EQ(kResponse, encoded_xml); |
| 2932 } | 2954 } |
| 2933 | 2955 |
| 2934 // Sending field metadata to the server is disabled. | 2956 // Sending field metadata to the server is disabled. |
| 2935 TEST_F(FormStructureTest, EncodeQueryRequest_DisabledMetadataTrial) { | 2957 TEST_F(FormStructureTest, EncodeQueryRequest_DisabledMetadataTrial) { |
| 2936 DisableAutofillMetadataFieldTrial(); | 2958 DisableAutofillMetadataFieldTrial(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2951 field.form_control_type = "text"; | 2973 field.form_control_type = "text"; |
| 2952 field.is_checkable = false; | 2974 field.is_checkable = false; |
| 2953 form.fields.push_back(field); | 2975 form.fields.push_back(field); |
| 2954 | 2976 |
| 2955 ScopedVector<FormStructure> forms; | 2977 ScopedVector<FormStructure> forms; |
| 2956 forms.push_back(new FormStructure(form)); | 2978 forms.push_back(new FormStructure(form)); |
| 2957 std::vector<std::string> encoded_signatures; | 2979 std::vector<std::string> encoded_signatures; |
| 2958 std::string encoded_xml; | 2980 std::string encoded_xml; |
| 2959 | 2981 |
| 2960 const char kSignature[] = "7635954436925888745"; | 2982 const char kSignature[] = "7635954436925888745"; |
| 2961 const char kResponse[] = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" | 2983 const char kResponse[] = |
| 2984 "<?xml version=\"1.0\"?>\n" |
| 2962 "<autofillquery clientversion=\"6.1.1715.1442/en (GGLL)\">" | 2985 "<autofillquery clientversion=\"6.1.1715.1442/en (GGLL)\">" |
| 2963 "<form signature=\"7635954436925888745\">" | 2986 "<form signature=\"7635954436925888745\">" |
| 2964 "<field signature=\"239111655\"/>" | 2987 "<field signature=\"239111655\"/>" |
| 2965 "<field signature=\"3654076265\"/>" | 2988 "<field signature=\"3654076265\"/>" |
| 2966 "</form></autofillquery>"; | 2989 "</form></autofillquery>\n"; |
| 2967 ASSERT_TRUE(FormStructure::EncodeQueryRequest( | 2990 ASSERT_TRUE(FormStructure::EncodeQueryRequest( |
| 2968 forms.get(), &encoded_signatures, &encoded_xml)); | 2991 forms.get(), &encoded_signatures, &encoded_xml)); |
| 2969 ASSERT_EQ(1U, encoded_signatures.size()); | 2992 ASSERT_EQ(1U, encoded_signatures.size()); |
| 2970 EXPECT_EQ(kSignature, encoded_signatures[0]); | 2993 EXPECT_EQ(kSignature, encoded_signatures[0]); |
| 2971 EXPECT_EQ(kResponse, encoded_xml); | 2994 EXPECT_EQ(kResponse, encoded_xml); |
| 2972 } | 2995 } |
| 2973 | 2996 |
| 2974 TEST_F(FormStructureTest, PossibleValues) { | 2997 TEST_F(FormStructureTest, PossibleValues) { |
| 2975 FormData form_data; | 2998 FormData form_data; |
| 2976 FormFieldData field; | 2999 FormFieldData field; |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3092 "</autofillqueryresponse>"; | 3115 "</autofillqueryresponse>"; |
| 3093 | 3116 |
| 3094 FormStructure::ParseQueryResponse(response, forms.get(), nullptr); | 3117 FormStructure::ParseQueryResponse(response, forms.get(), nullptr); |
| 3095 | 3118 |
| 3096 ASSERT_GE(forms[0]->field_count(), 2U); | 3119 ASSERT_GE(forms[0]->field_count(), 2U); |
| 3097 EXPECT_EQ(NO_SERVER_DATA, forms[0]->field(0)->server_type()); | 3120 EXPECT_EQ(NO_SERVER_DATA, forms[0]->field(0)->server_type()); |
| 3098 EXPECT_EQ(76, forms[0]->field(1)->server_type()); | 3121 EXPECT_EQ(76, forms[0]->field(1)->server_type()); |
| 3099 } | 3122 } |
| 3100 | 3123 |
| 3101 } // namespace autofill | 3124 } // namespace autofill |
| OLD | NEW |