| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
| 7 #include "base/memory/scoped_vector.h" | 7 #include "base/memory/scoped_vector.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "base/string16.h" | 9 #include "base/string16.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 // Case 0/null: "" | 32 // Case 0/null: "" |
| 33 AutofillProfile profile0; | 33 AutofillProfile profile0; |
| 34 // Empty profile - nothing to update. | 34 // Empty profile - nothing to update. |
| 35 EXPECT_FALSE(UpdateProfileLabel(&profile0)); | 35 EXPECT_FALSE(UpdateProfileLabel(&profile0)); |
| 36 string16 summary0 = profile0.Label(); | 36 string16 summary0 = profile0.Label(); |
| 37 EXPECT_EQ(string16(), summary0); | 37 EXPECT_EQ(string16(), summary0); |
| 38 | 38 |
| 39 // Case 0a/empty name and address, so the first two fields of the rest of the | 39 // Case 0a/empty name and address, so the first two fields of the rest of the |
| 40 // data is used: "Hollywood, CA" | 40 // data is used: "Hollywood, CA" |
| 41 AutofillProfile profile00; | 41 AutofillProfile profile00; |
| 42 autofill_test::SetProfileInfo(&profile00, "", "Mitchell", "", | 42 autofill_test::SetProfileInfo(&profile00, "", "", "", |
| 43 "johnwayne@me.xyz", "Fox", "", "", "Hollywood", "CA", "91601", "US", | 43 "johnwayne@me.xyz", "Fox", "", "", "Hollywood", "CA", "91601", "US", |
| 44 "16505678910"); | 44 "16505678910"); |
| 45 EXPECT_TRUE(UpdateProfileLabel(&profile00)); | 45 EXPECT_TRUE(UpdateProfileLabel(&profile00)); |
| 46 string16 summary00 = profile00.Label(); | 46 string16 summary00 = profile00.Label(); |
| 47 EXPECT_EQ(ASCIIToUTF16("Hollywood, CA"), summary00); | 47 EXPECT_EQ(ASCIIToUTF16("Hollywood, CA"), summary00); |
| 48 | 48 |
| 49 // Case 1: "<address>" without line 2. | 49 // Case 1: "<address>" without line 2. |
| 50 AutofillProfile profile1; | 50 AutofillProfile profile1; |
| 51 autofill_test::SetProfileInfo(&profile1, "", "Mitchell", "", | 51 autofill_test::SetProfileInfo(&profile1, "", "", "", |
| 52 "johnwayne@me.xyz", "Fox", "123 Zoo St.", "", "Hollywood", "CA", | 52 "johnwayne@me.xyz", "Fox", "123 Zoo St.", "", "Hollywood", "CA", |
| 53 "91601", "US", "16505678910"); | 53 "91601", "US", "16505678910"); |
| 54 EXPECT_TRUE(UpdateProfileLabel(&profile1)); | 54 EXPECT_TRUE(UpdateProfileLabel(&profile1)); |
| 55 string16 summary1 = profile1.Label(); | 55 string16 summary1 = profile1.Label(); |
| 56 EXPECT_EQ(ASCIIToUTF16("123 Zoo St., Hollywood"), summary1); | 56 EXPECT_EQ(ASCIIToUTF16("123 Zoo St., Hollywood"), summary1); |
| 57 | 57 |
| 58 // Case 1a: "<address>" with line 2. | 58 // Case 1a: "<address>" with line 2. |
| 59 AutofillProfile profile1a; | 59 AutofillProfile profile1a; |
| 60 autofill_test::SetProfileInfo(&profile1a, "", "Mitchell", "", | 60 autofill_test::SetProfileInfo(&profile1a, "", "", "", |
| 61 "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", "Hollywood", "CA", | 61 "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", "Hollywood", "CA", |
| 62 "91601", "US", "16505678910"); | 62 "91601", "US", "16505678910"); |
| 63 EXPECT_TRUE(UpdateProfileLabel(&profile1a)); | 63 EXPECT_TRUE(UpdateProfileLabel(&profile1a)); |
| 64 string16 summary1a = profile1a.Label(); | 64 string16 summary1a = profile1a.Label(); |
| 65 EXPECT_EQ(ASCIIToUTF16("123 Zoo St., unit 5"), summary1a); | 65 EXPECT_EQ(ASCIIToUTF16("123 Zoo St., unit 5"), summary1a); |
| 66 | 66 |
| 67 // Case 2: "<lastname>" | 67 // Case 2: "<lastname>" |
| 68 AutofillProfile profile2; | 68 AutofillProfile profile2; |
| 69 autofill_test::SetProfileInfo(&profile2, "", "Mitchell", | 69 autofill_test::SetProfileInfo(&profile2, "", "Mitchell", |
| 70 "Morrison", "johnwayne@me.xyz", "Fox", "", "", "Hollywood", "CA", | 70 "Morrison", "johnwayne@me.xyz", "Fox", "", "", "Hollywood", "CA", |
| 71 "91601", "US", "16505678910"); | 71 "91601", "US", "16505678910"); |
| 72 EXPECT_TRUE(UpdateProfileLabel(&profile2)); | 72 EXPECT_TRUE(UpdateProfileLabel(&profile2)); |
| 73 string16 summary2 = profile2.Label(); | 73 string16 summary2 = profile2.Label(); |
| 74 // Summary does include full name which is empty if the first name is empty. | 74 // Summary includes full name, to the maximal extent available. |
| 75 EXPECT_EQ(ASCIIToUTF16("Hollywood, CA"), summary2); | 75 EXPECT_EQ(ASCIIToUTF16("Mitchell Morrison, Hollywood"), summary2); |
| 76 | 76 |
| 77 // Case 3: "<lastname>, <address>" | 77 // Case 3: "<lastname>, <address>" |
| 78 AutofillProfile profile3; | 78 AutofillProfile profile3; |
| 79 autofill_test::SetProfileInfo(&profile3, "", "Mitchell", | 79 autofill_test::SetProfileInfo(&profile3, "", "Mitchell", |
| 80 "Morrison", "johnwayne@me.xyz", "Fox", "123 Zoo St.", "", | 80 "Morrison", "johnwayne@me.xyz", "Fox", "123 Zoo St.", "", |
| 81 "Hollywood", "CA", "91601", "US", "16505678910"); | 81 "Hollywood", "CA", "91601", "US", "16505678910"); |
| 82 EXPECT_TRUE(UpdateProfileLabel(&profile3)); | 82 EXPECT_TRUE(UpdateProfileLabel(&profile3)); |
| 83 string16 summary3 = profile3.Label(); | 83 string16 summary3 = profile3.Label(); |
| 84 EXPECT_EQ(ASCIIToUTF16("123 Zoo St., Hollywood"), summary3); | 84 EXPECT_EQ(ASCIIToUTF16("Mitchell Morrison, 123 Zoo St."), summary3); |
| 85 | 85 |
| 86 // Case 4: "<firstname>" | 86 // Case 4: "<firstname>" |
| 87 AutofillProfile profile4; | 87 AutofillProfile profile4; |
| 88 autofill_test::SetProfileInfo(&profile4, "Marion", "Mitchell", "", | 88 autofill_test::SetProfileInfo(&profile4, "Marion", "Mitchell", "", |
| 89 "johnwayne@me.xyz", "Fox", "", "", "Hollywood", "CA", "91601", "US", | 89 "johnwayne@me.xyz", "Fox", "", "", "Hollywood", "CA", "91601", "US", |
| 90 "16505678910"); | 90 "16505678910"); |
| 91 EXPECT_TRUE(UpdateProfileLabel(&profile4)); | 91 EXPECT_TRUE(UpdateProfileLabel(&profile4)); |
| 92 string16 summary4 = profile4.Label(); | 92 string16 summary4 = profile4.Label(); |
| 93 EXPECT_EQ(ASCIIToUTF16("Marion Mitchell, Hollywood"), summary4); | 93 EXPECT_EQ(ASCIIToUTF16("Marion Mitchell, Hollywood"), summary4); |
| 94 | 94 |
| (...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 774 // Delete values. | 774 // Delete values. |
| 775 set_values.clear(); | 775 set_values.clear(); |
| 776 p.SetMultiInfo(PHONE_HOME_WHOLE_NUMBER, set_values); | 776 p.SetMultiInfo(PHONE_HOME_WHOLE_NUMBER, set_values); |
| 777 p.GetMultiInfo(PHONE_HOME_WHOLE_NUMBER, &get_values); | 777 p.GetMultiInfo(PHONE_HOME_WHOLE_NUMBER, &get_values); |
| 778 ASSERT_EQ(1UL, get_values.size()); | 778 ASSERT_EQ(1UL, get_values.size()); |
| 779 EXPECT_EQ(string16(), get_values[0]); | 779 EXPECT_EQ(string16(), get_values[0]); |
| 780 | 780 |
| 781 // Expect regular |GetInfo| returns empty value. | 781 // Expect regular |GetInfo| returns empty value. |
| 782 EXPECT_EQ(string16(), p.GetInfo(PHONE_HOME_WHOLE_NUMBER)); | 782 EXPECT_EQ(string16(), p.GetInfo(PHONE_HOME_WHOLE_NUMBER)); |
| 783 } | 783 } |
| OLD | NEW |