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

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

Issue 17572015: Begin abstracting sending of IPC from autofill core code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Response to review, add tests Created 7 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 "components/autofill/core/browser/autofill_common_test.h" 5 #include "components/autofill/core/browser/autofill_common_test.h"
6 6
7 #include "base/guid.h" 7 #include "base/guid.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "components/autofill/core/browser/autofill_profile.h" 10 #include "components/autofill/core/browser/autofill_profile.h"
11 #include "components/autofill/core/browser/credit_card.h" 11 #include "components/autofill/core/browser/credit_card.h"
12 #include "components/autofill/core/common/autofill_pref_names.h" 12 #include "components/autofill/core/common/autofill_pref_names.h"
13 #include "components/autofill/core/common/form_data.h"
13 #include "components/autofill/core/common/form_field_data.h" 14 #include "components/autofill/core/common/form_field_data.h"
14 #include "components/user_prefs/user_prefs.h" 15 #include "components/user_prefs/user_prefs.h"
15 #include "components/webdata/encryptor/encryptor.h" 16 #include "components/webdata/encryptor/encryptor.h"
16 #include "content/public/browser/browser_context.h" 17 #include "content/public/browser/browser_context.h"
17 18
18 namespace autofill { 19 namespace autofill {
19 namespace test { 20 namespace test {
20 21
21 namespace { 22 namespace {
22 23
23 const char kSettingsOrigin[] = "Chrome settings"; 24 const char kSettingsOrigin[] = "Chrome settings";
24 25
25 } // namespace 26 } // namespace
26 27
27 void CreateTestFormField(const char* label, 28 void CreateTestFormField(const char* label,
28 const char* name, 29 const char* name,
29 const char* value, 30 const char* value,
30 const char* type, 31 const char* type,
31 FormFieldData* field) { 32 FormFieldData* field) {
32 field->label = ASCIIToUTF16(label); 33 field->label = ASCIIToUTF16(label);
33 field->name = ASCIIToUTF16(name); 34 field->name = ASCIIToUTF16(name);
34 field->value = ASCIIToUTF16(value); 35 field->value = ASCIIToUTF16(value);
35 field->form_control_type = type; 36 field->form_control_type = type;
36 } 37 }
37 38
39 // Populates |form| with data corresponding to a simple address form.
40 // Note that this actually appends fields to the form data, which can be useful
41 // for building up more complex test forms.
Ilya Sherman 2013/06/26 22:54:58 nit: This comment is duplicated from the header.
blundell 2013/06/27 21:58:27 Done.
42 void CreateTestAddressFormData(FormData* form) {
43 form->name = ASCIIToUTF16("MyForm");
44 form->method = ASCIIToUTF16("POST");
45 form->origin = GURL("http://myform.com/form.html");
46 form->action = GURL("http://myform.com/submit.html");
47 form->user_submitted = true;
48
49 FormFieldData field;
50 test::CreateTestFormField("First Name", "firstname", "", "text", &field);
51 form->fields.push_back(field);
52 test::CreateTestFormField("Middle Name", "middlename", "", "text", &field);
53 form->fields.push_back(field);
54 test::CreateTestFormField("Last Name", "lastname", "", "text", &field);
55 form->fields.push_back(field);
56 test::CreateTestFormField("Address Line 1", "addr1", "", "text", &field);
57 form->fields.push_back(field);
58 test::CreateTestFormField("Address Line 2", "addr2", "", "text", &field);
59 form->fields.push_back(field);
60 test::CreateTestFormField("City", "city", "", "text", &field);
61 form->fields.push_back(field);
62 test::CreateTestFormField("State", "state", "", "text", &field);
63 form->fields.push_back(field);
64 test::CreateTestFormField("Postal Code", "zipcode", "", "text", &field);
65 form->fields.push_back(field);
66 test::CreateTestFormField("Country", "country", "", "text", &field);
67 form->fields.push_back(field);
68 test::CreateTestFormField("Phone Number", "phonenumber", "", "tel", &field);
69 form->fields.push_back(field);
70 test::CreateTestFormField("Email", "email", "", "email", &field);
71 form->fields.push_back(field);
72 }
73
38 inline void check_and_set( 74 inline void check_and_set(
39 FormGroup* profile, AutofillFieldType type, const char* value) { 75 FormGroup* profile, AutofillFieldType type, const char* value) {
40 if (value) 76 if (value)
41 profile->SetRawInfo(type, UTF8ToUTF16(value)); 77 profile->SetRawInfo(type, UTF8ToUTF16(value));
42 } 78 }
43 79
44 AutofillProfile GetFullProfile() { 80 AutofillProfile GetFullProfile() {
45 AutofillProfile profile(base::GenerateGUID(), "http://www.example.com/"); 81 AutofillProfile profile(base::GenerateGUID(), "http://www.example.com/");
46 SetProfileInfo(&profile, 82 SetProfileInfo(&profile,
47 "John", 83 "John",
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 // Disable auxiliary profiles for unit testing. These reach out to system 187 // Disable auxiliary profiles for unit testing. These reach out to system
152 // services on the Mac. 188 // services on the Mac.
153 if (browser_context) { 189 if (browser_context) {
154 user_prefs::UserPrefs::Get(browser_context)->SetBoolean( 190 user_prefs::UserPrefs::Get(browser_context)->SetBoolean(
155 prefs::kAutofillAuxiliaryProfilesEnabled, false); 191 prefs::kAutofillAuxiliaryProfilesEnabled, false);
156 } 192 }
157 } 193 }
158 194
159 } // namespace test 195 } // namespace test
160 } // namespace autofill 196 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698