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

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

Issue 347183005: autofill names - dont parse when calling SetRawInfo(FULL_NAME) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix android test expectation Created 6 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 <string> 5 #include <string>
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/files/scoped_temp_dir.h" 8 #include "base/files/scoped_temp_dir.h"
9 #include "base/guid.h" 9 #include "base/guid.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 1079 matching lines...) Expand 10 before | Expand all | Expand 10 after
1090 ASSERT_FALSE(imported_credit_card); 1090 ASSERT_FALSE(imported_credit_card);
1091 1091
1092 // Verify that the web database has been updated and the notification sent. 1092 // Verify that the web database has been updated and the notification sent.
1093 EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) 1093 EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged())
1094 .WillOnce(QuitMainMessageLoop()); 1094 .WillOnce(QuitMainMessageLoop());
1095 base::MessageLoop::current()->Run(); 1095 base::MessageLoop::current()->Run();
1096 1096
1097 const std::vector<AutofillProfile*>& results2 = personal_data_->GetProfiles(); 1097 const std::vector<AutofillProfile*>& results2 = personal_data_->GetProfiles();
1098 1098
1099 // Modify expected to include multi-valued fields. 1099 // Modify expected to include multi-valued fields.
1100 std::vector<base::string16> values; 1100 std::vector<base::string16> first_names, last_names, emails;
1101 expected.GetRawMultiInfo(NAME_FULL, &values); 1101 expected.GetRawMultiInfo(NAME_FIRST, &first_names);
1102 values.push_back(ASCIIToUTF16("John Adams")); 1102 first_names.push_back(ASCIIToUTF16("John"));
1103 expected.SetRawMultiInfo(NAME_FULL, values); 1103 expected.GetRawMultiInfo(NAME_LAST, &last_names);
1104 expected.GetRawMultiInfo(EMAIL_ADDRESS, &values); 1104 last_names.push_back(ASCIIToUTF16("Adams"));
1105 values.push_back(ASCIIToUTF16("second@gmail.com")); 1105 expected.SetRawMultiInfo(NAME_FIRST, first_names);
1106 expected.SetRawMultiInfo(EMAIL_ADDRESS, values); 1106 expected.SetRawMultiInfo(NAME_LAST, last_names);
1107
1108 expected.GetRawMultiInfo(EMAIL_ADDRESS, &emails);
1109 emails.push_back(ASCIIToUTF16("second@gmail.com"));
1110 expected.SetRawMultiInfo(EMAIL_ADDRESS, emails);
1107 1111
1108 ASSERT_EQ(1U, results2.size()); 1112 ASSERT_EQ(1U, results2.size());
1109 EXPECT_EQ(0, expected.Compare(*results2[0])); 1113 EXPECT_EQ(0, expected.Compare(*results2[0]));
1110 } 1114 }
1111 1115
1112 TEST_F(PersonalDataManagerTest, AggregateSameProfileWithConflict) { 1116 TEST_F(PersonalDataManagerTest, AggregateSameProfileWithConflict) {
1113 FormData form1; 1117 FormData form1;
1114 FormFieldData field; 1118 FormFieldData field;
1115 test::CreateTestFormField( 1119 test::CreateTestFormField(
1116 "First name:", "first_name", "George", "text", &field); 1120 "First name:", "first_name", "George", "text", &field);
(...skipping 995 matching lines...) Expand 10 before | Expand all | Expand 10 after
2112 personal_data_->SaveImportedProfile(new_verified_profile); 2116 personal_data_->SaveImportedProfile(new_verified_profile);
2113 2117
2114 // Verify that the web database has been updated and the notification sent. 2118 // Verify that the web database has been updated and the notification sent.
2115 EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) 2119 EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged())
2116 .WillOnce(QuitMainMessageLoop()); 2120 .WillOnce(QuitMainMessageLoop());
2117 base::MessageLoop::current()->Run(); 2121 base::MessageLoop::current()->Run();
2118 2122
2119 // The new profile should be merged into the existing one. 2123 // The new profile should be merged into the existing one.
2120 AutofillProfile expected_profile = new_verified_profile; 2124 AutofillProfile expected_profile = new_verified_profile;
2121 expected_profile.set_guid(profile.guid()); 2125 expected_profile.set_guid(profile.guid());
2122 std::vector<base::string16> names; 2126 std::vector<base::string16> first_names, middle_names, last_names;
2123 expected_profile.GetRawMultiInfo(NAME_FULL, &names); 2127 expected_profile.GetRawMultiInfo(NAME_FIRST, &first_names);
2124 names.insert(names.begin(), ASCIIToUTF16("Marion Mitchell Morrison")); 2128 expected_profile.GetRawMultiInfo(NAME_MIDDLE, &middle_names);
2125 expected_profile.SetRawMultiInfo(NAME_FULL, names); 2129 expected_profile.GetRawMultiInfo(NAME_LAST, &last_names);
2130 first_names.insert(first_names.begin(), ASCIIToUTF16("Marion"));
2131 middle_names.insert(middle_names.begin(), ASCIIToUTF16("Mitchell"));
2132 last_names.insert(last_names.begin(), ASCIIToUTF16("Morrison"));
2133 expected_profile.SetRawMultiInfo(NAME_FIRST, first_names);
2134 expected_profile.SetRawMultiInfo(NAME_MIDDLE, middle_names);
2135 expected_profile.SetRawMultiInfo(NAME_LAST, last_names);
2126 2136
2127 const std::vector<AutofillProfile*>& results = personal_data_->GetProfiles(); 2137 const std::vector<AutofillProfile*>& results = personal_data_->GetProfiles();
2128 ASSERT_EQ(1U, results.size()); 2138 ASSERT_EQ(1U, results.size());
2129 EXPECT_EQ(expected_profile, *results[0]); 2139 EXPECT_EQ(expected_profile, *results[0]);
2130 } 2140 }
2131 2141
2132 // Ensure that verified credit cards can be saved via SaveImportedCreditCard. 2142 // Ensure that verified credit cards can be saved via SaveImportedCreditCard.
2133 TEST_F(PersonalDataManagerTest, SaveImportedCreditCardWithVerifiedData) { 2143 TEST_F(PersonalDataManagerTest, SaveImportedCreditCardWithVerifiedData) {
2134 // Start with a verified credit card. 2144 // Start with a verified credit card.
2135 CreditCard credit_card(base::GenerateGUID(), "Chrome settings"); 2145 CreditCard credit_card(base::GenerateGUID(), "Chrome settings");
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
2558 .WillOnce(QuitMainMessageLoop()); 2568 .WillOnce(QuitMainMessageLoop());
2559 base::MessageLoop::current()->Run(); 2569 base::MessageLoop::current()->Run();
2560 2570
2561 const std::vector<AutofillProfile*>& results = personal_data_->GetProfiles(); 2571 const std::vector<AutofillProfile*>& results = personal_data_->GetProfiles();
2562 ASSERT_EQ(1U, results.size()); 2572 ASSERT_EQ(1U, results.size());
2563 EXPECT_EQ(0, profile.Compare(*results[0])); 2573 EXPECT_EQ(0, profile.Compare(*results[0]));
2564 EXPECT_EQ("en", results[0]->language_code()); 2574 EXPECT_EQ("en", results[0]->language_code());
2565 } 2575 }
2566 2576
2567 } // namespace autofill 2577 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698