OLD | NEW |
---|---|
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/prefs/pref_service_builder.h" | |
10 #include "base/prefs/testing_pref_store.h" | |
9 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
12 #include "components/autofill/core/browser/autofill_manager.h" | |
10 #include "components/autofill/core/browser/autofill_profile.h" | 13 #include "components/autofill/core/browser/autofill_profile.h" |
11 #include "components/autofill/core/browser/credit_card.h" | 14 #include "components/autofill/core/browser/credit_card.h" |
12 #include "components/autofill/core/browser/field_types.h" | 15 #include "components/autofill/core/browser/field_types.h" |
13 #include "components/autofill/core/common/autofill_pref_names.h" | 16 #include "components/autofill/core/common/autofill_pref_names.h" |
14 #include "components/autofill/core/common/form_data.h" | 17 #include "components/autofill/core/common/form_data.h" |
15 #include "components/autofill/core/common/form_field_data.h" | 18 #include "components/autofill/core/common/form_field_data.h" |
19 #include "components/user_prefs/pref_registry_syncable.h" | |
16 #include "components/user_prefs/user_prefs.h" | 20 #include "components/user_prefs/user_prefs.h" |
17 #include "components/webdata/encryptor/encryptor.h" | 21 #include "components/webdata/encryptor/encryptor.h" |
18 #include "content/public/browser/browser_context.h" | 22 #include "content/public/browser/browser_context.h" |
19 | 23 |
20 namespace autofill { | 24 namespace autofill { |
21 namespace test { | 25 namespace test { |
22 | 26 |
23 namespace { | 27 namespace { |
24 | 28 |
25 const char kSettingsOrigin[] = "Chrome settings"; | 29 const char kSettingsOrigin[] = "Chrome settings"; |
26 | 30 |
27 } // namespace | 31 } // namespace |
28 | 32 |
33 scoped_ptr<PrefService> PrefServiceForTesting() { | |
34 scoped_refptr<user_prefs::PrefRegistrySyncable> registry( | |
35 new user_prefs::PrefRegistrySyncable()); | |
36 AutofillManager::RegisterProfilePrefs(registry.get()); | |
37 PrefServiceBuilder builder; | |
38 builder.WithUserPrefs(new TestingPrefStore()); | |
Ilya Sherman
2013/11/05 18:50:49
nit: Probably best to leave to a separate CL, but
blundell
2013/11/06 10:37:20
Strongly agreed. I filed crbug.com/315499.
On 201
| |
39 return scoped_ptr<PrefService>(builder.Create(registry.get())); | |
40 } | |
41 | |
29 void CreateTestFormField(const char* label, | 42 void CreateTestFormField(const char* label, |
30 const char* name, | 43 const char* name, |
31 const char* value, | 44 const char* value, |
32 const char* type, | 45 const char* type, |
33 FormFieldData* field) { | 46 FormFieldData* field) { |
34 field->label = ASCIIToUTF16(label); | 47 field->label = ASCIIToUTF16(label); |
35 field->name = ASCIIToUTF16(name); | 48 field->name = ASCIIToUTF16(name); |
36 field->value = ASCIIToUTF16(value); | 49 field->value = ASCIIToUTF16(value); |
37 field->form_control_type = type; | 50 field->form_control_type = type; |
38 } | 51 } |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
198 // Disable auxiliary profiles for unit testing. These reach out to system | 211 // Disable auxiliary profiles for unit testing. These reach out to system |
199 // services on the Mac. | 212 // services on the Mac. |
200 if (browser_context) { | 213 if (browser_context) { |
201 user_prefs::UserPrefs::Get(browser_context)->SetBoolean( | 214 user_prefs::UserPrefs::Get(browser_context)->SetBoolean( |
202 prefs::kAutofillAuxiliaryProfilesEnabled, false); | 215 prefs::kAutofillAuxiliaryProfilesEnabled, false); |
203 } | 216 } |
204 } | 217 } |
205 | 218 |
206 } // namespace test | 219 } // namespace test |
207 } // namespace autofill | 220 } // namespace autofill |
OLD | NEW |