OLD | NEW |
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 "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/strings/string16.h" | 10 #include "base/strings/string16.h" |
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 "Hollywood", "CA", "91601", "US", | 560 "Hollywood", "CA", "91601", "US", |
561 "12345678910"); | 561 "12345678910"); |
562 std::vector<base::string16> names; | 562 std::vector<base::string16> names; |
563 a.GetRawMultiInfo(NAME_FULL, &names); | 563 a.GetRawMultiInfo(NAME_FULL, &names); |
564 names.push_back(ASCIIToUTF16("Marion Morrison")); | 564 names.push_back(ASCIIToUTF16("Marion Morrison")); |
565 a.SetRawMultiInfo(NAME_FULL, names); | 565 a.SetRawMultiInfo(NAME_FULL, names); |
566 | 566 |
567 // Create an identical profile except that the new profile: | 567 // Create an identical profile except that the new profile: |
568 // (1) Has a different origin, | 568 // (1) Has a different origin, |
569 // (2) Has a different address line 2, | 569 // (2) Has a different address line 2, |
570 // (3) Lacks a company name, and | 570 // (3) Lacks a company name, |
571 // (4) Has a different full name variant. | 571 // (4) Has a different full name variant, and |
| 572 // (5) Has a language code. |
572 AutofillProfile b = a; | 573 AutofillProfile b = a; |
573 b.set_guid(base::GenerateGUID()); | 574 b.set_guid(base::GenerateGUID()); |
574 b.set_origin("Chrome settings"); | 575 b.set_origin("Chrome settings"); |
575 b.SetRawInfo(ADDRESS_HOME_LINE2, ASCIIToUTF16("area 51")); | 576 b.SetRawInfo(ADDRESS_HOME_LINE2, ASCIIToUTF16("area 51")); |
576 b.SetRawInfo(COMPANY_NAME, base::string16()); | 577 b.SetRawInfo(COMPANY_NAME, base::string16()); |
577 b.GetRawMultiInfo(NAME_FULL, &names); | 578 b.GetRawMultiInfo(NAME_FULL, &names); |
578 names.push_back(ASCIIToUTF16("Marion M. Morrison")); | 579 names.push_back(ASCIIToUTF16("Marion M. Morrison")); |
579 b.SetRawMultiInfo(NAME_FULL, names); | 580 b.SetRawMultiInfo(NAME_FULL, names); |
| 581 b.set_language_code("en"); |
580 | 582 |
581 a.OverwriteWithOrAddTo(b, "en-US"); | 583 a.OverwriteWithOrAddTo(b, "en-US"); |
582 EXPECT_EQ("Chrome settings", a.origin()); | 584 EXPECT_EQ("Chrome settings", a.origin()); |
583 EXPECT_EQ(ASCIIToUTF16("area 51"), a.GetRawInfo(ADDRESS_HOME_LINE2)); | 585 EXPECT_EQ(ASCIIToUTF16("area 51"), a.GetRawInfo(ADDRESS_HOME_LINE2)); |
584 EXPECT_EQ(ASCIIToUTF16("Fox"), a.GetRawInfo(COMPANY_NAME)); | 586 EXPECT_EQ(ASCIIToUTF16("Fox"), a.GetRawInfo(COMPANY_NAME)); |
585 a.GetRawMultiInfo(NAME_FULL, &names); | 587 a.GetRawMultiInfo(NAME_FULL, &names); |
586 ASSERT_EQ(3U, names.size()); | 588 ASSERT_EQ(3U, names.size()); |
587 EXPECT_EQ(ASCIIToUTF16("Marion Mitchell Morrison"), names[0]); | 589 EXPECT_EQ(ASCIIToUTF16("Marion Mitchell Morrison"), names[0]); |
588 EXPECT_EQ(ASCIIToUTF16("Marion Morrison"), names[1]); | 590 EXPECT_EQ(ASCIIToUTF16("Marion Morrison"), names[1]); |
589 EXPECT_EQ(ASCIIToUTF16("Marion M. Morrison"), names[2]); | 591 EXPECT_EQ(ASCIIToUTF16("Marion M. Morrison"), names[2]); |
| 592 EXPECT_EQ("en", a.language_code()); |
590 } | 593 } |
591 | 594 |
592 TEST(AutofillProfileTest, AssignmentOperator) { | 595 TEST(AutofillProfileTest, AssignmentOperator) { |
593 AutofillProfile a(base::GenerateGUID(), "https://www.example.com/"); | 596 AutofillProfile a(base::GenerateGUID(), "https://www.example.com/"); |
594 test::SetProfileInfo(&a, "Marion", "Mitchell", "Morrison", | 597 test::SetProfileInfo(&a, "Marion", "Mitchell", "Morrison", |
595 "marion@me.xyz", "Fox", "123 Zoo St.", "unit 5", | 598 "marion@me.xyz", "Fox", "123 Zoo St.", "unit 5", |
596 "Hollywood", "CA", "91601", "US", | 599 "Hollywood", "CA", "91601", "US", |
597 "12345678910"); | 600 "12345678910"); |
598 | 601 |
599 // Result of assignment should be logically equal to the original profile. | 602 // Result of assignment should be logically equal to the original profile. |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
844 AutofillProfile profile(base::GenerateGUID(), "https://www.example.com/"); | 847 AutofillProfile profile(base::GenerateGUID(), "https://www.example.com/"); |
845 | 848 |
846 profile.SetInfo(AutofillType(EMAIL_ADDRESS), | 849 profile.SetInfo(AutofillType(EMAIL_ADDRESS), |
847 ASCIIToUTF16("\tuser@example.com "), | 850 ASCIIToUTF16("\tuser@example.com "), |
848 "en-US"); | 851 "en-US"); |
849 EXPECT_EQ(ASCIIToUTF16("user@example.com"), | 852 EXPECT_EQ(ASCIIToUTF16("user@example.com"), |
850 profile.GetRawInfo(EMAIL_ADDRESS)); | 853 profile.GetRawInfo(EMAIL_ADDRESS)); |
851 } | 854 } |
852 | 855 |
853 } // namespace autofill | 856 } // namespace autofill |
OLD | NEW |