| 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 23 matching lines...) Expand all Loading... |
| 34 AutofillProfile profile0; | 34 AutofillProfile profile0; |
| 35 // Empty profile - nothing to update. | 35 // Empty profile - nothing to update. |
| 36 EXPECT_FALSE(UpdateProfileLabel(&profile0)); | 36 EXPECT_FALSE(UpdateProfileLabel(&profile0)); |
| 37 string16 summary0 = profile0.Label(); | 37 string16 summary0 = profile0.Label(); |
| 38 EXPECT_EQ(string16(), summary0); | 38 EXPECT_EQ(string16(), summary0); |
| 39 | 39 |
| 40 // Case 0a/empty name and address, so the first two fields of the rest of the | 40 // Case 0a/empty name and address, so the first two fields of the rest of the |
| 41 // data is used: "Hollywood, CA" | 41 // data is used: "Hollywood, CA" |
| 42 AutofillProfile profile00; | 42 AutofillProfile profile00; |
| 43 autofill_test::SetProfileInfo(&profile00, "", "Mitchell", "", | 43 autofill_test::SetProfileInfo(&profile00, "", "Mitchell", "", |
| 44 "johnwayne@me.xyz", "Fox", "", "unit 5", "Hollywood", "CA", "91601", "US", | 44 "johnwayne@me.xyz", "Fox", "", "", "Hollywood", "CA", "91601", "US", |
| 45 "16505678910", "78127654321"); | 45 "16505678910", "78127654321"); |
| 46 EXPECT_TRUE(UpdateProfileLabel(&profile00)); | 46 EXPECT_TRUE(UpdateProfileLabel(&profile00)); |
| 47 string16 summary00 = profile00.Label(); | 47 string16 summary00 = profile00.Label(); |
| 48 EXPECT_EQ(ASCIIToUTF16("Hollywood, CA"), summary00); | 48 EXPECT_EQ(ASCIIToUTF16("Hollywood, CA"), summary00); |
| 49 | 49 |
| 50 // Case 1: "<address>" | 50 // Case 1: "<address>" without line 2. |
| 51 AutofillProfile profile1; | 51 AutofillProfile profile1; |
| 52 autofill_test::SetProfileInfo(&profile1, "", "Mitchell", "", | 52 autofill_test::SetProfileInfo(&profile1, "", "Mitchell", "", |
| 53 "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", "Hollywood", "CA", | 53 "johnwayne@me.xyz", "Fox", "123 Zoo St.", "", "Hollywood", "CA", |
| 54 "91601", "US", "16505678910", "78127654321"); | 54 "91601", "US", "16505678910", "78127654321"); |
| 55 EXPECT_TRUE(UpdateProfileLabel(&profile1)); | 55 EXPECT_TRUE(UpdateProfileLabel(&profile1)); |
| 56 string16 summary1 = profile1.Label(); | 56 string16 summary1 = profile1.Label(); |
| 57 EXPECT_EQ(ASCIIToUTF16("123 Zoo St., Hollywood"), summary1); | 57 EXPECT_EQ(ASCIIToUTF16("123 Zoo St., Hollywood"), summary1); |
| 58 | 58 |
| 59 // Case 1a: "<address>" with line 2. |
| 60 AutofillProfile profile1a; |
| 61 autofill_test::SetProfileInfo(&profile1a, "", "Mitchell", "", |
| 62 "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", "Hollywood", "CA", |
| 63 "91601", "US", "16505678910", "78127654321"); |
| 64 EXPECT_TRUE(UpdateProfileLabel(&profile1a)); |
| 65 string16 summary1a = profile1a.Label(); |
| 66 EXPECT_EQ(ASCIIToUTF16("123 Zoo St., unit 5"), summary1a); |
| 67 |
| 59 // Case 2: "<lastname>" | 68 // Case 2: "<lastname>" |
| 60 AutofillProfile profile2; | 69 AutofillProfile profile2; |
| 61 autofill_test::SetProfileInfo(&profile2, "", "Mitchell", | 70 autofill_test::SetProfileInfo(&profile2, "", "Mitchell", |
| 62 "Morrison", "johnwayne@me.xyz", "Fox", "", "unit 5", "Hollywood", "CA", | 71 "Morrison", "johnwayne@me.xyz", "Fox", "", "", "Hollywood", "CA", |
| 63 "91601", "US", "16505678910", "78127654321"); | 72 "91601", "US", "16505678910", "78127654321"); |
| 64 EXPECT_TRUE(UpdateProfileLabel(&profile2)); | 73 EXPECT_TRUE(UpdateProfileLabel(&profile2)); |
| 65 string16 summary2 = profile2.Label(); | 74 string16 summary2 = profile2.Label(); |
| 66 // Summary does include full name which is empty if the first name is empty. | 75 // Summary does include full name which is empty if the first name is empty. |
| 67 EXPECT_EQ(ASCIIToUTF16("Hollywood, CA"), summary2); | 76 EXPECT_EQ(ASCIIToUTF16("Hollywood, CA"), summary2); |
| 68 | 77 |
| 69 // Case 3: "<lastname>, <address>" | 78 // Case 3: "<lastname>, <address>" |
| 70 AutofillProfile profile3; | 79 AutofillProfile profile3; |
| 71 autofill_test::SetProfileInfo(&profile3, "", "Mitchell", | 80 autofill_test::SetProfileInfo(&profile3, "", "Mitchell", |
| 72 "Morrison", "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", | 81 "Morrison", "johnwayne@me.xyz", "Fox", "123 Zoo St.", "", |
| 73 "Hollywood", "CA", "91601", "US", "16505678910", "78127654321"); | 82 "Hollywood", "CA", "91601", "US", "16505678910", "78127654321"); |
| 74 EXPECT_TRUE(UpdateProfileLabel(&profile3)); | 83 EXPECT_TRUE(UpdateProfileLabel(&profile3)); |
| 75 string16 summary3 = profile3.Label(); | 84 string16 summary3 = profile3.Label(); |
| 76 EXPECT_EQ(ASCIIToUTF16("123 Zoo St., Hollywood"), summary3); | 85 EXPECT_EQ(ASCIIToUTF16("123 Zoo St., Hollywood"), summary3); |
| 77 | 86 |
| 78 // Case 4: "<firstname>" | 87 // Case 4: "<firstname>" |
| 79 AutofillProfile profile4; | 88 AutofillProfile profile4; |
| 80 autofill_test::SetProfileInfo(&profile4, "Marion", "Mitchell", "", | 89 autofill_test::SetProfileInfo(&profile4, "Marion", "Mitchell", "", |
| 81 "johnwayne@me.xyz", "Fox", "", "unit 5", "Hollywood", "CA", "91601", "US", | 90 "johnwayne@me.xyz", "Fox", "", "", "Hollywood", "CA", "91601", "US", |
| 82 "16505678910", "01987654321"); | 91 "16505678910", "01987654321"); |
| 83 EXPECT_TRUE(UpdateProfileLabel(&profile4)); | 92 EXPECT_TRUE(UpdateProfileLabel(&profile4)); |
| 84 string16 summary4 = profile4.Label(); | 93 string16 summary4 = profile4.Label(); |
| 85 EXPECT_EQ(ASCIIToUTF16("Marion Mitchell, Hollywood"), summary4); | 94 EXPECT_EQ(ASCIIToUTF16("Marion Mitchell, Hollywood"), summary4); |
| 86 | 95 |
| 87 // Case 5: "<firstname>, <address>" | 96 // Case 5: "<firstname>, <address>" |
| 88 AutofillProfile profile5; | 97 AutofillProfile profile5; |
| 89 autofill_test::SetProfileInfo(&profile5, "Marion", "Mitchell", "", | 98 autofill_test::SetProfileInfo(&profile5, "Marion", "Mitchell", "", |
| 90 "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", "Hollywood", "CA", | 99 "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", "Hollywood", "CA", |
| 91 "91601", "US", "16505678910", "78127654321"); | 100 "91601", "US", "16505678910", "78127654321"); |
| 92 EXPECT_TRUE(UpdateProfileLabel(&profile5)); | 101 EXPECT_TRUE(UpdateProfileLabel(&profile5)); |
| 93 string16 summary5 = profile5.Label(); | 102 string16 summary5 = profile5.Label(); |
| 94 EXPECT_EQ(ASCIIToUTF16("Marion Mitchell, 123 Zoo St."), summary5); | 103 EXPECT_EQ(ASCIIToUTF16("Marion Mitchell, 123 Zoo St."), summary5); |
| 95 | 104 |
| 96 // Case 6: "<firstname> <lastname>" | 105 // Case 6: "<firstname> <lastname>" |
| 97 AutofillProfile profile6; | 106 AutofillProfile profile6; |
| 98 autofill_test::SetProfileInfo(&profile6, "Marion", "Mitchell", | 107 autofill_test::SetProfileInfo(&profile6, "Marion", "Mitchell", |
| 99 "Morrison", "johnwayne@me.xyz", "Fox", "", "unit 5", "Hollywood", "CA", | 108 "Morrison", "johnwayne@me.xyz", "Fox", "", "", "Hollywood", "CA", |
| 100 "91601", "US", "16505678910", "78127654321"); | 109 "91601", "US", "16505678910", "78127654321"); |
| 101 EXPECT_TRUE(UpdateProfileLabel(&profile6)); | 110 EXPECT_TRUE(UpdateProfileLabel(&profile6)); |
| 102 string16 summary6 = profile6.Label(); | 111 string16 summary6 = profile6.Label(); |
| 103 EXPECT_EQ(ASCIIToUTF16("Marion Mitchell Morrison, Hollywood"), | 112 EXPECT_EQ(ASCIIToUTF16("Marion Mitchell Morrison, Hollywood"), |
| 104 summary6); | 113 summary6); |
| 105 | 114 |
| 106 // Case 7: "<firstname> <lastname>, <address>" | 115 // Case 7: "<firstname> <lastname>, <address>" |
| 107 AutofillProfile profile7; | 116 AutofillProfile profile7; |
| 108 autofill_test::SetProfileInfo(&profile7, "Marion", "Mitchell", | 117 autofill_test::SetProfileInfo(&profile7, "Marion", "Mitchell", |
| 109 "Morrison", "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", | 118 "Morrison", "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", |
| (...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 813 // Delete values. | 822 // Delete values. |
| 814 set_values.clear(); | 823 set_values.clear(); |
| 815 p.SetMultiInfo(PHONE_FAX_WHOLE_NUMBER, set_values); | 824 p.SetMultiInfo(PHONE_FAX_WHOLE_NUMBER, set_values); |
| 816 p.GetMultiInfo(PHONE_FAX_WHOLE_NUMBER, &get_values); | 825 p.GetMultiInfo(PHONE_FAX_WHOLE_NUMBER, &get_values); |
| 817 ASSERT_EQ(1UL, get_values.size()); | 826 ASSERT_EQ(1UL, get_values.size()); |
| 818 EXPECT_EQ(string16(), get_values[0]); | 827 EXPECT_EQ(string16(), get_values[0]); |
| 819 | 828 |
| 820 // Expect regular |GetInfo| returns empty value. | 829 // Expect regular |GetInfo| returns empty value. |
| 821 EXPECT_EQ(string16(), p.GetInfo(PHONE_FAX_WHOLE_NUMBER)); | 830 EXPECT_EQ(string16(), p.GetInfo(PHONE_FAX_WHOLE_NUMBER)); |
| 822 } | 831 } |
| OLD | NEW |