OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 // Aggregate profiles from forms into Autofill preferences. Returns the number | 235 // Aggregate profiles from forms into Autofill preferences. Returns the number |
236 // of parsed profiles. | 236 // of parsed profiles. |
237 int AggregateProfilesIntoAutofillPrefs(const std::string& filename) { | 237 int AggregateProfilesIntoAutofillPrefs(const std::string& filename) { |
238 CHECK(test_server()->Start()); | 238 CHECK(test_server()->Start()); |
239 | 239 |
240 std::string data; | 240 std::string data; |
241 base::FilePath data_file = | 241 base::FilePath data_file = |
242 ui_test_utils::GetTestFilePath(base::FilePath().AppendASCII("autofill"), | 242 ui_test_utils::GetTestFilePath(base::FilePath().AppendASCII("autofill"), |
243 base::FilePath().AppendASCII(filename)); | 243 base::FilePath().AppendASCII(filename)); |
244 CHECK(base::ReadFileToString(data_file, &data)); | 244 CHECK(base::ReadFileToString(data_file, &data)); |
245 std::vector<std::string> lines; | 245 std::vector<std::string> lines = base::SplitString( |
246 base::SplitString(data, '\n', &lines); | 246 data, "\n", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
247 int parsed_profiles = 0; | 247 int parsed_profiles = 0; |
248 for (size_t i = 0; i < lines.size(); ++i) { | 248 for (size_t i = 0; i < lines.size(); ++i) { |
249 if (base::StartsWith(lines[i], "#", base::CompareCase::SENSITIVE)) | 249 if (base::StartsWith(lines[i], "#", base::CompareCase::SENSITIVE)) |
250 continue; | 250 continue; |
251 | 251 |
252 std::vector<std::string> fields = base::SplitString( | 252 std::vector<std::string> fields = base::SplitString( |
253 lines[i], "|", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); | 253 lines[i], "|", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
254 if (fields.empty()) | 254 if (fields.empty()) |
255 continue; // Blank line. | 255 continue; // Blank line. |
256 | 256 |
(...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
943 IN_PROC_BROWSER_TEST_F(AutofillTest, | 943 IN_PROC_BROWSER_TEST_F(AutofillTest, |
944 DISABLED_MergeAggregatedDuplicatedProfiles) { | 944 DISABLED_MergeAggregatedDuplicatedProfiles) { |
945 int num_of_profiles = | 945 int num_of_profiles = |
946 AggregateProfilesIntoAutofillPrefs("dataset_duplicated_profiles.txt"); | 946 AggregateProfilesIntoAutofillPrefs("dataset_duplicated_profiles.txt"); |
947 | 947 |
948 ASSERT_GT(num_of_profiles, | 948 ASSERT_GT(num_of_profiles, |
949 static_cast<int>(personal_data_manager()->GetProfiles().size())); | 949 static_cast<int>(personal_data_manager()->GetProfiles().size())); |
950 } | 950 } |
951 | 951 |
952 } // namespace autofill | 952 } // namespace autofill |
OLD | NEW |