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/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 int AggregateProfilesIntoAutofillPrefs(const std::string& filename) { | 195 int AggregateProfilesIntoAutofillPrefs(const std::string& filename) { |
196 CHECK(test_server()->Start()); | 196 CHECK(test_server()->Start()); |
197 | 197 |
198 std::string data; | 198 std::string data; |
199 base::FilePath data_file = | 199 base::FilePath data_file = |
200 ui_test_utils::GetTestFilePath(base::FilePath().AppendASCII("autofill"), | 200 ui_test_utils::GetTestFilePath(base::FilePath().AppendASCII("autofill"), |
201 base::FilePath().AppendASCII(filename)); | 201 base::FilePath().AppendASCII(filename)); |
202 CHECK(file_util::ReadFileToString(data_file, &data)); | 202 CHECK(file_util::ReadFileToString(data_file, &data)); |
203 std::vector<std::string> lines; | 203 std::vector<std::string> lines; |
204 base::SplitString(data, '\n', &lines); | 204 base::SplitString(data, '\n', &lines); |
| 205 int parsed_profiles = 0; |
205 for (size_t i = 0; i < lines.size(); ++i) { | 206 for (size_t i = 0; i < lines.size(); ++i) { |
206 if (StartsWithASCII(lines[i], "#", false)) | 207 if (StartsWithASCII(lines[i], "#", false)) |
207 continue; | 208 continue; |
| 209 |
208 std::vector<std::string> fields; | 210 std::vector<std::string> fields; |
209 base::SplitString(lines[i], '|', &fields); | 211 base::SplitString(lines[i], '|', &fields); |
210 if (fields.empty()) | 212 if (fields.empty()) |
211 continue; // Blank line. | 213 continue; // Blank line. |
| 214 |
| 215 ++parsed_profiles; |
212 CHECK_EQ(12u, fields.size()); | 216 CHECK_EQ(12u, fields.size()); |
213 | 217 |
214 FormMap data; | 218 FormMap data; |
215 data["NAME_FIRST"] = fields[0]; | 219 data["NAME_FIRST"] = fields[0]; |
216 data["NAME_MIDDLE"] = fields[1]; | 220 data["NAME_MIDDLE"] = fields[1]; |
217 data["NAME_LAST"] = fields[2]; | 221 data["NAME_LAST"] = fields[2]; |
218 data["EMAIL_ADDRESS"] = fields[3]; | 222 data["EMAIL_ADDRESS"] = fields[3]; |
219 data["COMPANY_NAME"] = fields[4]; | 223 data["COMPANY_NAME"] = fields[4]; |
220 data["ADDRESS_HOME_LINE1"] = fields[5]; | 224 data["ADDRESS_HOME_LINE1"] = fields[5]; |
221 data["ADDRESS_HOME_LINE2"] = fields[6]; | 225 data["ADDRESS_HOME_LINE2"] = fields[6]; |
222 data["ADDRESS_HOME_CITY"] = fields[7]; | 226 data["ADDRESS_HOME_CITY"] = fields[7]; |
223 data["ADDRESS_HOME_STATE"] = fields[8]; | 227 data["ADDRESS_HOME_STATE"] = fields[8]; |
224 data["ADDRESS_HOME_ZIP"] = fields[9]; | 228 data["ADDRESS_HOME_ZIP"] = fields[9]; |
225 data["ADDRESS_HOME_COUNTRY"] = fields[10]; | 229 data["ADDRESS_HOME_COUNTRY"] = fields[10]; |
226 data["PHONE_HOME_WHOLE_NUMBER"] = fields[11]; | 230 data["PHONE_HOME_WHOLE_NUMBER"] = fields[11]; |
227 | 231 |
228 FillFormAndSubmit("duplicate_profiles_test.html", data); | 232 FillFormAndSubmit("duplicate_profiles_test.html", data); |
229 } | 233 } |
230 return lines.size(); | 234 return parsed_profiles; |
231 } | 235 } |
232 | 236 |
233 void ExpectFieldValue(const std::string& field_name, | 237 void ExpectFieldValue(const std::string& field_name, |
234 const std::string& expected_value) { | 238 const std::string& expected_value) { |
235 std::string value; | 239 std::string value; |
236 ASSERT_TRUE(content::ExecuteScriptAndExtractString( | 240 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
237 browser()->tab_strip_model()->GetActiveWebContents(), | 241 browser()->tab_strip_model()->GetActiveWebContents(), |
238 "window.domAutomationController.send(" | 242 "window.domAutomationController.send(" |
239 " document.getElementById('" + field_name + "').value);", | 243 " document.getElementById('" + field_name + "').value);", |
240 &value)); | 244 &value)); |
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
687 } | 691 } |
688 | 692 |
689 // Test that profiles merge for aggregated data with same address. | 693 // Test that profiles merge for aggregated data with same address. |
690 // The criterion for when two profiles are expected to be merged is when their | 694 // The criterion for when two profiles are expected to be merged is when their |
691 // 'Address Line 1' and 'City' data match. When two profiles are merged, any | 695 // 'Address Line 1' and 'City' data match. When two profiles are merged, any |
692 // remaining address fields are expected to be overwritten. Any non-address | 696 // remaining address fields are expected to be overwritten. Any non-address |
693 // fields should accumulate multi-valued data. | 697 // fields should accumulate multi-valued data. |
694 // DISABLED: http://crbug.com/150084 | 698 // DISABLED: http://crbug.com/150084 |
695 IN_PROC_BROWSER_TEST_F(AutofillTest, | 699 IN_PROC_BROWSER_TEST_F(AutofillTest, |
696 DISABLED_MergeAggregatedProfilesWithSameAddress) { | 700 DISABLED_MergeAggregatedProfilesWithSameAddress) { |
697 AggregateProfilesIntoAutofillPrefs("dataset_2.txt"); | 701 AggregateProfilesIntoAutofillPrefs("dataset_same_address.txt"); |
698 | 702 |
699 ASSERT_EQ(3u, personal_data_manager()->GetProfiles().size()); | 703 ASSERT_EQ(3u, personal_data_manager()->GetProfiles().size()); |
700 } | 704 } |
701 | 705 |
702 // Test profiles are not merged without mininum address values. | 706 // Test profiles are not merged without mininum address values. |
703 // Mininum address values needed during aggregation are: address line 1, city, | 707 // Mininum address values needed during aggregation are: address line 1, city, |
704 // state, and zip code. | 708 // state, and zip code. |
705 // Profiles are merged when data for address line 1 and city match. | 709 // Profiles are merged when data for address line 1 and city match. |
706 // DISABLED: http://crbug.com/150084 | 710 // DISABLED: http://crbug.com/150084 |
707 IN_PROC_BROWSER_TEST_F(AutofillTest, | 711 IN_PROC_BROWSER_TEST_F(AutofillTest, |
708 DISABLED_ProfilesNotMergedWhenNoMinAddressData) { | 712 DISABLED_ProfilesNotMergedWhenNoMinAddressData) { |
709 AggregateProfilesIntoAutofillPrefs("dataset_no_address.txt"); | 713 AggregateProfilesIntoAutofillPrefs("dataset_no_address.txt"); |
710 | 714 |
711 ASSERT_EQ(0u, personal_data_manager()->GetProfiles().size()); | 715 ASSERT_EQ(0u, personal_data_manager()->GetProfiles().size()); |
712 } | 716 } |
713 | 717 |
714 // Test Autofill ability to merge duplicate profiles and throw away junk. | 718 // Test Autofill ability to merge duplicate profiles and throw away junk. |
715 // TODO(isherman): this looks redundant, consider removing. | 719 // TODO(isherman): this looks redundant, consider removing. |
716 // DISABLED: http://crbug.com/150084 | 720 // DISABLED: http://crbug.com/150084 |
717 IN_PROC_BROWSER_TEST_F(AutofillTest, | 721 IN_PROC_BROWSER_TEST_F(AutofillTest, |
718 DISABLED_MergeAggregatedDuplicatedProfiles) { | 722 DISABLED_MergeAggregatedDuplicatedProfiles) { |
719 int num_of_profiles = | 723 int num_of_profiles = |
720 AggregateProfilesIntoAutofillPrefs("dataset_no_address.txt"); | 724 AggregateProfilesIntoAutofillPrefs("dataset_duplicated_profiles.txt"); |
721 | 725 |
722 ASSERT_GT(num_of_profiles, | 726 ASSERT_GT(num_of_profiles, |
723 static_cast<int>(personal_data_manager()->GetProfiles().size())); | 727 static_cast<int>(personal_data_manager()->GetProfiles().size())); |
724 } | 728 } |
725 | 729 |
726 } // namespace autofill | 730 } // namespace autofill |
OLD | NEW |