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

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

Issue 6673079: Reduce boxing and unboxing of AutofillFieldType (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 9 years, 9 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <vector> 5 #include <vector>
6 6
7 #include "base/ref_counted.h" 7 #include "base/ref_counted.h"
8 #include "base/scoped_ptr.h" 8 #include "base/scoped_ptr.h"
9 #include "base/scoped_vector.h" 9 #include "base/scoped_vector.h"
10 #include "base/string16.h" 10 #include "base/string16.h"
(...skipping 1654 matching lines...) Expand 10 before | Expand all | Expand 10 after
1665 "Phone Extension", "ext", "", "text", &field); 1665 "Phone Extension", "ext", "", "text", &field);
1666 field.max_length = 3; 1666 field.max_length = 3;
1667 form.fields.push_back(field); 1667 form.fields.push_back(field);
1668 1668
1669 std::vector<FormData> forms(1, form); 1669 std::vector<FormData> forms(1, form);
1670 FormsSeen(forms); 1670 FormsSeen(forms);
1671 1671
1672 AutofillProfile *work_profile = autofill_manager_->GetProfileWithGUID( 1672 AutofillProfile *work_profile = autofill_manager_->GetProfileWithGUID(
1673 "00000000-0000-0000-0000-000000000002"); 1673 "00000000-0000-0000-0000-000000000002");
1674 ASSERT_TRUE(work_profile != NULL); 1674 ASSERT_TRUE(work_profile != NULL);
1675 const AutofillType phone_type(PHONE_HOME_NUMBER); 1675 string16 saved_phone = work_profile->GetFieldText(PHONE_HOME_NUMBER);
1676 string16 saved_phone = work_profile->GetFieldText(phone_type);
1677 1676
1678 char test_data[] = "1234567890123456"; 1677 char test_data[] = "1234567890123456";
1679 for (int i = arraysize(test_data) - 1; i >= 0; --i) { 1678 for (int i = arraysize(test_data) - 1; i >= 0; --i) {
1680 test_data[i] = 0; 1679 test_data[i] = 0;
1681 SCOPED_TRACE(StringPrintf("Testing phone: %s", test_data)); 1680 SCOPED_TRACE(StringPrintf("Testing phone: %s", test_data));
1682 work_profile->SetInfo(phone_type, ASCIIToUTF16(test_data)); 1681 work_profile->SetInfo(PHONE_HOME_NUMBER, ASCIIToUTF16(test_data));
1683 // The page ID sent to the AutofillManager from the RenderView, used to send 1682 // The page ID sent to the AutofillManager from the RenderView, used to send
1684 // an IPC message back to the renderer. 1683 // an IPC message back to the renderer.
1685 int page_id = 100 - i; 1684 int page_id = 100 - i;
1686 FillAutoFillFormData( 1685 FillAutoFillFormData(
1687 page_id, form, *form.fields.begin(), 1686 page_id, form, *form.fields.begin(),
1688 autofill_manager_->PackGUIDs(std::string(), work_profile->guid())); 1687 autofill_manager_->PackGUIDs(std::string(), work_profile->guid()));
1689 page_id = 0; 1688 page_id = 0;
1690 FormData results; 1689 FormData results;
1691 EXPECT_TRUE(GetAutoFillFormDataFilledMessage(&page_id, &results)); 1690 EXPECT_TRUE(GetAutoFillFormDataFilledMessage(&page_id, &results));
1692 1691
1693 if (i != 7) { 1692 if (i != 7) {
1694 EXPECT_EQ(ASCIIToUTF16(test_data), results.fields[2].value); 1693 EXPECT_EQ(ASCIIToUTF16(test_data), results.fields[2].value);
1695 EXPECT_EQ(ASCIIToUTF16(test_data), results.fields[3].value); 1694 EXPECT_EQ(ASCIIToUTF16(test_data), results.fields[3].value);
1696 } else { 1695 } else {
1697 // The only size that is parsed and split, right now is 7: 1696 // The only size that is parsed and split, right now is 7:
1698 EXPECT_EQ(ASCIIToUTF16("123"), results.fields[2].value); 1697 EXPECT_EQ(ASCIIToUTF16("123"), results.fields[2].value);
1699 EXPECT_EQ(ASCIIToUTF16("4567"), results.fields[3].value); 1698 EXPECT_EQ(ASCIIToUTF16("4567"), results.fields[3].value);
1700 } 1699 }
1701 } 1700 }
1702 1701
1703 work_profile->SetInfo(phone_type, saved_phone); 1702 work_profile->SetInfo(PHONE_HOME_NUMBER, saved_phone);
1704 } 1703 }
1705 1704
1706 // Test that we can still fill a form when a field has been removed from it. 1705 // Test that we can still fill a form when a field has been removed from it.
1707 TEST_F(AutofillManagerTest, FormChangesRemoveField) { 1706 TEST_F(AutofillManagerTest, FormChangesRemoveField) {
1708 // Set up our form data. 1707 // Set up our form data.
1709 FormData form; 1708 FormData form;
1710 CreateTestAddressFormData(&form); 1709 CreateTestAddressFormData(&form);
1711 1710
1712 // Add a field -- we'll remove it again later. 1711 // Add a field -- we'll remove it again later.
1713 FormField field; 1712 FormField field;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1778 #else 1777 #else
1779 ASSERT_FALSE(profile()->GetPrefs()->GetBoolean( 1778 ASSERT_FALSE(profile()->GetPrefs()->GetBoolean(
1780 prefs::kAutoFillAuxiliaryProfilesEnabled)); 1779 prefs::kAutoFillAuxiliaryProfilesEnabled));
1781 profile()->GetPrefs()->SetBoolean( 1780 profile()->GetPrefs()->SetBoolean(
1782 prefs::kAutoFillAuxiliaryProfilesEnabled, true); 1781 prefs::kAutoFillAuxiliaryProfilesEnabled, true);
1783 profile()->GetPrefs()->ClearPref(prefs::kAutoFillAuxiliaryProfilesEnabled); 1782 profile()->GetPrefs()->ClearPref(prefs::kAutoFillAuxiliaryProfilesEnabled);
1784 ASSERT_FALSE(profile()->GetPrefs()->GetBoolean( 1783 ASSERT_FALSE(profile()->GetPrefs()->GetBoolean(
1785 prefs::kAutoFillAuxiliaryProfilesEnabled)); 1784 prefs::kAutoFillAuxiliaryProfilesEnabled));
1786 #endif 1785 #endif
1787 } 1786 }
OLDNEW
« no previous file with comments | « chrome/browser/autofill/autofill_manager.cc ('k') | chrome/browser/autofill/autofill_merge_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698