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

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

Issue 2226063002: Add a ScopedFeatureList class for testing and start using it. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix issue in previous patchset. Created 4 years, 4 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
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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include <map> 7 #include <map>
8 #include <memory> 8 #include <memory>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/feature_list.h" 11 #include "base/feature_list.h"
12 #include "base/files/file_enumerator.h" 12 #include "base/files/file_enumerator.h"
13 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/path_service.h" 15 #include "base/path_service.h"
16 #include "base/strings/string_split.h" 16 #include "base/strings/string_split.h"
17 #include "base/strings/string_util.h" 17 #include "base/strings/string_util.h"
18 #include "base/strings/utf_string_conversions.h" 18 #include "base/strings/utf_string_conversions.h"
19 #include "base/test/scoped_feature_list.h"
19 #include "components/autofill/core/browser/autofill_experiments.h" 20 #include "components/autofill/core/browser/autofill_experiments.h"
20 #include "components/autofill/core/browser/autofill_test_utils.h" 21 #include "components/autofill/core/browser/autofill_test_utils.h"
21 #include "components/autofill/core/browser/autofill_type.h" 22 #include "components/autofill/core/browser/autofill_type.h"
22 #include "components/autofill/core/browser/country_names.h" 23 #include "components/autofill/core/browser/country_names.h"
23 #include "components/autofill/core/browser/data_driven_test.h" 24 #include "components/autofill/core/browser/data_driven_test.h"
24 #include "components/autofill/core/browser/form_structure.h" 25 #include "components/autofill/core/browser/form_structure.h"
25 #include "components/autofill/core/browser/personal_data_manager.h" 26 #include "components/autofill/core/browser/personal_data_manager.h"
26 #include "components/autofill/core/common/form_data.h" 27 #include "components/autofill/core/common/form_data.h"
27 #include "testing/gtest/include/gtest/gtest.h" 28 #include "testing/gtest/include/gtest/gtest.h"
28 #include "url/gurl.h" 29 #include "url/gurl.h"
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 // Deserializes a set of Autofill profiles from |profiles|, imports each 177 // Deserializes a set of Autofill profiles from |profiles|, imports each
177 // sequentially, and fills |merged_profiles| with the serialized result. 178 // sequentially, and fills |merged_profiles| with the serialized result.
178 void MergeProfiles(const std::string& profiles, std::string* merged_profiles); 179 void MergeProfiles(const std::string& profiles, std::string* merged_profiles);
179 180
180 // Deserializes |str| into a field type. 181 // Deserializes |str| into a field type.
181 ServerFieldType StringToFieldType(const std::string& str); 182 ServerFieldType StringToFieldType(const std::string& str);
182 183
183 PersonalDataManagerMock personal_data_; 184 PersonalDataManagerMock personal_data_;
184 185
185 private: 186 private:
187 base::test::ScopedFeatureList scoped_feature_list_;
186 std::map<std::string, ServerFieldType> string_to_field_type_map_; 188 std::map<std::string, ServerFieldType> string_to_field_type_map_;
187 189
188 DISALLOW_COPY_AND_ASSIGN(AutofillMergeTest); 190 DISALLOW_COPY_AND_ASSIGN(AutofillMergeTest);
189 }; 191 };
190 192
191 AutofillMergeTest::AutofillMergeTest() : DataDrivenTest(GetTestDataDir()) { 193 AutofillMergeTest::AutofillMergeTest() : DataDrivenTest(GetTestDataDir()) {
192 CountryNames::SetLocaleString("en-US"); 194 CountryNames::SetLocaleString("en-US");
193 for (size_t i = NO_SERVER_DATA; i < MAX_VALID_FIELD_TYPE; ++i) { 195 for (size_t i = NO_SERVER_DATA; i < MAX_VALID_FIELD_TYPE; ++i) {
194 ServerFieldType field_type = static_cast<ServerFieldType>(i); 196 ServerFieldType field_type = static_cast<ServerFieldType>(i);
195 string_to_field_type_map_[AutofillType(field_type).ToString()] = field_type; 197 string_to_field_type_map_[AutofillType(field_type).ToString()] = field_type;
196 } 198 }
197 } 199 }
198 200
199 AutofillMergeTest::~AutofillMergeTest() { 201 AutofillMergeTest::~AutofillMergeTest() {
200 } 202 }
201 203
202 void AutofillMergeTest::SetUp() { 204 void AutofillMergeTest::SetUp() {
203 test::DisableSystemServices(nullptr); 205 test::DisableSystemServices(nullptr);
204 206 scoped_feature_list_.InitAndEnableFeature(kAutofillProfileCleanup);
205 base::FeatureList::ClearInstanceForTesting();
206 std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList);
207 feature_list->InitializeFromCommandLine(kAutofillProfileCleanup.name,
208 std::string());
209 base::FeatureList::SetInstance(std::move(feature_list));
210 } 207 }
211 208
212 void AutofillMergeTest::TearDown() { 209 void AutofillMergeTest::TearDown() {
213 test::ReenableSystemServices(); 210 test::ReenableSystemServices();
214 } 211 }
215 212
216 void AutofillMergeTest::GenerateResults(const std::string& input, 213 void AutofillMergeTest::GenerateResults(const std::string& input,
217 std::string* output) { 214 std::string* output) {
218 MergeProfiles(input, output); 215 MergeProfiles(input, output);
219 } 216 }
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 return string_to_field_type_map_[str]; 289 return string_to_field_type_map_[str];
293 } 290 }
294 291
295 TEST_P(AutofillMergeTest, DataDrivenMergeProfiles) { 292 TEST_P(AutofillMergeTest, DataDrivenMergeProfiles) {
296 RunOneDataDrivenTest(GetParam(), GetOutputDirectory(kTestName)); 293 RunOneDataDrivenTest(GetParam(), GetOutputDirectory(kTestName));
297 } 294 }
298 295
299 INSTANTIATE_TEST_CASE_P(, AutofillMergeTest, testing::ValuesIn(GetTestFiles())); 296 INSTANTIATE_TEST_CASE_P(, AutofillMergeTest, testing::ValuesIn(GetTestFiles()));
300 297
301 } // namespace autofill 298 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698