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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/guid.h" | 6 #include "base/guid.h" |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/memory/scoped_vector.h" | 8 #include "base/memory/scoped_vector.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "base/string16.h" | 10 #include "base/string16.h" |
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 new AutofillProfile(base::GenerateGUID(), "https://www.example.com/")); | 538 new AutofillProfile(base::GenerateGUID(), "https://www.example.com/")); |
539 test::SetProfileInfo(a.get(), "Thomas", NULL, "Jefferson", | 539 test::SetProfileInfo(a.get(), "Thomas", NULL, "Jefferson", |
540 "declaration_guy@gmail.com", NULL, NULL, NULL, NULL, NULL, NULL, NULL, | 540 "declaration_guy@gmail.com", NULL, NULL, NULL, NULL, NULL, NULL, NULL, |
541 NULL); | 541 NULL); |
542 test::SetProfileInfo(a.get(), "Thomas", NULL, "Adams", | 542 test::SetProfileInfo(a.get(), "Thomas", NULL, "Adams", |
543 "declaration_guy@gmail.com", NULL, NULL, NULL, NULL, NULL, NULL, NULL, | 543 "declaration_guy@gmail.com", NULL, NULL, NULL, NULL, NULL, NULL, NULL, |
544 NULL); | 544 NULL); |
545 EXPECT_FALSE(a->IsSubsetOf(*b, "en-US")); | 545 EXPECT_FALSE(a->IsSubsetOf(*b, "en-US")); |
546 } | 546 } |
547 | 547 |
| 548 TEST(AutofillProfileTest, OverwriteWithOrAddTo) { |
| 549 AutofillProfile a(base::GenerateGUID(), "https://www.example.com"); |
| 550 test::SetProfileInfo(&a, "Marion", "Mitchell", "Morrison", |
| 551 "marion@me.xyz", "Fox", "123 Zoo St.", "unit 5", |
| 552 "Hollywood", "CA", "91601", "US", |
| 553 "12345678910"); |
| 554 std::vector<base::string16> names; |
| 555 a.GetRawMultiInfo(NAME_FULL, &names); |
| 556 names.push_back(ASCIIToUTF16("Marion Morrison")); |
| 557 a.SetRawMultiInfo(NAME_FULL, names); |
| 558 |
| 559 // Create an identical profile except that the new profile: |
| 560 // (1) Has a different origin, |
| 561 // (2) Has a different address line 2, |
| 562 // (3) Lacks a company name, and |
| 563 // (4) Has a different full name variant. |
| 564 AutofillProfile b = a; |
| 565 b.set_guid(base::GenerateGUID()); |
| 566 b.set_origin("Chrome settings"); |
| 567 b.SetRawInfo(ADDRESS_HOME_LINE2, ASCIIToUTF16("area 51")); |
| 568 b.SetRawInfo(COMPANY_NAME, base::string16()); |
| 569 b.GetRawMultiInfo(NAME_FULL, &names); |
| 570 names.push_back(ASCIIToUTF16("Marion M. Morrison")); |
| 571 b.SetRawMultiInfo(NAME_FULL, names); |
| 572 |
| 573 a.OverwriteWithOrAddTo(b, "en-US"); |
| 574 EXPECT_EQ("Chrome settings", a.origin()); |
| 575 EXPECT_EQ(ASCIIToUTF16("area 51"), a.GetRawInfo(ADDRESS_HOME_LINE2)); |
| 576 EXPECT_EQ(ASCIIToUTF16("Fox"), a.GetRawInfo(COMPANY_NAME)); |
| 577 a.GetRawMultiInfo(NAME_FULL, &names); |
| 578 ASSERT_EQ(3U, names.size()); |
| 579 EXPECT_EQ(ASCIIToUTF16("Marion Mitchell Morrison"), names[0]); |
| 580 EXPECT_EQ(ASCIIToUTF16("Marion Morrison"), names[1]); |
| 581 EXPECT_EQ(ASCIIToUTF16("Marion M. Morrison"), names[2]); |
| 582 } |
| 583 |
548 TEST(AutofillProfileTest, AssignmentOperator) { | 584 TEST(AutofillProfileTest, AssignmentOperator) { |
549 AutofillProfile a(base::GenerateGUID(), "https://www.example.com/"); | 585 AutofillProfile a(base::GenerateGUID(), "https://www.example.com/"); |
550 test::SetProfileInfo(&a, "Marion", "Mitchell", "Morrison", | 586 test::SetProfileInfo(&a, "Marion", "Mitchell", "Morrison", |
551 "marion@me.xyz", "Fox", "123 Zoo St.", "unit 5", | 587 "marion@me.xyz", "Fox", "123 Zoo St.", "unit 5", |
552 "Hollywood", "CA", "91601", "US", | 588 "Hollywood", "CA", "91601", "US", |
553 "12345678910"); | 589 "12345678910"); |
554 | 590 |
555 // Result of assignment should be logically equal to the original profile. | 591 // Result of assignment should be logically equal to the original profile. |
556 AutofillProfile b(base::GenerateGUID(), "http://www.example.com/"); | 592 AutofillProfile b(base::GenerateGUID(), "http://www.example.com/"); |
557 b = a; | 593 b = a; |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
853 field.option_values = values; | 889 field.option_values = values; |
854 field.option_contents = contents; | 890 field.option_contents = contents; |
855 | 891 |
856 AutofillProfile profile(base::GenerateGUID(), "https://www.example.com/"); | 892 AutofillProfile profile(base::GenerateGUID(), "https://www.example.com/"); |
857 profile.SetRawInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("California")); | 893 profile.SetRawInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("California")); |
858 profile.FillSelectControl(ADDRESS_HOME_STATE, "en-US", &field); | 894 profile.FillSelectControl(ADDRESS_HOME_STATE, "en-US", &field); |
859 EXPECT_EQ(ASCIIToUTF16("2"), field.value); | 895 EXPECT_EQ(ASCIIToUTF16("2"), field.value); |
860 } | 896 } |
861 | 897 |
862 } // namespace autofill | 898 } // namespace autofill |
OLD | NEW |