Chromium Code Reviews| Index: components/autofill/core/browser/credit_card_unittest.cc |
| diff --git a/components/autofill/core/browser/credit_card_unittest.cc b/components/autofill/core/browser/credit_card_unittest.cc |
| index 4e371ec4656c77167a33d5b7c6407f6843fcae03..4a2ef7029d2d24f3eadaffad9bbaa70297e1bfb5 100644 |
| --- a/components/autofill/core/browser/credit_card_unittest.cc |
| +++ b/components/autofill/core/browser/credit_card_unittest.cc |
| @@ -8,6 +8,7 @@ |
| #include "base/macros.h" |
| #include "base/strings/string_number_conversions.h" |
| #include "base/strings/utf_string_conversions.h" |
| +#include "base/test/scoped_feature_list.h" |
| #include "base/time/time.h" |
| #include "build/build_config.h" |
| #include "components/autofill/core/browser/autofill_experiments.h" |
| @@ -144,6 +145,26 @@ TEST(CreditCardTest, PreviewSummaryAndTypeAndLastFourDigitsStrings) { |
| obfuscated5); |
| } |
| +// Tests credit card bank name and last four digits string generation. |
| +TEST(CreditCardTest, BankNameAndLastFourDigitsStrings) { |
|
sebsg
2017/04/12 22:32:36
Could you please add a test with a bank name longe
Shanfeng
2017/04/13 18:29:09
Done.
|
| + // Case 1: Have everything and show bank name |
| + CreditCard credit_card1(base::GenerateGUID(), "https://www.example.com/"); |
| + test::SetCreditCardInfo(&credit_card1, "John Dillinger", |
| + "5105 1051 0510 5100", "01", "2010"); |
| + credit_card1.SetBankName("Chase"); |
| + base::string16 obfuscated1 = credit_card1.BankNameAndLastFourDigits(); |
| + EXPECT_FALSE(credit_card1.bank_name().empty()); |
| + EXPECT_EQ(UTF8ToUTF16("Chase" + kUTF8MidlineEllipsis + "5100"), obfuscated1); |
| + |
| + // Case 2: Have no bank name and not show bank name |
| + CreditCard credit_card2(base::GenerateGUID(), "https://www.example.com/"); |
| + test::SetCreditCardInfo(&credit_card2, "John Dillinger", |
| + "5105 1051 0510 5100", "01", "2010"); |
| + base::string16 obfuscated2 = credit_card2.BankNameAndLastFourDigits(); |
| + EXPECT_TRUE(credit_card2.bank_name().empty()); |
| + EXPECT_EQ(UTF8ToUTF16(kUTF8MidlineEllipsis + "5100"), obfuscated2); |
| +} |
| + |
| TEST(CreditCardTest, AssignmentOperator) { |
| CreditCard a(base::GenerateGUID(), "some origin"); |
| test::SetCreditCardInfo(&a, "John Dillinger", "123456789012", "01", "2010"); |