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

Side by Side Diff: components/autofill/core/browser/autofill_manager_unittest.cc

Issue 365783002: Autofill: don't require POST method. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove method_ member Created 6 years, 5 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 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 <algorithm> 5 #include <algorithm>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 DISALLOW_COPY_AND_ASSIGN(TestPersonalDataManager); 181 DISALLOW_COPY_AND_ASSIGN(TestPersonalDataManager);
182 }; 182 };
183 183
184 // Populates |form| with data corresponding to a simple credit card form. 184 // Populates |form| with data corresponding to a simple credit card form.
185 // Note that this actually appends fields to the form data, which can be useful 185 // Note that this actually appends fields to the form data, which can be useful
186 // for building up more complex test forms. 186 // for building up more complex test forms.
187 void CreateTestCreditCardFormData(FormData* form, 187 void CreateTestCreditCardFormData(FormData* form,
188 bool is_https, 188 bool is_https,
189 bool use_month_type) { 189 bool use_month_type) {
190 form->name = ASCIIToUTF16("MyForm"); 190 form->name = ASCIIToUTF16("MyForm");
191 form->method = ASCIIToUTF16("POST");
192 if (is_https) { 191 if (is_https) {
193 form->origin = GURL("https://myform.com/form.html"); 192 form->origin = GURL("https://myform.com/form.html");
194 form->action = GURL("https://myform.com/submit.html"); 193 form->action = GURL("https://myform.com/submit.html");
195 } else { 194 } else {
196 form->origin = GURL("http://myform.com/form.html"); 195 form->origin = GURL("http://myform.com/form.html");
197 form->action = GURL("http://myform.com/submit.html"); 196 form->action = GURL("http://myform.com/submit.html");
198 } 197 }
199 form->user_submitted = true; 198 form->user_submitted = true;
200 199
201 FormFieldData field; 200 FormFieldData field;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 const char* expiration_year, 250 const char* expiration_year,
252 bool has_address_fields, 251 bool has_address_fields,
253 bool has_credit_card_fields, 252 bool has_credit_card_fields,
254 bool use_month_type) { 253 bool use_month_type) {
255 // The number of fields in the address and credit card forms created above. 254 // The number of fields in the address and credit card forms created above.
256 const size_t kAddressFormSize = 11; 255 const size_t kAddressFormSize = 11;
257 const size_t kCreditCardFormSize = use_month_type ? 3 : 4; 256 const size_t kCreditCardFormSize = use_month_type ? 3 : 4;
258 257
259 EXPECT_EQ(expected_page_id, page_id); 258 EXPECT_EQ(expected_page_id, page_id);
260 EXPECT_EQ(ASCIIToUTF16("MyForm"), filled_form.name); 259 EXPECT_EQ(ASCIIToUTF16("MyForm"), filled_form.name);
261 EXPECT_EQ(ASCIIToUTF16("POST"), filled_form.method);
262 if (has_credit_card_fields) { 260 if (has_credit_card_fields) {
263 EXPECT_EQ(GURL("https://myform.com/form.html"), filled_form.origin); 261 EXPECT_EQ(GURL("https://myform.com/form.html"), filled_form.origin);
264 EXPECT_EQ(GURL("https://myform.com/submit.html"), filled_form.action); 262 EXPECT_EQ(GURL("https://myform.com/submit.html"), filled_form.action);
265 } else { 263 } else {
266 EXPECT_EQ(GURL("http://myform.com/form.html"), filled_form.origin); 264 EXPECT_EQ(GURL("http://myform.com/form.html"), filled_form.origin);
267 EXPECT_EQ(GURL("http://myform.com/submit.html"), filled_form.action); 265 EXPECT_EQ(GURL("http://myform.com/submit.html"), filled_form.action);
268 } 266 }
269 EXPECT_TRUE(filled_form.user_submitted); 267 EXPECT_TRUE(filled_form.user_submitted);
270 268
271 size_t form_size = 0; 269 size_t form_size = 0;
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 external_delegate_->CheckSuggestions( 762 external_delegate_->CheckSuggestions(
765 kDefaultPageID, arraysize(expected_values), expected_values, 763 kDefaultPageID, arraysize(expected_values), expected_values,
766 expected_labels, expected_icons, expected_unique_ids); 764 expected_labels, expected_icons, expected_unique_ids);
767 } 765 }
768 766
769 // Test that we return no suggestions when the form has no relevant fields. 767 // Test that we return no suggestions when the form has no relevant fields.
770 TEST_F(AutofillManagerTest, GetProfileSuggestionsUnknownFields) { 768 TEST_F(AutofillManagerTest, GetProfileSuggestionsUnknownFields) {
771 // Set up our form data. 769 // Set up our form data.
772 FormData form; 770 FormData form;
773 form.name = ASCIIToUTF16("MyForm"); 771 form.name = ASCIIToUTF16("MyForm");
774 form.method = ASCIIToUTF16("POST");
775 form.origin = GURL("http://myform.com/form.html"); 772 form.origin = GURL("http://myform.com/form.html");
776 form.action = GURL("http://myform.com/submit.html"); 773 form.action = GURL("http://myform.com/submit.html");
777 form.user_submitted = true; 774 form.user_submitted = true;
778 775
779 FormFieldData field; 776 FormFieldData field;
780 test::CreateTestFormField("Username", "username", "", "text",&field); 777 test::CreateTestFormField("Username", "username", "", "text",&field);
781 form.fields.push_back(field); 778 form.fields.push_back(field);
782 test::CreateTestFormField("Password", "password", "", "password",&field); 779 test::CreateTestFormField("Password", "password", "", "password",&field);
783 form.fields.push_back(field); 780 form.fields.push_back(field);
784 test::CreateTestFormField("Quest", "quest", "", "quest", &field); 781 test::CreateTestFormField("Quest", "quest", "", "quest", &field);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
840 FormsSeen(forms); 837 FormsSeen(forms);
841 838
842 // Disable Autofill. 839 // Disable Autofill.
843 autofill_manager_->set_autofill_enabled(false); 840 autofill_manager_->set_autofill_enabled(false);
844 841
845 const FormFieldData& field = form.fields[0]; 842 const FormFieldData& field = form.fields[0];
846 GetAutofillSuggestions(form, field); 843 GetAutofillSuggestions(form, field);
847 EXPECT_FALSE(external_delegate_->on_suggestions_returned_seen()); 844 EXPECT_FALSE(external_delegate_->on_suggestions_returned_seen());
848 } 845 }
849 846
850 // Test that we return a warning explaining that autofill suggestions are
851 // unavailable when the form method is GET rather than POST.
852 TEST_F(AutofillManagerTest, GetProfileSuggestionsMethodGet) {
853 // Set up our form data.
854 FormData form;
855 test::CreateTestAddressFormData(&form);
856 form.method = ASCIIToUTF16("GET");
857 std::vector<FormData> forms(1, form);
858 FormsSeen(forms);
859
860 const FormFieldData& field = form.fields[0];
861 GetAutofillSuggestions(form, field);
862
863 // No suggestions provided, so send an empty vector as the results.
864 // This triggers the combined message send.
865 AutocompleteSuggestionsReturned(std::vector<base::string16>());
866
867 // Test that we sent the right values to the external delegate.
868 base::string16 expected_values[] = {
869 l10n_util::GetStringUTF16(IDS_AUTOFILL_WARNING_FORM_DISABLED)
870 };
871 base::string16 expected_labels[] = {base::string16()};
872 base::string16 expected_icons[] = {base::string16()};
873 int expected_unique_ids[] = {POPUP_ITEM_ID_WARNING_MESSAGE};
874 external_delegate_->CheckSuggestions(
875 kDefaultPageID, arraysize(expected_values), expected_values,
876 expected_labels, expected_icons, expected_unique_ids);
877
878 // Now add some Autocomplete suggestions. We should return the autocomplete
879 // suggestions and the warning; these will be culled by the renderer.
880 const int kPageID2 = 2;
881 GetAutofillSuggestions(kPageID2, form, field);
882
883 std::vector<base::string16> suggestions;
884 suggestions.push_back(ASCIIToUTF16("Jay"));
885 suggestions.push_back(ASCIIToUTF16("Jason"));
886 AutocompleteSuggestionsReturned(suggestions);
887
888 base::string16 expected_values2[] = {
889 l10n_util::GetStringUTF16(IDS_AUTOFILL_WARNING_FORM_DISABLED),
890 ASCIIToUTF16("Jay"),
891 ASCIIToUTF16("Jason")
892 };
893 base::string16 expected_labels2[] = { base::string16(), base::string16(),
894 base::string16()};
895 base::string16 expected_icons2[] = { base::string16(), base::string16(),
896 base::string16()};
897 int expected_unique_ids2[] = {-1, 0, 0};
898 external_delegate_->CheckSuggestions(
899 kPageID2, arraysize(expected_values2), expected_values2,
900 expected_labels2, expected_icons2, expected_unique_ids2);
901
902 // Now clear the test profiles and try again -- we shouldn't return a warning.
903 personal_data_.ClearAutofillProfiles();
904 GetAutofillSuggestions(form, field);
905 EXPECT_FALSE(external_delegate_->on_suggestions_returned_seen());
906 }
907
908 // Test that we return all credit card profile suggestions when all form fields 847 // Test that we return all credit card profile suggestions when all form fields
909 // are empty. 848 // are empty.
910 TEST_F(AutofillManagerTest, GetCreditCardSuggestionsEmptyValue) { 849 TEST_F(AutofillManagerTest, GetCreditCardSuggestionsEmptyValue) {
911 // Set up our form data. 850 // Set up our form data.
912 FormData form; 851 FormData form;
913 CreateTestCreditCardFormData(&form, true, false); 852 CreateTestCreditCardFormData(&form, true, false);
914 std::vector<FormData> forms(1, form); 853 std::vector<FormData> forms(1, form);
915 FormsSeen(forms); 854 FormsSeen(forms);
916 855
917 FormFieldData field = form.fields[1]; 856 FormFieldData field = form.fields[1];
(...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after
1796 } 1735 }
1797 } 1736 }
1798 1737
1799 // Test that we correctly fill a form that has author-specified sections, which 1738 // Test that we correctly fill a form that has author-specified sections, which
1800 // might not match our expected section breakdown. 1739 // might not match our expected section breakdown.
1801 TEST_F(AutofillManagerTest, FillFormWithAuthorSpecifiedSections) { 1740 TEST_F(AutofillManagerTest, FillFormWithAuthorSpecifiedSections) {
1802 // Create a form with a billing section and an unnamed section, interleaved. 1741 // Create a form with a billing section and an unnamed section, interleaved.
1803 // The billing section includes both address and credit card fields. 1742 // The billing section includes both address and credit card fields.
1804 FormData form; 1743 FormData form;
1805 form.name = ASCIIToUTF16("MyForm"); 1744 form.name = ASCIIToUTF16("MyForm");
1806 form.method = ASCIIToUTF16("POST");
1807 form.origin = GURL("https://myform.com/form.html"); 1745 form.origin = GURL("https://myform.com/form.html");
1808 form.action = GURL("https://myform.com/submit.html"); 1746 form.action = GURL("https://myform.com/submit.html");
1809 form.user_submitted = true; 1747 form.user_submitted = true;
1810 1748
1811 FormFieldData field; 1749 FormFieldData field;
1812 1750
1813 test::CreateTestFormField("", "country", "", "text", &field); 1751 test::CreateTestFormField("", "country", "", "text", &field);
1814 field.autocomplete_attribute = "section-billing country"; 1752 field.autocomplete_attribute = "section-billing country";
1815 form.fields.push_back(field); 1753 form.fields.push_back(field);
1816 1754
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1861 GUIDPair guid("00000000-0000-0000-0000-000000000001", 0); 1799 GUIDPair guid("00000000-0000-0000-0000-000000000001", 0);
1862 GUIDPair empty(std::string(), 0); 1800 GUIDPair empty(std::string(), 0);
1863 int response_page_id = 0; 1801 int response_page_id = 0;
1864 FormData response_data; 1802 FormData response_data;
1865 FillAutofillFormDataAndSaveResults(kDefaultPageID, form, form.fields[1], 1803 FillAutofillFormDataAndSaveResults(kDefaultPageID, form, form.fields[1],
1866 PackGUIDs(empty, guid), &response_page_id, &response_data); 1804 PackGUIDs(empty, guid), &response_page_id, &response_data);
1867 { 1805 {
1868 SCOPED_TRACE("Unnamed section"); 1806 SCOPED_TRACE("Unnamed section");
1869 EXPECT_EQ(kDefaultPageID, response_page_id); 1807 EXPECT_EQ(kDefaultPageID, response_page_id);
1870 EXPECT_EQ(ASCIIToUTF16("MyForm"), response_data.name); 1808 EXPECT_EQ(ASCIIToUTF16("MyForm"), response_data.name);
1871 EXPECT_EQ(ASCIIToUTF16("POST"), response_data.method);
1872 EXPECT_EQ(GURL("https://myform.com/form.html"), response_data.origin); 1809 EXPECT_EQ(GURL("https://myform.com/form.html"), response_data.origin);
1873 EXPECT_EQ(GURL("https://myform.com/submit.html"), response_data.action); 1810 EXPECT_EQ(GURL("https://myform.com/submit.html"), response_data.action);
1874 EXPECT_TRUE(response_data.user_submitted); 1811 EXPECT_TRUE(response_data.user_submitted);
1875 ASSERT_EQ(11U, response_data.fields.size()); 1812 ASSERT_EQ(11U, response_data.fields.size());
1876 1813
1877 ExpectFilledField("", "country", "", "text", response_data.fields[0]); 1814 ExpectFilledField("", "country", "", "text", response_data.fields[0]);
1878 ExpectFilledField("", "firstname", "Elvis", "text", 1815 ExpectFilledField("", "firstname", "Elvis", "text",
1879 response_data.fields[1]); 1816 response_data.fields[1]);
1880 ExpectFilledField("", "lastname", "Presley", "text", 1817 ExpectFilledField("", "lastname", "Presley", "text",
1881 response_data.fields[2]); 1818 response_data.fields[2]);
(...skipping 11 matching lines...) Expand all
1893 // Fill the address portion of the billing section. 1830 // Fill the address portion of the billing section.
1894 const int kPageID2 = 2; 1831 const int kPageID2 = 2;
1895 GUIDPair guid2("00000000-0000-0000-0000-000000000001", 0); 1832 GUIDPair guid2("00000000-0000-0000-0000-000000000001", 0);
1896 response_page_id = 0; 1833 response_page_id = 0;
1897 FillAutofillFormDataAndSaveResults(kPageID2, form, form.fields[0], 1834 FillAutofillFormDataAndSaveResults(kPageID2, form, form.fields[0],
1898 PackGUIDs(empty, guid2), &response_page_id, &response_data); 1835 PackGUIDs(empty, guid2), &response_page_id, &response_data);
1899 { 1836 {
1900 SCOPED_TRACE("Billing address"); 1837 SCOPED_TRACE("Billing address");
1901 EXPECT_EQ(kPageID2, response_page_id); 1838 EXPECT_EQ(kPageID2, response_page_id);
1902 EXPECT_EQ(ASCIIToUTF16("MyForm"), response_data.name); 1839 EXPECT_EQ(ASCIIToUTF16("MyForm"), response_data.name);
1903 EXPECT_EQ(ASCIIToUTF16("POST"), response_data.method);
1904 EXPECT_EQ(GURL("https://myform.com/form.html"), response_data.origin); 1840 EXPECT_EQ(GURL("https://myform.com/form.html"), response_data.origin);
1905 EXPECT_EQ(GURL("https://myform.com/submit.html"), response_data.action); 1841 EXPECT_EQ(GURL("https://myform.com/submit.html"), response_data.action);
1906 EXPECT_TRUE(response_data.user_submitted); 1842 EXPECT_TRUE(response_data.user_submitted);
1907 ASSERT_EQ(11U, response_data.fields.size()); 1843 ASSERT_EQ(11U, response_data.fields.size());
1908 1844
1909 ExpectFilledField("", "country", "US", "text", 1845 ExpectFilledField("", "country", "US", "text",
1910 response_data.fields[0]); 1846 response_data.fields[0]);
1911 ExpectFilledField("", "firstname", "", "text", response_data.fields[1]); 1847 ExpectFilledField("", "firstname", "", "text", response_data.fields[1]);
1912 ExpectFilledField("", "lastname", "", "text", response_data.fields[2]); 1848 ExpectFilledField("", "lastname", "", "text", response_data.fields[2]);
1913 ExpectFilledField("", "address", "3734 Elvis Presley Blvd.", "text", 1849 ExpectFilledField("", "address", "3734 Elvis Presley Blvd.", "text",
(...skipping 12 matching lines...) Expand all
1926 const int kPageID3 = 3; 1862 const int kPageID3 = 3;
1927 GUIDPair guid3("00000000-0000-0000-0000-000000000004", 0); 1863 GUIDPair guid3("00000000-0000-0000-0000-000000000004", 0);
1928 response_page_id = 0; 1864 response_page_id = 0;
1929 FillAutofillFormDataAndSaveResults( 1865 FillAutofillFormDataAndSaveResults(
1930 kPageID3, form, form.fields[form.fields.size() - 2], 1866 kPageID3, form, form.fields[form.fields.size() - 2],
1931 PackGUIDs(guid3, empty), &response_page_id, &response_data); 1867 PackGUIDs(guid3, empty), &response_page_id, &response_data);
1932 { 1868 {
1933 SCOPED_TRACE("Credit card"); 1869 SCOPED_TRACE("Credit card");
1934 EXPECT_EQ(kPageID3, response_page_id); 1870 EXPECT_EQ(kPageID3, response_page_id);
1935 EXPECT_EQ(ASCIIToUTF16("MyForm"), response_data.name); 1871 EXPECT_EQ(ASCIIToUTF16("MyForm"), response_data.name);
1936 EXPECT_EQ(ASCIIToUTF16("POST"), response_data.method);
1937 EXPECT_EQ(GURL("https://myform.com/form.html"), response_data.origin); 1872 EXPECT_EQ(GURL("https://myform.com/form.html"), response_data.origin);
1938 EXPECT_EQ(GURL("https://myform.com/submit.html"), response_data.action); 1873 EXPECT_EQ(GURL("https://myform.com/submit.html"), response_data.action);
1939 EXPECT_TRUE(response_data.user_submitted); 1874 EXPECT_TRUE(response_data.user_submitted);
1940 ASSERT_EQ(11U, response_data.fields.size()); 1875 ASSERT_EQ(11U, response_data.fields.size());
1941 1876
1942 ExpectFilledField("", "country", "", "text", response_data.fields[0]); 1877 ExpectFilledField("", "country", "", "text", response_data.fields[0]);
1943 ExpectFilledField("", "firstname", "", "text", response_data.fields[1]); 1878 ExpectFilledField("", "firstname", "", "text", response_data.fields[1]);
1944 ExpectFilledField("", "lastname", "", "text", response_data.fields[2]); 1879 ExpectFilledField("", "lastname", "", "text", response_data.fields[2]);
1945 ExpectFilledField("", "address", "", "text", response_data.fields[3]); 1880 ExpectFilledField("", "address", "", "text", response_data.fields[3]);
1946 ExpectFilledField("", "city", "", "text", response_data.fields[4]); 1881 ExpectFilledField("", "city", "", "text", response_data.fields[4]);
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
2099 "theking@gmail.com", "", "", "", "", true, false, false); 2034 "theking@gmail.com", "", "", "", "", true, false, false);
2100 } 2035 }
2101 } 2036 }
2102 2037
2103 // Test that we correctly fill a phone number split across multiple fields. 2038 // Test that we correctly fill a phone number split across multiple fields.
2104 TEST_F(AutofillManagerTest, FillPhoneNumber) { 2039 TEST_F(AutofillManagerTest, FillPhoneNumber) {
2105 // In one form, rely on the maxlength attribute to imply phone number parts. 2040 // In one form, rely on the maxlength attribute to imply phone number parts.
2106 // In the other form, rely on the autocompletetype attribute. 2041 // In the other form, rely on the autocompletetype attribute.
2107 FormData form_with_maxlength; 2042 FormData form_with_maxlength;
2108 form_with_maxlength.name = ASCIIToUTF16("MyMaxlengthPhoneForm"); 2043 form_with_maxlength.name = ASCIIToUTF16("MyMaxlengthPhoneForm");
2109 form_with_maxlength.method = ASCIIToUTF16("POST");
2110 form_with_maxlength.origin = GURL("http://myform.com/phone_form.html"); 2044 form_with_maxlength.origin = GURL("http://myform.com/phone_form.html");
2111 form_with_maxlength.action = GURL("http://myform.com/phone_submit.html"); 2045 form_with_maxlength.action = GURL("http://myform.com/phone_submit.html");
2112 form_with_maxlength.user_submitted = true; 2046 form_with_maxlength.user_submitted = true;
2113 FormData form_with_autocompletetype = form_with_maxlength; 2047 FormData form_with_autocompletetype = form_with_maxlength;
2114 form_with_autocompletetype.name = ASCIIToUTF16("MyAutocompletetypePhoneForm"); 2048 form_with_autocompletetype.name = ASCIIToUTF16("MyAutocompletetypePhoneForm");
2115 2049
2116 struct { 2050 struct {
2117 const char* label; 2051 const char* label;
2118 const char* name; 2052 const char* name;
2119 size_t max_length; 2053 size_t max_length;
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
2334 autofill_manager_->set_autofill_enabled(false); 2268 autofill_manager_->set_autofill_enabled(false);
2335 scoped_ptr<MockAutocompleteHistoryManager> autocomplete_history_manager; 2269 scoped_ptr<MockAutocompleteHistoryManager> autocomplete_history_manager;
2336 autocomplete_history_manager.reset( 2270 autocomplete_history_manager.reset(
2337 new MockAutocompleteHistoryManager(autofill_driver_.get(), &client)); 2271 new MockAutocompleteHistoryManager(autofill_driver_.get(), &client));
2338 autofill_manager_->autocomplete_history_manager_ = 2272 autofill_manager_->autocomplete_history_manager_ =
2339 autocomplete_history_manager.Pass(); 2273 autocomplete_history_manager.Pass();
2340 2274
2341 // Set up our form data. 2275 // Set up our form data.
2342 FormData form; 2276 FormData form;
2343 test::CreateTestAddressFormData(&form); 2277 test::CreateTestAddressFormData(&form);
2344 form.method = ASCIIToUTF16("GET");
2345 MockAutocompleteHistoryManager* m = static_cast< 2278 MockAutocompleteHistoryManager* m = static_cast<
2346 MockAutocompleteHistoryManager*>( 2279 MockAutocompleteHistoryManager*>(
2347 autofill_manager_->autocomplete_history_manager_.get()); 2280 autofill_manager_->autocomplete_history_manager_.get());
2348 EXPECT_CALL(*m, 2281 EXPECT_CALL(*m,
2349 OnFormSubmitted(_)).Times(1); 2282 OnFormSubmitted(_)).Times(1);
2350 FormSubmitted(form); 2283 FormSubmitted(form);
2351 } 2284 }
2352 2285
2353 // Test that when Autocomplete is enabled and Autofill is disabled, 2286 // Test that when Autocomplete is enabled and Autofill is disabled,
2354 // Autocomplete suggestions are still received. 2287 // Autocomplete suggestions are still received.
2355 TEST_F(AutofillManagerTest, AutocompleteSuggestionsWhenAutofillDisabled) { 2288 TEST_F(AutofillManagerTest, AutocompleteSuggestionsWhenAutofillDisabled) {
2356 TestAutofillClient client; 2289 TestAutofillClient client;
2357 autofill_manager_.reset( 2290 autofill_manager_.reset(
2358 new TestAutofillManager(autofill_driver_.get(), &client, NULL)); 2291 new TestAutofillManager(autofill_driver_.get(), &client, NULL));
2359 autofill_manager_->set_autofill_enabled(false); 2292 autofill_manager_->set_autofill_enabled(false);
2360 autofill_manager_->SetExternalDelegate(external_delegate_.get()); 2293 autofill_manager_->SetExternalDelegate(external_delegate_.get());
2361 2294
2362 // Set up our form data. 2295 // Set up our form data.
2363 FormData form; 2296 FormData form;
2364 test::CreateTestAddressFormData(&form); 2297 test::CreateTestAddressFormData(&form);
2365 form.method = ASCIIToUTF16("GET");
2366 std::vector<FormData> forms(1, form); 2298 std::vector<FormData> forms(1, form);
2367 FormsSeen(forms); 2299 FormsSeen(forms);
2368 const FormFieldData& field = form.fields[0]; 2300 const FormFieldData& field = form.fields[0];
2369 GetAutofillSuggestions(form, field); 2301 GetAutofillSuggestions(form, field);
2370 2302
2371 // Add some Autocomplete suggestions. We should return the autocomplete 2303 // Add some Autocomplete suggestions. We should return the autocomplete
2372 // suggestions, these will be culled by the renderer. 2304 // suggestions, these will be culled by the renderer.
2373 std::vector<base::string16> suggestions; 2305 std::vector<base::string16> suggestions;
2374 suggestions.push_back(ASCIIToUTF16("Jay")); 2306 suggestions.push_back(ASCIIToUTF16("Jay"));
2375 suggestions.push_back(ASCIIToUTF16("Jason")); 2307 suggestions.push_back(ASCIIToUTF16("Jason"));
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
2510 prefs->SetBoolean(::autofill::prefs::kAutofillAuxiliaryProfilesEnabled, true); 2442 prefs->SetBoolean(::autofill::prefs::kAutofillAuxiliaryProfilesEnabled, true);
2511 prefs->ClearPref(::autofill::prefs::kAutofillAuxiliaryProfilesEnabled); 2443 prefs->ClearPref(::autofill::prefs::kAutofillAuxiliaryProfilesEnabled);
2512 ASSERT_FALSE( 2444 ASSERT_FALSE(
2513 prefs->GetBoolean(::autofill::prefs::kAutofillAuxiliaryProfilesEnabled)); 2445 prefs->GetBoolean(::autofill::prefs::kAutofillAuxiliaryProfilesEnabled));
2514 #endif // defined(OS_MACOSX) || defined(OS_ANDROID) 2446 #endif // defined(OS_MACOSX) || defined(OS_ANDROID)
2515 } 2447 }
2516 2448
2517 TEST_F(AutofillManagerTest, DeterminePossibleFieldTypesForUpload) { 2449 TEST_F(AutofillManagerTest, DeterminePossibleFieldTypesForUpload) {
2518 FormData form; 2450 FormData form;
2519 form.name = ASCIIToUTF16("MyForm"); 2451 form.name = ASCIIToUTF16("MyForm");
2520 form.method = ASCIIToUTF16("POST");
2521 form.origin = GURL("http://myform.com/form.html"); 2452 form.origin = GURL("http://myform.com/form.html");
2522 form.action = GURL("http://myform.com/submit.html"); 2453 form.action = GURL("http://myform.com/submit.html");
2523 form.user_submitted = true; 2454 form.user_submitted = true;
2524 2455
2525 std::vector<ServerFieldTypeSet> expected_types; 2456 std::vector<ServerFieldTypeSet> expected_types;
2526 2457
2527 // These fields should all match. 2458 // These fields should all match.
2528 FormFieldData field; 2459 FormFieldData field;
2529 ServerFieldTypeSet types; 2460 ServerFieldTypeSet types;
2530 test::CreateTestFormField("", "1", "Elvis", "text", &field); 2461 test::CreateTestFormField("", "1", "Elvis", "text", &field);
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
2886 test::CreateTestAddressFormData(&form); 2817 test::CreateTestAddressFormData(&form);
2887 std::vector<FormData> forms(1, form); 2818 std::vector<FormData> forms(1, form);
2888 FormsSeen(forms); 2819 FormsSeen(forms);
2889 const FormFieldData& field = form.fields[0]; 2820 const FormFieldData& field = form.fields[0];
2890 GetAutofillSuggestions(form, field); // should call the delegate's OnQuery() 2821 GetAutofillSuggestions(form, field); // should call the delegate's OnQuery()
2891 2822
2892 EXPECT_TRUE(external_delegate_->on_query_seen()); 2823 EXPECT_TRUE(external_delegate_->on_query_seen());
2893 } 2824 }
2894 2825
2895 } // namespace autofill 2826 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/autofill_manager.cc ('k') | components/autofill/core/browser/autofill_merge_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698