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

Side by Side Diff: chrome/browser/autofill/form_structure_unittest.cc

Issue 6213002: Propagate correct data to the Toolbar servers (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/scoped_ptr.h" 5 #include "base/scoped_ptr.h"
6 #include "base/string_util.h" 6 #include "base/string_util.h"
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/autofill/form_structure.h" 8 #include "chrome/browser/autofill/form_structure.h"
9 #include "googleurl/src/gurl.h" 9 #include "googleurl/src/gurl.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 1653 matching lines...) Expand 10 before | Expand all | Expand 10 after
1664 ASCIIToUTF16("radio"), 1664 ASCIIToUTF16("radio"),
1665 0, 1665 0,
1666 false)); 1666 false));
1667 possible_field_types.push_back(FieldTypeSet()); 1667 possible_field_types.push_back(FieldTypeSet());
1668 possible_field_types.back().insert(ADDRESS_HOME_LINE1); 1668 possible_field_types.back().insert(ADDRESS_HOME_LINE1);
1669 form_structure.reset(new FormStructure(form)); 1669 form_structure.reset(new FormStructure(form));
1670 std::string encoded_xml; 1670 std::string encoded_xml;
1671 ASSERT_EQ(form_structure->field_count(), possible_field_types.size()); 1671 ASSERT_EQ(form_structure->field_count(), possible_field_types.size());
1672 for (size_t i = 0; i < form_structure->field_count(); ++i) 1672 for (size_t i = 0; i < form_structure->field_count(); ++i)
1673 form_structure->set_possible_types(i, possible_field_types[i]); 1673 form_structure->set_possible_types(i, possible_field_types[i]);
1674 EXPECT_TRUE(form_structure->EncodeUploadRequest(false, &encoded_xml)); 1674 EXPECT_TRUE(form_structure->EncodeUploadRequest(false, "", &encoded_xml));
1675 EXPECT_EQ(encoded_xml, 1675 EXPECT_EQ(encoded_xml,
1676 "<\?xml version=\"1.0\" encoding=\"UTF-8\"\?><autofillupload " 1676 "<\?xml version=\"1.0\" encoding=\"UTF-8\"\?><autofillupload "
1677 "clientversion=\"6.1.1715.1442/en (GGLL)\" formsignature=\"" 1677 "clientversion=\"6.1.1715.1442/en (GGLL)\" formsignature=\""
1678 "8269229441054798720\" autofillused=\"false\" datapresent=\"\"><field " 1678 "8269229441054798720\" autofillused=\"false\" datapresent=\"\"><field "
1679 "signature=\"3763331450\" autofilltype=\"3\"/><field signature=\"" 1679 "signature=\"3763331450\" autofilltype=\"3\"/><field signature=\""
1680 "3494530716\" autofilltype=\"5\"/><field signature=\"1029417091\" " 1680 "3494530716\" autofilltype=\"5\"/><field signature=\"1029417091\" "
1681 "autofilltype=\"9\"/><field signature=\"466116101\" autofilltype=" 1681 "autofilltype=\"9\"/><field signature=\"466116101\" autofilltype="
1682 "\"14\"/><field signature=\"2799270304\" autofilltype=\"36\"/><field " 1682 "\"14\"/><field signature=\"2799270304\" autofilltype=\"36\"/><field "
1683 "signature=\"1876771436\" autofilltype=\"24\"/><field signature=" 1683 "signature=\"1876771436\" autofilltype=\"24\"/><field signature="
1684 "\"263446779\" autofilltype=\"30\"/></autofillupload>"); 1684 "\"263446779\" autofilltype=\"30\"/></autofillupload>");
1685 EXPECT_TRUE(form_structure->EncodeUploadRequest(true, &encoded_xml)); 1685 EXPECT_TRUE(form_structure->EncodeUploadRequest(true, "af11", &encoded_xml));
1686 EXPECT_EQ(encoded_xml, 1686 EXPECT_EQ(encoded_xml,
1687 "<\?xml version=\"1.0\" encoding=\"UTF-8\"\?><autofillupload " 1687 "<\?xml version=\"1.0\" encoding=\"UTF-8\"\?><autofillupload "
1688 "clientversion=\"6.1.1715.1442/en (GGLL)\" formsignature=\"" 1688 "clientversion=\"6.1.1715.1442/en (GGLL)\" formsignature=\""
1689 "8269229441054798720\" autofillused=\"true\" datapresent=\"\"><field " 1689 "8269229441054798720\" autofillused=\"true\" datapresent=\"af11\"><field "
1690 "signature=\"3763331450\" autofilltype=\"3\"/><field signature=\"" 1690 "signature=\"3763331450\" autofilltype=\"3\"/><field signature=\""
1691 "3494530716\" autofilltype=\"5\"/><field signature=\"1029417091\" " 1691 "3494530716\" autofilltype=\"5\"/><field signature=\"1029417091\" "
1692 "autofilltype=\"9\"/><field signature=\"466116101\" autofilltype=" 1692 "autofilltype=\"9\"/><field signature=\"466116101\" autofilltype="
1693 "\"14\"/><field signature=\"2799270304\" autofilltype=\"36\"/><field " 1693 "\"14\"/><field signature=\"2799270304\" autofilltype=\"36\"/><field "
1694 "signature=\"1876771436\" autofilltype=\"24\"/><field signature=" 1694 "signature=\"1876771436\" autofilltype=\"24\"/><field signature="
1695 "\"263446779\" autofilltype=\"30\"/></autofillupload>"); 1695 "\"263446779\" autofilltype=\"30\"/></autofillupload>");
1696 // Add 5 address fields - this should be still a valid form. 1696 // Add 5 address fields - this should be still a valid form.
1697 for (size_t i = 0; i < 5; ++i) { 1697 for (size_t i = 0; i < 5; ++i) {
1698 form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Address"), 1698 form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Address"),
1699 ASCIIToUTF16("address"), 1699 ASCIIToUTF16("address"),
1700 string16(), 1700 string16(),
1701 ASCIIToUTF16("text"), 1701 ASCIIToUTF16("text"),
1702 0, 1702 0,
1703 false)); 1703 false));
1704 possible_field_types.push_back(FieldTypeSet()); 1704 possible_field_types.push_back(FieldTypeSet());
1705 possible_field_types.back().insert(ADDRESS_HOME_LINE1); 1705 possible_field_types.back().insert(ADDRESS_HOME_LINE1);
1706 possible_field_types.back().insert(ADDRESS_HOME_LINE2); 1706 possible_field_types.back().insert(ADDRESS_HOME_LINE2);
1707 possible_field_types.back().insert(ADDRESS_BILLING_LINE1); 1707 possible_field_types.back().insert(ADDRESS_BILLING_LINE1);
1708 possible_field_types.back().insert(ADDRESS_BILLING_LINE2); 1708 possible_field_types.back().insert(ADDRESS_BILLING_LINE2);
1709 } 1709 }
1710 form_structure.reset(new FormStructure(form)); 1710 form_structure.reset(new FormStructure(form));
1711 ASSERT_EQ(form_structure->field_count(), possible_field_types.size()); 1711 ASSERT_EQ(form_structure->field_count(), possible_field_types.size());
1712 for (size_t i = 0; i < form_structure->field_count(); ++i) 1712 for (size_t i = 0; i < form_structure->field_count(); ++i)
1713 form_structure->set_possible_types(i, possible_field_types[i]); 1713 form_structure->set_possible_types(i, possible_field_types[i]);
1714 EXPECT_TRUE(form_structure->EncodeUploadRequest(false, &encoded_xml)); 1714 EXPECT_TRUE(form_structure->EncodeUploadRequest(false, "", &encoded_xml));
1715 EXPECT_EQ(encoded_xml, 1715 EXPECT_EQ(encoded_xml,
1716 "<\?xml version=\"1.0\" encoding=\"UTF-8\"\?><autofillupload " 1716 "<\?xml version=\"1.0\" encoding=\"UTF-8\"\?><autofillupload "
1717 "clientversion=\"6.1.1715.1442/en (GGLL)\" formsignature=\"" 1717 "clientversion=\"6.1.1715.1442/en (GGLL)\" formsignature=\""
1718 "2027360543766157144\" autofillused=\"false\" datapresent=\"\"><field " 1718 "2027360543766157144\" autofillused=\"false\" datapresent=\"\"><field "
1719 "signature=\"3763331450\" autofilltype=\"3\"/><field signature=\"" 1719 "signature=\"3763331450\" autofilltype=\"3\"/><field signature=\""
1720 "3494530716\" autofilltype=\"5\"/><field signature=\"1029417091\" " 1720 "3494530716\" autofilltype=\"5\"/><field signature=\"1029417091\" "
1721 "autofilltype=\"9\"/><field signature=\"466116101\" autofilltype=\"14\"/>" 1721 "autofilltype=\"9\"/><field signature=\"466116101\" autofilltype=\"14\"/>"
1722 "<field signature=\"2799270304\" autofilltype=\"36\"/><field signature=\"" 1722 "<field signature=\"2799270304\" autofilltype=\"36\"/><field signature=\""
1723 "1876771436\" autofilltype=\"24\"/><field signature=\"263446779\" " 1723 "1876771436\" autofilltype=\"24\"/><field signature=\"263446779\" "
1724 "autofilltype=\"30\"/><field signature=\"509334676\" autofilltype=" 1724 "autofilltype=\"30\"/><field signature=\"509334676\" autofilltype="
(...skipping 24 matching lines...) Expand all
1749 possible_field_types.push_back(FieldTypeSet()); 1749 possible_field_types.push_back(FieldTypeSet());
1750 possible_field_types.back().insert(ADDRESS_HOME_LINE1); 1750 possible_field_types.back().insert(ADDRESS_HOME_LINE1);
1751 possible_field_types.back().insert(ADDRESS_HOME_LINE2); 1751 possible_field_types.back().insert(ADDRESS_HOME_LINE2);
1752 possible_field_types.back().insert(ADDRESS_BILLING_LINE1); 1752 possible_field_types.back().insert(ADDRESS_BILLING_LINE1);
1753 possible_field_types.back().insert(ADDRESS_BILLING_LINE2); 1753 possible_field_types.back().insert(ADDRESS_BILLING_LINE2);
1754 } 1754 }
1755 form_structure.reset(new FormStructure(form)); 1755 form_structure.reset(new FormStructure(form));
1756 ASSERT_EQ(form_structure->field_count(), possible_field_types.size()); 1756 ASSERT_EQ(form_structure->field_count(), possible_field_types.size());
1757 for (size_t i = 0; i < form_structure->field_count(); ++i) 1757 for (size_t i = 0; i < form_structure->field_count(); ++i)
1758 form_structure->set_possible_types(i, possible_field_types[i]); 1758 form_structure->set_possible_types(i, possible_field_types[i]);
1759 EXPECT_FALSE(form_structure->EncodeUploadRequest(false, &encoded_xml)); 1759 EXPECT_FALSE(form_structure->EncodeUploadRequest(false, "", &encoded_xml));
1760 EXPECT_EQ(encoded_xml, ""); 1760 EXPECT_EQ(encoded_xml, "");
1761 } 1761 }
1762 1762
1763 } // namespace 1763 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698