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

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

Issue 65813002: mac: Prepare most test code for -Wunused-functions too. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 1 month 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/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 199
200 credit_card = new CreditCard; 200 credit_card = new CreditCard;
201 test::SetCreditCardInfo(credit_card, "", "", "", ""); 201 test::SetCreditCardInfo(credit_card, "", "", "", "");
202 credit_card->set_guid("00000000-0000-0000-0000-000000000006"); 202 credit_card->set_guid("00000000-0000-0000-0000-000000000006");
203 credit_cards->push_back(credit_card); 203 credit_cards->push_back(credit_card);
204 } 204 }
205 205
206 DISALLOW_COPY_AND_ASSIGN(TestPersonalDataManager); 206 DISALLOW_COPY_AND_ASSIGN(TestPersonalDataManager);
207 }; 207 };
208 208
209 // Populates |form| with 3 fields and a field with autocomplete attribute.
210 void CreateTestFormWithAutocompleteAttribute(FormData* form) {
211 form->name = ASCIIToUTF16("UserSpecified");
212 form->method = ASCIIToUTF16("POST");
213 form->origin = GURL("http://myform.com/userspecified.html");
214 form->action = GURL("http://myform.com/submit.html");
215 form->user_submitted = true;
216
217 FormFieldData field;
218 test::CreateTestFormField("First Name", "firstname", "", "text", &field);
219 form->fields.push_back(field);
220 test::CreateTestFormField("Middle Name", "middlename", "", "text", &field);
221 form->fields.push_back(field);
222 test::CreateTestFormField("Last Name", "lastname", "", "text", &field);
223 form->fields.push_back(field);
224 field.autocomplete_attribute="cc-type";
225 test::CreateTestFormField("cc-type", "cc-type", "", "text", &field);
226 form->fields.push_back(field);
227 }
228
229 // Populates |form| with data corresponding to a simple shipping options form.
230 void CreateTestShippingOptionsFormData(FormData* form) {
231 form->name = ASCIIToUTF16("Shipping Options");
232 form->method = ASCIIToUTF16("POST");
233 form->origin = GURL("http://myform.com/shipping.html");
234 form->action = GURL("http://myform.com/submit.html");
235 form->user_submitted = true;
236
237 FormFieldData field;
238 test::CreateTestFormField("Shipping1", "option", "option1", "radio", &field);
239 form->fields.push_back(field);
240 test::CreateTestFormField("Shipping2", "option", "option2", "radio", &field);
241 form->fields.push_back(field);
242 }
243
244 // Populates |form| with data corresponding to a simple credit card form. 209 // Populates |form| with data corresponding to a simple credit card form.
245 // Note that this actually appends fields to the form data, which can be useful 210 // Note that this actually appends fields to the form data, which can be useful
246 // for building up more complex test forms. 211 // for building up more complex test forms.
247 void CreateTestCreditCardFormData(FormData* form, 212 void CreateTestCreditCardFormData(FormData* form,
248 bool is_https, 213 bool is_https,
249 bool use_month_type) { 214 bool use_month_type) {
250 form->name = ASCIIToUTF16("MyForm"); 215 form->name = ASCIIToUTF16("MyForm");
251 form->method = ASCIIToUTF16("POST"); 216 form->method = ASCIIToUTF16("POST");
252 if (is_https) { 217 if (is_https) {
253 form->origin = GURL("https://myform.com/form.html"); 218 form->origin = GURL("https://myform.com/form.html");
(...skipping 14 matching lines...) Expand all
268 "Expiration Date", "ccmonth", "", "month", &field); 233 "Expiration Date", "ccmonth", "", "month", &field);
269 form->fields.push_back(field); 234 form->fields.push_back(field);
270 } else { 235 } else {
271 test::CreateTestFormField("Expiration Date", "ccmonth", "", "text", &field); 236 test::CreateTestFormField("Expiration Date", "ccmonth", "", "text", &field);
272 form->fields.push_back(field); 237 form->fields.push_back(field);
273 test::CreateTestFormField("", "ccyear", "", "text", &field); 238 test::CreateTestFormField("", "ccyear", "", "text", &field);
274 form->fields.push_back(field); 239 form->fields.push_back(field);
275 } 240 }
276 } 241 }
277 242
278 void ExpectSuggestions(int page_id,
279 const std::vector<base::string16>& values,
280 const std::vector<base::string16>& labels,
281 const std::vector<base::string16>& icons,
282 const std::vector<int>& unique_ids,
283 int expected_page_id,
284 size_t expected_num_suggestions,
285 const base::string16 expected_values[],
286 const base::string16 expected_labels[],
287 const base::string16 expected_icons[],
288 const int expected_unique_ids[]) {
289 EXPECT_EQ(expected_page_id, page_id);
290 ASSERT_EQ(expected_num_suggestions, values.size());
291 ASSERT_EQ(expected_num_suggestions, labels.size());
292 ASSERT_EQ(expected_num_suggestions, icons.size());
293 ASSERT_EQ(expected_num_suggestions, unique_ids.size());
294 for (size_t i = 0; i < expected_num_suggestions; ++i) {
295 SCOPED_TRACE(base::StringPrintf("i: %" PRIuS, i));
296 EXPECT_EQ(expected_values[i], values[i]);
297 EXPECT_EQ(expected_labels[i], labels[i]);
298 EXPECT_EQ(expected_icons[i], icons[i]);
299 EXPECT_EQ(expected_unique_ids[i], unique_ids[i]);
300 }
301 }
302
303 void ExpectFilledField(const char* expected_label, 243 void ExpectFilledField(const char* expected_label,
304 const char* expected_name, 244 const char* expected_name,
305 const char* expected_value, 245 const char* expected_value,
306 const char* expected_form_control_type, 246 const char* expected_form_control_type,
307 const FormFieldData& field) { 247 const FormFieldData& field) {
308 SCOPED_TRACE(expected_label); 248 SCOPED_TRACE(expected_label);
309 EXPECT_EQ(UTF8ToUTF16(expected_label), field.label); 249 EXPECT_EQ(UTF8ToUTF16(expected_label), field.label);
310 EXPECT_EQ(UTF8ToUTF16(expected_name), field.name); 250 EXPECT_EQ(UTF8ToUTF16(expected_name), field.name);
311 EXPECT_EQ(UTF8ToUTF16(expected_value), field.value); 251 EXPECT_EQ(UTF8ToUTF16(expected_value), field.value);
312 EXPECT_EQ(expected_form_control_type, field.form_control_type); 252 EXPECT_EQ(expected_form_control_type, field.form_control_type);
(...skipping 2695 matching lines...) Expand 10 before | Expand all | Expand 10 after
3008 test::CreateTestAddressFormData(&form); 2948 test::CreateTestAddressFormData(&form);
3009 std::vector<FormData> forms(1, form); 2949 std::vector<FormData> forms(1, form);
3010 FormsSeen(forms); 2950 FormsSeen(forms);
3011 const FormFieldData& field = form.fields[0]; 2951 const FormFieldData& field = form.fields[0];
3012 GetAutofillSuggestions(form, field); // should call the delegate's OnQuery() 2952 GetAutofillSuggestions(form, field); // should call the delegate's OnQuery()
3013 2953
3014 EXPECT_TRUE(external_delegate_->on_query_seen()); 2954 EXPECT_TRUE(external_delegate_->on_query_seen());
3015 } 2955 }
3016 2956
3017 } // namespace autofill 2957 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/test/perf/generate_profile.cc ('k') | content/browser/browser_plugin/browser_plugin_host_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698