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

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: Rebase 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 void CreateTestAddressFormData(FormData* form) {
40 form->name = ASCIIToUTF16("MyForm");
41 form->method = ASCIIToUTF16("POST");
42 form->origin = GURL("http://myform.com/form.html");
43 form->action = GURL("http://myform.com/submit.html");
44 form->user_submitted = true;
45
46 FormFieldData field;
47 test::CreateTestFormField("First Name", "firstname", "", "text", &field);
48 form->fields.push_back(field);
49 test::CreateTestFormField("Middle Name", "middlename", "", "text", &field);
50 form->fields.push_back(field);
51 test::CreateTestFormField("Last Name", "lastname", "", "text", &field);
52 form->fields.push_back(field);
53 test::CreateTestFormField("Address Line 1", "addr1", "", "text", &field);
54 form->fields.push_back(field);
55 test::CreateTestFormField("Address Line 2", "addr2", "", "text", &field);
56 form->fields.push_back(field);
57 test::CreateTestFormField("City", "city", "", "text", &field);
58 form->fields.push_back(field);
59 test::CreateTestFormField("State", "state", "", "text", &field);
60 form->fields.push_back(field);
61 test::CreateTestFormField("Postal Code", "zipcode", "", "text", &field);
62 form->fields.push_back(field);
63 test::CreateTestFormField("Country", "country", "", "text", &field);
64 form->fields.push_back(field);
65 test::CreateTestFormField("Phone Number", "phonenumber", "", "tel", &field);
66 form->fields.push_back(field);
67 test::CreateTestFormField("Email", "email", "", "email", &field);
68 form->fields.push_back(field);
69 }
70
38 inline void check_and_set( 71 inline void check_and_set(
39 FormGroup* profile, AutofillFieldType type, const char* value) { 72 FormGroup* profile, AutofillFieldType type, const char* value) {
40 if (value) 73 if (value)
41 profile->SetRawInfo(type, UTF8ToUTF16(value)); 74 profile->SetRawInfo(type, UTF8ToUTF16(value));
42 } 75 }
43 76
44 AutofillProfile GetFullProfile() { 77 AutofillProfile GetFullProfile() {
45 AutofillProfile profile(base::GenerateGUID(), "http://www.example.com/"); 78 AutofillProfile profile(base::GenerateGUID(), "http://www.example.com/");
46 SetProfileInfo(&profile, 79 SetProfileInfo(&profile,
47 "John", 80 "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 184 // Disable auxiliary profiles for unit testing. These reach out to system
152 // services on the Mac. 185 // services on the Mac.
153 if (browser_context) { 186 if (browser_context) {
154 user_prefs::UserPrefs::Get(browser_context)->SetBoolean( 187 user_prefs::UserPrefs::Get(browser_context)->SetBoolean(
155 prefs::kAutofillAuxiliaryProfilesEnabled, false); 188 prefs::kAutofillAuxiliaryProfilesEnabled, false);
156 } 189 }
157 } 190 }
158 191
159 } // namespace test 192 } // namespace test
160 } // namespace autofill 193 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/autofill_common_test.h ('k') | components/autofill/core/browser/autofill_driver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698