Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(281)

Unified Diff: components/autofill/core/browser/credit_card_unittest.cc

Issue 2711543002: Experiment to add bank name in autofill ui. (Closed)
Patch Set: Experiment to add bank name in autofill ui. Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 3857613b21adcbf9cba869456a64c7f84f8cdb5e..c8e873c0cbb89d6e86cc234d9d1ca6fa143e20d7 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"
@@ -155,6 +156,37 @@ TEST(CreditCardTest, PreviewSummaryAndNetworkAndLastFourDigitsStrings) {
obfuscated5);
}
+// Tests credit card bank name and last four digits string generation.
+TEST(CreditCardTest, BankNameAndLastFourDigitsStrings) {
+ // 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", "1");
+ credit_card1.set_bank_name("Chase");
+ base::string16 obfuscated1 = credit_card1.BankNameAndLastFourDigits();
+ EXPECT_FALSE(credit_card1.bank_name().empty());
+ EXPECT_EQ(UTF8ToUTF16(std::string("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", "1");
+ base::string16 obfuscated2 = credit_card2.BankNameAndLastFourDigits();
+ EXPECT_TRUE(credit_card2.bank_name().empty());
+ EXPECT_EQ(UTF8ToUTF16(std::string(kUTF8MidlineEllipsis) + "5100"),
+ obfuscated2);
+
+ // Case 3: Have bank name but no last four digits, only show bank name.
+ CreditCard credit_card3(base::GenerateGUID(), "https://www.example.com/");
+ test::SetCreditCardInfo(&credit_card3, "John Dillinger",
+ "", "01", "2010", "1");
+ credit_card3.set_bank_name("Chase");
+ base::string16 obfuscated3 = credit_card3.BankNameAndLastFourDigits();
+ EXPECT_FALSE(credit_card3.bank_name().empty());
+ EXPECT_EQ(UTF8ToUTF16(std::string("Chase")), obfuscated3);
+}
+
TEST(CreditCardTest, AssignmentOperator) {
CreditCard a(base::GenerateGUID(), "some origin");
test::SetCreditCardInfo(&a, "John Dillinger", "123456789012", "01", "2010",
« no previous file with comments | « components/autofill/core/browser/credit_card.cc ('k') | components/autofill/core/browser/personal_data_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698