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/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "components/autofill/core/browser/autofill_test_utils.h" | 8 #include "components/autofill/core/browser/autofill_test_utils.h" |
9 #include "components/autofill/core/browser/autofill_type.h" | 9 #include "components/autofill/core/browser/autofill_type.h" |
10 #include "components/autofill/core/browser/credit_card.h" | 10 #include "components/autofill/core/browser/credit_card.h" |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 "5100"), | 114 "5100"), |
115 obfuscated3); | 115 obfuscated3); |
116 | 116 |
117 // Case 4: Have everything. | 117 // Case 4: Have everything. |
118 CreditCard credit_card4(base::GenerateGUID(), "https://www.example.com/"); | 118 CreditCard credit_card4(base::GenerateGUID(), "https://www.example.com/"); |
119 test::SetCreditCardInfo( | 119 test::SetCreditCardInfo( |
120 &credit_card4, "John Dillinger", "5105 1051 0510 5100", "01", "2010"); | 120 &credit_card4, "John Dillinger", "5105 1051 0510 5100", "01", "2010"); |
121 base::string16 summary4 = credit_card4.Label(); | 121 base::string16 summary4 = credit_card4.Label(); |
122 EXPECT_EQ(UTF8ToUTF16( | 122 EXPECT_EQ(UTF8ToUTF16( |
123 "MasterCard \xE2\x8B\xAF" | 123 "MasterCard \xE2\x8B\xAF" |
124 "5100, Exp: 01/2010"), | 124 "5100, 01/2010"), |
125 summary4); | 125 summary4); |
126 base::string16 obfuscated4 = credit_card4.TypeAndLastFourDigits(); | 126 base::string16 obfuscated4 = credit_card4.TypeAndLastFourDigits(); |
127 EXPECT_EQ(UTF8ToUTF16( | 127 EXPECT_EQ(UTF8ToUTF16( |
128 "MasterCard \xE2\x8B\xAF" | 128 "MasterCard \xE2\x8B\xAF" |
129 "5100"), | 129 "5100"), |
130 obfuscated4); | 130 obfuscated4); |
131 | 131 |
132 // Case 5: Very long credit card | 132 // Case 5: Very long credit card |
133 CreditCard credit_card5(base::GenerateGUID(), "https://www.example.com/"); | 133 CreditCard credit_card5(base::GenerateGUID(), "https://www.example.com/"); |
134 test::SetCreditCardInfo( | 134 test::SetCreditCardInfo( |
135 &credit_card5, | 135 &credit_card5, |
136 "John Dillinger", | 136 "John Dillinger", |
137 "0123456789 0123456789 0123456789 5105 1051 0510 5100", "01", "2010"); | 137 "0123456789 0123456789 0123456789 5105 1051 0510 5100", "01", "2010"); |
138 base::string16 summary5 = credit_card5.Label(); | 138 base::string16 summary5 = credit_card5.Label(); |
139 EXPECT_EQ(UTF8ToUTF16( | 139 EXPECT_EQ(UTF8ToUTF16( |
140 "Card \xE2\x8B\xAF" | 140 "Card \xE2\x8B\xAF" |
141 "5100, Exp: 01/2010"), | 141 "5100, 01/2010"), |
142 summary5); | 142 summary5); |
143 base::string16 obfuscated5 = credit_card5.TypeAndLastFourDigits(); | 143 base::string16 obfuscated5 = credit_card5.TypeAndLastFourDigits(); |
144 EXPECT_EQ(UTF8ToUTF16( | 144 EXPECT_EQ(UTF8ToUTF16( |
145 "Card \xE2\x8B\xAF" | 145 "Card \xE2\x8B\xAF" |
146 "5100"), | 146 "5100"), |
147 obfuscated5); | 147 obfuscated5); |
148 } | 148 } |
149 | 149 |
150 TEST(CreditCardTest, AssignmentOperator) { | 150 TEST(CreditCardTest, AssignmentOperator) { |
151 CreditCard a(base::GenerateGUID(), "some origin"); | 151 CreditCard a(base::GenerateGUID(), "some origin"); |
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
652 base::string16 card_number = base::ASCIIToUTF16("test"); | 652 base::string16 card_number = base::ASCIIToUTF16("test"); |
653 int month = 1; | 653 int month = 1; |
654 int year = 3000; | 654 int year = 3000; |
655 CreditCard card(card_number, month, year); | 655 CreditCard card(card_number, month, year); |
656 EXPECT_EQ(card_number, card.number()); | 656 EXPECT_EQ(card_number, card.number()); |
657 EXPECT_EQ(month, card.expiration_month()); | 657 EXPECT_EQ(month, card.expiration_month()); |
658 EXPECT_EQ(year, card.expiration_year()); | 658 EXPECT_EQ(year, card.expiration_year()); |
659 } | 659 } |
660 | 660 |
661 } // namespace autofill | 661 } // namespace autofill |
OLD | NEW |