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

Side by Side Diff: components/webdata/autofill/autofill_table_unittest.cc

Issue 13973004: Convert string16 -> base::string16 in components/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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 (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 <vector> 5 #include <vector>
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.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/path_service.h" 10 #include "base/path_service.h"
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 131
132 // Simulate the submission of a handful of entries in a field called "Name", 132 // Simulate the submission of a handful of entries in a field called "Name",
133 // some more often than others. 133 // some more often than others.
134 AutofillChangeList changes; 134 AutofillChangeList changes;
135 FormFieldData field; 135 FormFieldData field;
136 field.name = ASCIIToUTF16("Name"); 136 field.name = ASCIIToUTF16("Name");
137 field.value = ASCIIToUTF16("Superman"); 137 field.value = ASCIIToUTF16("Superman");
138 base::Time now = base::Time::Now(); 138 base::Time now = base::Time::Now();
139 base::TimeDelta two_seconds = base::TimeDelta::FromSeconds(2); 139 base::TimeDelta two_seconds = base::TimeDelta::FromSeconds(2);
140 EXPECT_TRUE(table_->AddFormFieldValue(field, &changes)); 140 EXPECT_TRUE(table_->AddFormFieldValue(field, &changes));
141 std::vector<string16> v; 141 std::vector<base::string16> v;
142 for (int i = 0; i < 5; i++) { 142 for (int i = 0; i < 5; i++) {
143 field.value = ASCIIToUTF16("Clark Kent"); 143 field.value = ASCIIToUTF16("Clark Kent");
144 EXPECT_TRUE(table_->AddFormFieldValueTime(field, &changes, 144 EXPECT_TRUE(table_->AddFormFieldValueTime(field, &changes,
145 now + i * two_seconds)); 145 now + i * two_seconds));
146 } 146 }
147 for (int i = 0; i < 3; i++) { 147 for (int i = 0; i < 3; i++) {
148 field.value = ASCIIToUTF16("Clark Sutter"); 148 field.value = ASCIIToUTF16("Clark Sutter");
149 EXPECT_TRUE(table_->AddFormFieldValueTime(field, &changes, 149 EXPECT_TRUE(table_->AddFormFieldValueTime(field, &changes,
150 now + i * two_seconds)); 150 now + i * two_seconds));
151 } 151 }
(...skipping 24 matching lines...) Expand all
176 field.name = ASCIIToUTF16("Favorite Color"); 176 field.name = ASCIIToUTF16("Favorite Color");
177 field.value = ASCIIToUTF16("Green"); 177 field.value = ASCIIToUTF16("Green");
178 EXPECT_TRUE(table_->GetIDAndCountOfFormElement(field, &pair_id, &count)); 178 EXPECT_TRUE(table_->GetIDAndCountOfFormElement(field, &pair_id, &count));
179 EXPECT_EQ(2, count); 179 EXPECT_EQ(2, count);
180 180
181 // This is meant to get a list of suggestions for Name. The empty prefix 181 // This is meant to get a list of suggestions for Name. The empty prefix
182 // in the second argument means it should return all suggestions for a name 182 // in the second argument means it should return all suggestions for a name
183 // no matter what they start with. The order that the names occur in the list 183 // no matter what they start with. The order that the names occur in the list
184 // should be decreasing order by count. 184 // should be decreasing order by count.
185 EXPECT_TRUE(table_->GetFormValuesForElementName( 185 EXPECT_TRUE(table_->GetFormValuesForElementName(
186 ASCIIToUTF16("Name"), string16(), &v, 6)); 186 ASCIIToUTF16("Name"), base::string16(), &v, 6));
187 EXPECT_EQ(3U, v.size()); 187 EXPECT_EQ(3U, v.size());
188 if (v.size() == 3) { 188 if (v.size() == 3) {
189 EXPECT_EQ(ASCIIToUTF16("Clark Kent"), v[0]); 189 EXPECT_EQ(ASCIIToUTF16("Clark Kent"), v[0]);
190 EXPECT_EQ(ASCIIToUTF16("Clark Sutter"), v[1]); 190 EXPECT_EQ(ASCIIToUTF16("Clark Sutter"), v[1]);
191 EXPECT_EQ(ASCIIToUTF16("Superman"), v[2]); 191 EXPECT_EQ(ASCIIToUTF16("Superman"), v[2]);
192 } 192 }
193 193
194 // If we query again limiting the list size to 1, we should only get the most 194 // If we query again limiting the list size to 1, we should only get the most
195 // frequent entry. 195 // frequent entry.
196 EXPECT_TRUE(table_->GetFormValuesForElementName( 196 EXPECT_TRUE(table_->GetFormValuesForElementName(
197 ASCIIToUTF16("Name"), string16(), &v, 1)); 197 ASCIIToUTF16("Name"), base::string16(), &v, 1));
198 EXPECT_EQ(1U, v.size()); 198 EXPECT_EQ(1U, v.size());
199 if (v.size() == 1) { 199 if (v.size() == 1) {
200 EXPECT_EQ(ASCIIToUTF16("Clark Kent"), v[0]); 200 EXPECT_EQ(ASCIIToUTF16("Clark Kent"), v[0]);
201 } 201 }
202 202
203 // Querying for suggestions given a prefix is case-insensitive, so the prefix 203 // Querying for suggestions given a prefix is case-insensitive, so the prefix
204 // "cLa" shoud get suggestions for both Clarks. 204 // "cLa" shoud get suggestions for both Clarks.
205 EXPECT_TRUE(table_->GetFormValuesForElementName( 205 EXPECT_TRUE(table_->GetFormValuesForElementName(
206 ASCIIToUTF16("Name"), ASCIIToUTF16("cLa"), &v, 6)); 206 ASCIIToUTF16("Name"), ASCIIToUTF16("cLa"), &v, 6));
207 EXPECT_EQ(2U, v.size()); 207 EXPECT_EQ(2U, v.size());
(...skipping 25 matching lines...) Expand all
233 for (size_t i = 0; i < arraysize(expected_changes); i++) { 233 for (size_t i = 0; i < arraysize(expected_changes); i++) {
234 EXPECT_EQ(expected_changes[i], changes[i]); 234 EXPECT_EQ(expected_changes[i], changes[i]);
235 } 235 }
236 236
237 field.name = ASCIIToUTF16("Name"); 237 field.name = ASCIIToUTF16("Name");
238 field.value = ASCIIToUTF16("Clark Kent"); 238 field.value = ASCIIToUTF16("Clark Kent");
239 EXPECT_TRUE(table_->GetIDAndCountOfFormElement(field, &pair_id, &count)); 239 EXPECT_TRUE(table_->GetIDAndCountOfFormElement(field, &pair_id, &count));
240 EXPECT_EQ(0, count); 240 EXPECT_EQ(0, count);
241 241
242 EXPECT_TRUE(table_->GetFormValuesForElementName( 242 EXPECT_TRUE(table_->GetFormValuesForElementName(
243 ASCIIToUTF16("Name"), string16(), &v, 6)); 243 ASCIIToUTF16("Name"), base::string16(), &v, 6));
244 EXPECT_EQ(0U, v.size()); 244 EXPECT_EQ(0U, v.size());
245 245
246 // Now add some values with empty strings. 246 // Now add some values with empty strings.
247 const string16 kValue = ASCIIToUTF16(" toto "); 247 const base::string16 kValue = ASCIIToUTF16(" toto ");
248 field.name = ASCIIToUTF16("blank"); 248 field.name = ASCIIToUTF16("blank");
249 field.value = string16(); 249 field.value = base::string16();
250 EXPECT_TRUE(table_->AddFormFieldValue(field, &changes)); 250 EXPECT_TRUE(table_->AddFormFieldValue(field, &changes));
251 field.name = ASCIIToUTF16("blank"); 251 field.name = ASCIIToUTF16("blank");
252 field.value = ASCIIToUTF16(" "); 252 field.value = ASCIIToUTF16(" ");
253 EXPECT_TRUE(table_->AddFormFieldValue(field, &changes)); 253 EXPECT_TRUE(table_->AddFormFieldValue(field, &changes));
254 field.name = ASCIIToUTF16("blank"); 254 field.name = ASCIIToUTF16("blank");
255 field.value = ASCIIToUTF16(" "); 255 field.value = ASCIIToUTF16(" ");
256 EXPECT_TRUE(table_->AddFormFieldValue(field, &changes)); 256 EXPECT_TRUE(table_->AddFormFieldValue(field, &changes));
257 field.name = ASCIIToUTF16("blank"); 257 field.name = ASCIIToUTF16("blank");
258 field.value = kValue; 258 field.value = kValue;
259 EXPECT_TRUE(table_->AddFormFieldValue(field, &changes)); 259 EXPECT_TRUE(table_->AddFormFieldValue(field, &changes));
260 260
261 // They should be stored normally as the DB layer does not check for empty 261 // They should be stored normally as the DB layer does not check for empty
262 // values. 262 // values.
263 v.clear(); 263 v.clear();
264 EXPECT_TRUE(table_->GetFormValuesForElementName( 264 EXPECT_TRUE(table_->GetFormValuesForElementName(
265 ASCIIToUTF16("blank"), string16(), &v, 10)); 265 ASCIIToUTF16("blank"), base::string16(), &v, 10));
266 EXPECT_EQ(4U, v.size()); 266 EXPECT_EQ(4U, v.size());
267 267
268 // Now we'll check that ClearAutofillEmptyValueElements() works as expected. 268 // Now we'll check that ClearAutofillEmptyValueElements() works as expected.
269 table_->ClearAutofillEmptyValueElements(); 269 table_->ClearAutofillEmptyValueElements();
270 270
271 v.clear(); 271 v.clear();
272 EXPECT_TRUE(table_->GetFormValuesForElementName( 272 EXPECT_TRUE(table_->GetFormValuesForElementName(
273 ASCIIToUTF16("blank"), string16(), &v, 10)); 273 ASCIIToUTF16("blank"), base::string16(), &v, 10));
274 ASSERT_EQ(1U, v.size()); 274 ASSERT_EQ(1U, v.size());
275 275
276 EXPECT_EQ(kValue, v[0]); 276 EXPECT_EQ(kValue, v[0]);
277 } 277 }
278 278
279 TEST_F(AutofillTableTest, Autofill_RemoveBetweenChanges) { 279 TEST_F(AutofillTableTest, Autofill_RemoveBetweenChanges) {
280 TimeDelta one_day(TimeDelta::FromDays(1)); 280 TimeDelta one_day(TimeDelta::FromDays(1));
281 Time t1 = Time::Now(); 281 Time t1 = Time::Now();
282 Time t2 = t1 + one_day; 282 Time t2 = t1 + one_day;
283 283
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 EXPECT_FALSE(s_billing_updated_2.Step()); 609 EXPECT_FALSE(s_billing_updated_2.Step());
610 delete db_profile; 610 delete db_profile;
611 611
612 // Remove the 'Billing' profile. 612 // Remove the 'Billing' profile.
613 EXPECT_TRUE(table_->RemoveAutofillProfile(billing_profile.guid())); 613 EXPECT_TRUE(table_->RemoveAutofillProfile(billing_profile.guid()));
614 EXPECT_FALSE(table_->GetAutofillProfile(billing_profile.guid(), &db_profile)); 614 EXPECT_FALSE(table_->GetAutofillProfile(billing_profile.guid(), &db_profile));
615 } 615 }
616 616
617 TEST_F(AutofillTableTest, AutofillProfileMultiValueNames) { 617 TEST_F(AutofillTableTest, AutofillProfileMultiValueNames) {
618 AutofillProfile p; 618 AutofillProfile p;
619 const string16 kJohnDoe(ASCIIToUTF16("John Doe")); 619 const base::string16 kJohnDoe(ASCIIToUTF16("John Doe"));
620 const string16 kJohnPDoe(ASCIIToUTF16("John P. Doe")); 620 const base::string16 kJohnPDoe(ASCIIToUTF16("John P. Doe"));
621 std::vector<string16> set_values; 621 std::vector<base::string16> set_values;
622 set_values.push_back(kJohnDoe); 622 set_values.push_back(kJohnDoe);
623 set_values.push_back(kJohnPDoe); 623 set_values.push_back(kJohnPDoe);
624 p.SetRawMultiInfo(NAME_FULL, set_values); 624 p.SetRawMultiInfo(NAME_FULL, set_values);
625 625
626 EXPECT_TRUE(table_->AddAutofillProfile(p)); 626 EXPECT_TRUE(table_->AddAutofillProfile(p));
627 627
628 AutofillProfile* db_profile; 628 AutofillProfile* db_profile;
629 ASSERT_TRUE(table_->GetAutofillProfile(p.guid(), &db_profile)); 629 ASSERT_TRUE(table_->GetAutofillProfile(p.guid(), &db_profile));
630 EXPECT_EQ(p, *db_profile); 630 EXPECT_EQ(p, *db_profile);
631 EXPECT_EQ(0, p.Compare(*db_profile)); 631 EXPECT_EQ(0, p.Compare(*db_profile));
632 delete db_profile; 632 delete db_profile;
633 633
634 // Update the values. 634 // Update the values.
635 const string16 kNoOne(ASCIIToUTF16("No One")); 635 const base::string16 kNoOne(ASCIIToUTF16("No One"));
636 set_values[1] = kNoOne; 636 set_values[1] = kNoOne;
637 p.SetRawMultiInfo(NAME_FULL, set_values); 637 p.SetRawMultiInfo(NAME_FULL, set_values);
638 EXPECT_TRUE(table_->UpdateAutofillProfileMulti(p)); 638 EXPECT_TRUE(table_->UpdateAutofillProfileMulti(p));
639 ASSERT_TRUE(table_->GetAutofillProfile(p.guid(), &db_profile)); 639 ASSERT_TRUE(table_->GetAutofillProfile(p.guid(), &db_profile));
640 EXPECT_EQ(p, *db_profile); 640 EXPECT_EQ(p, *db_profile);
641 EXPECT_EQ(0, p.Compare(*db_profile)); 641 EXPECT_EQ(0, p.Compare(*db_profile));
642 delete db_profile; 642 delete db_profile;
643 643
644 // Delete values. 644 // Delete values.
645 set_values.clear(); 645 set_values.clear();
646 p.SetRawMultiInfo(NAME_FULL, set_values); 646 p.SetRawMultiInfo(NAME_FULL, set_values);
647 EXPECT_TRUE(table_->UpdateAutofillProfileMulti(p)); 647 EXPECT_TRUE(table_->UpdateAutofillProfileMulti(p));
648 ASSERT_TRUE(table_->GetAutofillProfile(p.guid(), &db_profile)); 648 ASSERT_TRUE(table_->GetAutofillProfile(p.guid(), &db_profile));
649 EXPECT_EQ(p, *db_profile); 649 EXPECT_EQ(p, *db_profile);
650 EXPECT_EQ(0, p.Compare(*db_profile)); 650 EXPECT_EQ(0, p.Compare(*db_profile));
651 EXPECT_EQ(string16(), db_profile->GetRawInfo(NAME_FULL)); 651 EXPECT_EQ(base::string16(), db_profile->GetRawInfo(NAME_FULL));
652 delete db_profile; 652 delete db_profile;
653 } 653 }
654 654
655 TEST_F(AutofillTableTest, AutofillProfileSingleValue) { 655 TEST_F(AutofillTableTest, AutofillProfileSingleValue) {
656 AutofillProfile p; 656 AutofillProfile p;
657 const string16 kJohnDoe(ASCIIToUTF16("John Doe")); 657 const base::string16 kJohnDoe(ASCIIToUTF16("John Doe"));
658 const string16 kJohnPDoe(ASCIIToUTF16("John P. Doe")); 658 const base::string16 kJohnPDoe(ASCIIToUTF16("John P. Doe"));
659 std::vector<string16> set_values; 659 std::vector<base::string16> set_values;
660 set_values.push_back(kJohnDoe); 660 set_values.push_back(kJohnDoe);
661 set_values.push_back(kJohnPDoe); 661 set_values.push_back(kJohnPDoe);
662 p.SetRawMultiInfo(NAME_FULL, set_values); 662 p.SetRawMultiInfo(NAME_FULL, set_values);
663 663
664 EXPECT_TRUE(table_->AddAutofillProfile(p)); 664 EXPECT_TRUE(table_->AddAutofillProfile(p));
665 665
666 AutofillProfile* db_profile; 666 AutofillProfile* db_profile;
667 ASSERT_TRUE(table_->GetAutofillProfile(p.guid(), &db_profile)); 667 ASSERT_TRUE(table_->GetAutofillProfile(p.guid(), &db_profile));
668 EXPECT_EQ(p, *db_profile); 668 EXPECT_EQ(p, *db_profile);
669 EXPECT_EQ(0, p.Compare(*db_profile)); 669 EXPECT_EQ(0, p.Compare(*db_profile));
670 delete db_profile; 670 delete db_profile;
671 671
672 const string16 kNoOne(ASCIIToUTF16("No One")); 672 const base::string16 kNoOne(ASCIIToUTF16("No One"));
673 set_values.resize(1); 673 set_values.resize(1);
674 set_values[0] = kNoOne; 674 set_values[0] = kNoOne;
675 p.SetRawMultiInfo(NAME_FULL, set_values); 675 p.SetRawMultiInfo(NAME_FULL, set_values);
676 EXPECT_TRUE(table_->UpdateAutofillProfile(p)); 676 EXPECT_TRUE(table_->UpdateAutofillProfile(p));
677 ASSERT_TRUE(table_->GetAutofillProfile(p.guid(), &db_profile)); 677 ASSERT_TRUE(table_->GetAutofillProfile(p.guid(), &db_profile));
678 EXPECT_EQ(p.PrimaryValue(), db_profile->PrimaryValue()); 678 EXPECT_EQ(p.PrimaryValue(), db_profile->PrimaryValue());
679 EXPECT_EQ(p.guid(), db_profile->guid()); 679 EXPECT_EQ(p.guid(), db_profile->guid());
680 EXPECT_NE(0, p.Compare(*db_profile)); 680 EXPECT_NE(0, p.Compare(*db_profile));
681 db_profile->GetRawMultiInfo(NAME_FULL, &set_values); 681 db_profile->GetRawMultiInfo(NAME_FULL, &set_values);
682 ASSERT_EQ(2UL, set_values.size()); 682 ASSERT_EQ(2UL, set_values.size());
683 EXPECT_EQ(kNoOne, set_values[0]); 683 EXPECT_EQ(kNoOne, set_values[0]);
684 EXPECT_EQ(kJohnPDoe, set_values[1]); 684 EXPECT_EQ(kJohnPDoe, set_values[1]);
685 delete db_profile; 685 delete db_profile;
686 } 686 }
687 687
688 TEST_F(AutofillTableTest, AutofillProfileMultiValueEmails) { 688 TEST_F(AutofillTableTest, AutofillProfileMultiValueEmails) {
689 AutofillProfile p; 689 AutofillProfile p;
690 const string16 kJohnDoe(ASCIIToUTF16("john@doe.com")); 690 const base::string16 kJohnDoe(ASCIIToUTF16("john@doe.com"));
691 const string16 kJohnPDoe(ASCIIToUTF16("john_p@doe.com")); 691 const base::string16 kJohnPDoe(ASCIIToUTF16("john_p@doe.com"));
692 std::vector<string16> set_values; 692 std::vector<base::string16> set_values;
693 set_values.push_back(kJohnDoe); 693 set_values.push_back(kJohnDoe);
694 set_values.push_back(kJohnPDoe); 694 set_values.push_back(kJohnPDoe);
695 p.SetRawMultiInfo(EMAIL_ADDRESS, set_values); 695 p.SetRawMultiInfo(EMAIL_ADDRESS, set_values);
696 696
697 EXPECT_TRUE(table_->AddAutofillProfile(p)); 697 EXPECT_TRUE(table_->AddAutofillProfile(p));
698 698
699 AutofillProfile* db_profile; 699 AutofillProfile* db_profile;
700 ASSERT_TRUE(table_->GetAutofillProfile(p.guid(), &db_profile)); 700 ASSERT_TRUE(table_->GetAutofillProfile(p.guid(), &db_profile));
701 EXPECT_EQ(p, *db_profile); 701 EXPECT_EQ(p, *db_profile);
702 EXPECT_EQ(0, p.Compare(*db_profile)); 702 EXPECT_EQ(0, p.Compare(*db_profile));
703 delete db_profile; 703 delete db_profile;
704 704
705 // Update the values. 705 // Update the values.
706 const string16 kNoOne(ASCIIToUTF16("no@one.com")); 706 const base::string16 kNoOne(ASCIIToUTF16("no@one.com"));
707 set_values[1] = kNoOne; 707 set_values[1] = kNoOne;
708 p.SetRawMultiInfo(EMAIL_ADDRESS, set_values); 708 p.SetRawMultiInfo(EMAIL_ADDRESS, set_values);
709 EXPECT_TRUE(table_->UpdateAutofillProfileMulti(p)); 709 EXPECT_TRUE(table_->UpdateAutofillProfileMulti(p));
710 ASSERT_TRUE(table_->GetAutofillProfile(p.guid(), &db_profile)); 710 ASSERT_TRUE(table_->GetAutofillProfile(p.guid(), &db_profile));
711 EXPECT_EQ(p, *db_profile); 711 EXPECT_EQ(p, *db_profile);
712 EXPECT_EQ(0, p.Compare(*db_profile)); 712 EXPECT_EQ(0, p.Compare(*db_profile));
713 delete db_profile; 713 delete db_profile;
714 714
715 // Delete values. 715 // Delete values.
716 set_values.clear(); 716 set_values.clear();
717 p.SetRawMultiInfo(EMAIL_ADDRESS, set_values); 717 p.SetRawMultiInfo(EMAIL_ADDRESS, set_values);
718 EXPECT_TRUE(table_->UpdateAutofillProfileMulti(p)); 718 EXPECT_TRUE(table_->UpdateAutofillProfileMulti(p));
719 ASSERT_TRUE(table_->GetAutofillProfile(p.guid(), &db_profile)); 719 ASSERT_TRUE(table_->GetAutofillProfile(p.guid(), &db_profile));
720 EXPECT_EQ(p, *db_profile); 720 EXPECT_EQ(p, *db_profile);
721 EXPECT_EQ(0, p.Compare(*db_profile)); 721 EXPECT_EQ(0, p.Compare(*db_profile));
722 EXPECT_EQ(string16(), db_profile->GetRawInfo(EMAIL_ADDRESS)); 722 EXPECT_EQ(base::string16(), db_profile->GetRawInfo(EMAIL_ADDRESS));
723 delete db_profile; 723 delete db_profile;
724 } 724 }
725 725
726 TEST_F(AutofillTableTest, AutofillProfileMultiValuePhone) { 726 TEST_F(AutofillTableTest, AutofillProfileMultiValuePhone) {
727 AutofillProfile p; 727 AutofillProfile p;
728 const string16 kJohnDoe(ASCIIToUTF16("4151112222")); 728 const base::string16 kJohnDoe(ASCIIToUTF16("4151112222"));
729 const string16 kJohnPDoe(ASCIIToUTF16("4151113333")); 729 const base::string16 kJohnPDoe(ASCIIToUTF16("4151113333"));
730 std::vector<string16> set_values; 730 std::vector<base::string16> set_values;
731 set_values.push_back(kJohnDoe); 731 set_values.push_back(kJohnDoe);
732 set_values.push_back(kJohnPDoe); 732 set_values.push_back(kJohnPDoe);
733 p.SetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, set_values); 733 p.SetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, set_values);
734 734
735 EXPECT_TRUE(table_->AddAutofillProfile(p)); 735 EXPECT_TRUE(table_->AddAutofillProfile(p));
736 736
737 AutofillProfile* db_profile; 737 AutofillProfile* db_profile;
738 ASSERT_TRUE(table_->GetAutofillProfile(p.guid(), &db_profile)); 738 ASSERT_TRUE(table_->GetAutofillProfile(p.guid(), &db_profile));
739 EXPECT_EQ(p, *db_profile); 739 EXPECT_EQ(p, *db_profile);
740 EXPECT_EQ(0, p.Compare(*db_profile)); 740 EXPECT_EQ(0, p.Compare(*db_profile));
741 delete db_profile; 741 delete db_profile;
742 742
743 // Update the values. 743 // Update the values.
744 const string16 kNoOne(ASCIIToUTF16("4151110000")); 744 const base::string16 kNoOne(ASCIIToUTF16("4151110000"));
745 set_values[1] = kNoOne; 745 set_values[1] = kNoOne;
746 p.SetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, set_values); 746 p.SetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, set_values);
747 EXPECT_TRUE(table_->UpdateAutofillProfileMulti(p)); 747 EXPECT_TRUE(table_->UpdateAutofillProfileMulti(p));
748 ASSERT_TRUE(table_->GetAutofillProfile(p.guid(), &db_profile)); 748 ASSERT_TRUE(table_->GetAutofillProfile(p.guid(), &db_profile));
749 EXPECT_EQ(p, *db_profile); 749 EXPECT_EQ(p, *db_profile);
750 EXPECT_EQ(0, p.Compare(*db_profile)); 750 EXPECT_EQ(0, p.Compare(*db_profile));
751 delete db_profile; 751 delete db_profile;
752 752
753 // Delete values. 753 // Delete values.
754 set_values.clear(); 754 set_values.clear();
755 p.SetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, set_values); 755 p.SetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, set_values);
756 EXPECT_TRUE(table_->UpdateAutofillProfileMulti(p)); 756 EXPECT_TRUE(table_->UpdateAutofillProfileMulti(p));
757 ASSERT_TRUE(table_->GetAutofillProfile(p.guid(), &db_profile)); 757 ASSERT_TRUE(table_->GetAutofillProfile(p.guid(), &db_profile));
758 EXPECT_EQ(p, *db_profile); 758 EXPECT_EQ(p, *db_profile);
759 EXPECT_EQ(0, p.Compare(*db_profile)); 759 EXPECT_EQ(0, p.Compare(*db_profile));
760 EXPECT_EQ(string16(), db_profile->GetRawInfo(EMAIL_ADDRESS)); 760 EXPECT_EQ(base::string16(), db_profile->GetRawInfo(EMAIL_ADDRESS));
761 delete db_profile; 761 delete db_profile;
762 } 762 }
763 763
764 TEST_F(AutofillTableTest, AutofillProfileTrash) { 764 TEST_F(AutofillTableTest, AutofillProfileTrash) {
765 std::vector<std::string> guids; 765 std::vector<std::string> guids;
766 table_->GetAutofillProfilesInTrash(&guids); 766 table_->GetAutofillProfilesInTrash(&guids);
767 EXPECT_TRUE(guids.empty()); 767 EXPECT_TRUE(guids.empty());
768 768
769 ASSERT_TRUE(table_->AddAutofillGUIDToTrash( 769 ASSERT_TRUE(table_->AddAutofillGUIDToTrash(
770 "00000000-0000-0000-0000-000000000000")); 770 "00000000-0000-0000-0000-000000000000"));
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
1319 1319
1320 // make sure the lists of entries match 1320 // make sure the lists of entries match
1321 ASSERT_EQ(expected_entries.size(), entry_set.size()); 1321 ASSERT_EQ(expected_entries.size(), entry_set.size());
1322 AutofillEntrySetIterator it; 1322 AutofillEntrySetIterator it;
1323 for (it = entry_set.begin(); it != entry_set.end(); it++) { 1323 for (it = entry_set.begin(); it != entry_set.end(); it++) {
1324 expected_entries.erase(*it); 1324 expected_entries.erase(*it);
1325 } 1325 }
1326 1326
1327 EXPECT_EQ(0U, expected_entries.size()); 1327 EXPECT_EQ(0U, expected_entries.size());
1328 } 1328 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698