OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
10 #include "base/string16.h" | 10 #include "base/string16.h" |
(...skipping 1861 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1872 "Phone Extension", "ext", "", "text", &field); | 1872 "Phone Extension", "ext", "", "text", &field); |
1873 field.max_length = 3; | 1873 field.max_length = 3; |
1874 form.fields.push_back(field); | 1874 form.fields.push_back(field); |
1875 | 1875 |
1876 std::vector<FormData> forms(1, form); | 1876 std::vector<FormData> forms(1, form); |
1877 FormsSeen(forms); | 1877 FormsSeen(forms); |
1878 | 1878 |
1879 AutofillProfile *work_profile = autofill_manager_->GetProfileWithGUID( | 1879 AutofillProfile *work_profile = autofill_manager_->GetProfileWithGUID( |
1880 "00000000-0000-0000-0000-000000000002"); | 1880 "00000000-0000-0000-0000-000000000002"); |
1881 ASSERT_TRUE(work_profile != NULL); | 1881 ASSERT_TRUE(work_profile != NULL); |
1882 string16 saved_phone = work_profile->GetInfo(PHONE_HOME_NUMBER); | 1882 string16 saved_phone = work_profile->GetInfo(PHONE_HOME_WHOLE_NUMBER); |
dhollowa
2011/05/13 18:55:35
It looks like this |save_phone| is unneeded. It i
GeorgeY
2011/05/18 17:41:45
Done.
| |
1883 | 1883 |
1884 GUIDPair guid(work_profile->guid(), 0); | 1884 GUIDPair guid(work_profile->guid(), 0); |
1885 GUIDPair empty(std::string(), 0); | 1885 GUIDPair empty(std::string(), 0); |
1886 | 1886 |
1887 char test_data[] = "1234567890123456"; | 1887 char test_data[] = "16505554567890123456"; |
1888 for (int i = arraysize(test_data) - 1; i >= 0; --i) { | 1888 for (int i = arraysize(test_data) - 1; i >= 0; --i) { |
1889 test_data[i] = 0; | 1889 test_data[i] = 0; |
1890 SCOPED_TRACE(StringPrintf("Testing phone: %s", test_data)); | 1890 SCOPED_TRACE(StringPrintf("Testing phone: %s", test_data)); |
1891 work_profile->SetInfo(PHONE_HOME_NUMBER, ASCIIToUTF16(test_data)); | 1891 work_profile->SetInfo(PHONE_HOME_WHOLE_NUMBER, ASCIIToUTF16(test_data)); |
1892 // The page ID sent to the AutofillManager from the RenderView, used to send | 1892 // The page ID sent to the AutofillManager from the RenderView, used to send |
1893 // an IPC message back to the renderer. | 1893 // an IPC message back to the renderer. |
1894 int page_id = 100 - i; | 1894 int page_id = 100 - i; |
1895 FillAutofillFormData( | 1895 FillAutofillFormData( |
1896 page_id, form, *form.fields.begin(), | 1896 page_id, form, *form.fields.begin(), |
1897 autofill_manager_->PackGUIDs(empty, guid)); | 1897 autofill_manager_->PackGUIDs(empty, guid)); |
1898 page_id = 0; | 1898 page_id = 0; |
1899 FormData results; | 1899 FormData results; |
1900 EXPECT_TRUE(GetAutofillFormDataFilledMessage(&page_id, &results)); | 1900 EXPECT_TRUE(GetAutofillFormDataFilledMessage(&page_id, &results)); |
1901 | 1901 |
1902 if (i != 7) { | 1902 if (i != 11) { |
1903 EXPECT_EQ(ASCIIToUTF16(test_data), results.fields[2].value); | 1903 // The only parsable phone is 16505554567. |
1904 EXPECT_EQ(ASCIIToUTF16(test_data), results.fields[3].value); | 1904 EXPECT_EQ(string16(), results.fields[2].value); |
1905 EXPECT_EQ(string16(), results.fields[3].value); | |
1905 } else { | 1906 } else { |
1906 // The only size that is parsed and split, right now is 7: | 1907 EXPECT_EQ(ASCIIToUTF16("555"), results.fields[2].value); |
1907 EXPECT_EQ(ASCIIToUTF16("123"), results.fields[2].value); | |
1908 EXPECT_EQ(ASCIIToUTF16("4567"), results.fields[3].value); | 1908 EXPECT_EQ(ASCIIToUTF16("4567"), results.fields[3].value); |
1909 } | 1909 } |
1910 } | 1910 } |
1911 | 1911 |
1912 work_profile->SetInfo(PHONE_HOME_NUMBER, saved_phone); | 1912 work_profile->SetInfo(PHONE_HOME_WHOLE_NUMBER, saved_phone); |
1913 } | 1913 } |
1914 | 1914 |
1915 // Test that we can still fill a form when a field has been removed from it. | 1915 // Test that we can still fill a form when a field has been removed from it. |
1916 TEST_F(AutofillManagerTest, FormChangesRemoveField) { | 1916 TEST_F(AutofillManagerTest, FormChangesRemoveField) { |
1917 // Set up our form data. | 1917 // Set up our form data. |
1918 FormData form; | 1918 FormData form; |
1919 CreateTestAddressFormData(&form); | 1919 CreateTestAddressFormData(&form); |
1920 | 1920 |
1921 // Add a field -- we'll remove it again later. | 1921 // Add a field -- we'll remove it again later. |
1922 FormField field; | 1922 FormField field; |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2052 #else | 2052 #else |
2053 ASSERT_FALSE(profile()->GetPrefs()->GetBoolean( | 2053 ASSERT_FALSE(profile()->GetPrefs()->GetBoolean( |
2054 prefs::kAutofillAuxiliaryProfilesEnabled)); | 2054 prefs::kAutofillAuxiliaryProfilesEnabled)); |
2055 profile()->GetPrefs()->SetBoolean( | 2055 profile()->GetPrefs()->SetBoolean( |
2056 prefs::kAutofillAuxiliaryProfilesEnabled, true); | 2056 prefs::kAutofillAuxiliaryProfilesEnabled, true); |
2057 profile()->GetPrefs()->ClearPref(prefs::kAutofillAuxiliaryProfilesEnabled); | 2057 profile()->GetPrefs()->ClearPref(prefs::kAutofillAuxiliaryProfilesEnabled); |
2058 ASSERT_FALSE(profile()->GetPrefs()->GetBoolean( | 2058 ASSERT_FALSE(profile()->GetPrefs()->GetBoolean( |
2059 prefs::kAutofillAuxiliaryProfilesEnabled)); | 2059 prefs::kAutofillAuxiliaryProfilesEnabled)); |
2060 #endif | 2060 #endif |
2061 } | 2061 } |
OLD | NEW |