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

Side by Side Diff: components/autofill/core/browser/autocomplete_history_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 <vector> 5 #include <vector>
6 6
7 #include "base/memory/ref_counted.h" 7 #include "base/memory/ref_counted.h"
8 #include "base/message_loop/message_loop_proxy.h" 8 #include "base/message_loop/message_loop_proxy.h"
9 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 scoped_refptr<MockWebDataService> web_data_service_; 82 scoped_refptr<MockWebDataService> web_data_service_;
83 scoped_ptr<AutocompleteHistoryManager> autocomplete_manager_; 83 scoped_ptr<AutocompleteHistoryManager> autocomplete_manager_;
84 scoped_ptr<AutofillDriver> autofill_driver_; 84 scoped_ptr<AutofillDriver> autofill_driver_;
85 scoped_ptr<MockAutofillClient> autofill_client_; 85 scoped_ptr<MockAutofillClient> autofill_client_;
86 }; 86 };
87 87
88 // Tests that credit card numbers are not sent to the WebDatabase to be saved. 88 // Tests that credit card numbers are not sent to the WebDatabase to be saved.
89 TEST_F(AutocompleteHistoryManagerTest, CreditCardNumberValue) { 89 TEST_F(AutocompleteHistoryManagerTest, CreditCardNumberValue) {
90 FormData form; 90 FormData form;
91 form.name = ASCIIToUTF16("MyForm"); 91 form.name = ASCIIToUTF16("MyForm");
92 form.method = ASCIIToUTF16("POST");
93 form.origin = GURL("http://myform.com/form.html"); 92 form.origin = GURL("http://myform.com/form.html");
94 form.action = GURL("http://myform.com/submit.html"); 93 form.action = GURL("http://myform.com/submit.html");
95 form.user_submitted = true; 94 form.user_submitted = true;
96 95
97 // Valid Visa credit card number pulled from the paypal help site. 96 // Valid Visa credit card number pulled from the paypal help site.
98 FormFieldData valid_cc; 97 FormFieldData valid_cc;
99 valid_cc.label = ASCIIToUTF16("Credit Card"); 98 valid_cc.label = ASCIIToUTF16("Credit Card");
100 valid_cc.name = ASCIIToUTF16("ccnum"); 99 valid_cc.name = ASCIIToUTF16("ccnum");
101 valid_cc.value = ASCIIToUTF16("4012888888881881"); 100 valid_cc.value = ASCIIToUTF16("4012888888881881");
102 valid_cc.form_control_type = "text"; 101 valid_cc.form_control_type = "text";
103 form.fields.push_back(valid_cc); 102 form.fields.push_back(valid_cc);
104 103
105 EXPECT_CALL(*web_data_service_.get(), AddFormFields(_)).Times(0); 104 EXPECT_CALL(*web_data_service_.get(), AddFormFields(_)).Times(0);
106 autocomplete_manager_->OnFormSubmitted(form); 105 autocomplete_manager_->OnFormSubmitted(form);
107 } 106 }
108 107
109 // Contrary test to AutocompleteHistoryManagerTest.CreditCardNumberValue. The 108 // Contrary test to AutocompleteHistoryManagerTest.CreditCardNumberValue. The
110 // value being submitted is not a valid credit card number, so it will be sent 109 // value being submitted is not a valid credit card number, so it will be sent
111 // to the WebDatabase to be saved. 110 // to the WebDatabase to be saved.
112 TEST_F(AutocompleteHistoryManagerTest, NonCreditCardNumberValue) { 111 TEST_F(AutocompleteHistoryManagerTest, NonCreditCardNumberValue) {
113 FormData form; 112 FormData form;
114 form.name = ASCIIToUTF16("MyForm"); 113 form.name = ASCIIToUTF16("MyForm");
115 form.method = ASCIIToUTF16("POST");
116 form.origin = GURL("http://myform.com/form.html"); 114 form.origin = GURL("http://myform.com/form.html");
117 form.action = GURL("http://myform.com/submit.html"); 115 form.action = GURL("http://myform.com/submit.html");
118 form.user_submitted = true; 116 form.user_submitted = true;
119 117
120 // Invalid credit card number. 118 // Invalid credit card number.
121 FormFieldData invalid_cc; 119 FormFieldData invalid_cc;
122 invalid_cc.label = ASCIIToUTF16("Credit Card"); 120 invalid_cc.label = ASCIIToUTF16("Credit Card");
123 invalid_cc.name = ASCIIToUTF16("ccnum"); 121 invalid_cc.name = ASCIIToUTF16("ccnum");
124 invalid_cc.value = ASCIIToUTF16("4580123456789012"); 122 invalid_cc.value = ASCIIToUTF16("4580123456789012");
125 invalid_cc.form_control_type = "text"; 123 invalid_cc.form_control_type = "text";
126 form.fields.push_back(invalid_cc); 124 form.fields.push_back(invalid_cc);
127 125
128 EXPECT_CALL(*(web_data_service_.get()), AddFormFields(_)).Times(1); 126 EXPECT_CALL(*(web_data_service_.get()), AddFormFields(_)).Times(1);
129 autocomplete_manager_->OnFormSubmitted(form); 127 autocomplete_manager_->OnFormSubmitted(form);
130 } 128 }
131 129
132 // Tests that SSNs are not sent to the WebDatabase to be saved. 130 // Tests that SSNs are not sent to the WebDatabase to be saved.
133 TEST_F(AutocompleteHistoryManagerTest, SSNValue) { 131 TEST_F(AutocompleteHistoryManagerTest, SSNValue) {
134 FormData form; 132 FormData form;
135 form.name = ASCIIToUTF16("MyForm"); 133 form.name = ASCIIToUTF16("MyForm");
136 form.method = ASCIIToUTF16("POST");
137 form.origin = GURL("http://myform.com/form.html"); 134 form.origin = GURL("http://myform.com/form.html");
138 form.action = GURL("http://myform.com/submit.html"); 135 form.action = GURL("http://myform.com/submit.html");
139 form.user_submitted = true; 136 form.user_submitted = true;
140 137
141 FormFieldData ssn; 138 FormFieldData ssn;
142 ssn.label = ASCIIToUTF16("Social Security Number"); 139 ssn.label = ASCIIToUTF16("Social Security Number");
143 ssn.name = ASCIIToUTF16("ssn"); 140 ssn.name = ASCIIToUTF16("ssn");
144 ssn.value = ASCIIToUTF16("078-05-1120"); 141 ssn.value = ASCIIToUTF16("078-05-1120");
145 ssn.form_control_type = "text"; 142 ssn.form_control_type = "text";
146 form.fields.push_back(ssn); 143 form.fields.push_back(ssn);
147 144
148 EXPECT_CALL(*web_data_service_.get(), AddFormFields(_)).Times(0); 145 EXPECT_CALL(*web_data_service_.get(), AddFormFields(_)).Times(0);
149 autocomplete_manager_->OnFormSubmitted(form); 146 autocomplete_manager_->OnFormSubmitted(form);
150 } 147 }
151 148
152 // Verify that autocomplete text is saved for search fields. 149 // Verify that autocomplete text is saved for search fields.
153 TEST_F(AutocompleteHistoryManagerTest, SearchField) { 150 TEST_F(AutocompleteHistoryManagerTest, SearchField) {
154 FormData form; 151 FormData form;
155 form.name = ASCIIToUTF16("MyForm"); 152 form.name = ASCIIToUTF16("MyForm");
156 form.method = ASCIIToUTF16("POST");
157 form.origin = GURL("http://myform.com/form.html"); 153 form.origin = GURL("http://myform.com/form.html");
158 form.action = GURL("http://myform.com/submit.html"); 154 form.action = GURL("http://myform.com/submit.html");
159 form.user_submitted = true; 155 form.user_submitted = true;
160 156
161 // Search field. 157 // Search field.
162 FormFieldData search_field; 158 FormFieldData search_field;
163 search_field.label = ASCIIToUTF16("Search"); 159 search_field.label = ASCIIToUTF16("Search");
164 search_field.name = ASCIIToUTF16("search"); 160 search_field.name = ASCIIToUTF16("search");
165 search_field.value = ASCIIToUTF16("my favorite query"); 161 search_field.value = ASCIIToUTF16("my favorite query");
166 search_field.form_control_type = "search"; 162 search_field.form_control_type = "search";
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 autofill_client_.get(), 226 autofill_client_.get(),
231 "en-US", 227 "en-US",
232 AutofillManager::ENABLE_AUTOFILL_DOWNLOAD_MANAGER)); 228 AutofillManager::ENABLE_AUTOFILL_DOWNLOAD_MANAGER));
233 229
234 MockAutofillExternalDelegate external_delegate(autofill_manager.get(), 230 MockAutofillExternalDelegate external_delegate(autofill_manager.get(),
235 autofill_driver_.get()); 231 autofill_driver_.get());
236 autocomplete_history_manager.SetExternalDelegate(&external_delegate); 232 autocomplete_history_manager.SetExternalDelegate(&external_delegate);
237 233
238 FormData form; 234 FormData form;
239 form.name = ASCIIToUTF16("MyForm"); 235 form.name = ASCIIToUTF16("MyForm");
240 form.method = ASCIIToUTF16("POST");
241 form.origin = GURL("http://myform.com/form.html"); 236 form.origin = GURL("http://myform.com/form.html");
242 form.action = GURL("http://myform.com/submit.html"); 237 form.action = GURL("http://myform.com/submit.html");
243 form.user_submitted = true; 238 form.user_submitted = true;
244 239
245 FormFieldData field; 240 FormFieldData field;
246 test::CreateTestFormField("Address", "address", "", "textarea", &field); 241 test::CreateTestFormField("Address", "address", "", "textarea", &field);
247 242
248 EXPECT_CALL(external_delegate, 243 EXPECT_CALL(external_delegate,
249 OnSuggestionsReturned(0, 244 OnSuggestionsReturned(0,
250 std::vector<base::string16>(), 245 std::vector<base::string16>(),
251 std::vector<base::string16>(), 246 std::vector<base::string16>(),
252 std::vector<base::string16>(), 247 std::vector<base::string16>(),
253 std::vector<int>())); 248 std::vector<int>()));
254 autocomplete_history_manager.OnGetAutocompleteSuggestions( 249 autocomplete_history_manager.OnGetAutocompleteSuggestions(
255 0, 250 0,
256 field.name, 251 field.name,
257 field.value, 252 field.value,
258 field.form_control_type, 253 field.form_control_type,
259 std::vector<base::string16>(), 254 std::vector<base::string16>(),
260 std::vector<base::string16>(), 255 std::vector<base::string16>(),
261 std::vector<base::string16>(), 256 std::vector<base::string16>(),
262 std::vector<int>()); 257 std::vector<int>());
263 } 258 }
264 259
265 } // namespace autofill 260 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698