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

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

Issue 2711543002: Experiment to add bank name in autofill ui. (Closed)
Patch Set: address comments 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/personal_data_manager_unittest.cc
diff --git a/components/autofill/core/browser/personal_data_manager_unittest.cc b/components/autofill/core/browser/personal_data_manager_unittest.cc
index 2a1b23db52fc1c27949428a1859cfb752853c0ec..ba87bdd7faddcade73f0504a58f10bd7e04d4cd3 100644
--- a/components/autofill/core/browser/personal_data_manager_unittest.cc
+++ b/components/autofill/core/browser/personal_data_manager_unittest.cc
@@ -24,6 +24,7 @@
#include "base/strings/utf_string_conversions.h"
#include "base/synchronization/waitable_event.h"
#include "base/test/histogram_tester.h"
+#include "base/test/scoped_feature_list.h"
#include "base/test/simple_test_clock.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/time/time.h"
@@ -3635,8 +3636,8 @@ TEST_F(PersonalDataManagerTest,
base::RunLoop().Run();
std::vector<Suggestion> suggestions =
- personal_data_->GetCreditCardSuggestions(AutofillType(CREDIT_CARD_NUMBER),
- base::ASCIIToUTF16("12345678"));
+ personal_data_->GetCreditCardSuggestions(
+ AutofillType(CREDIT_CARD_NUMBER), base::ASCIIToUTF16("12345678"));
// There should be no suggestions.
ASSERT_EQ(0U, suggestions.size());
@@ -3923,6 +3924,101 @@ TEST_F(PersonalDataManagerTest,
ASSERT_EQ(3U, suggestions.size());
}
+// Tests that server cards have bank name when feature flag on.
+TEST_F(PersonalDataManagerTest,
+ GetCreditCardSuggestions_ShowBankNameOfServerCards) {
+ // Turn on feature flag.
+ base::test::ScopedFeatureList scoped_feature_list_;
+ scoped_feature_list_.InitAndEnableFeature(kAutofillCreditCardBankNameDisplay);
+
+ EnableWalletCardImport();
+ SetupReferenceLocalCreditCards();
+
+ // Add some server cards.
+ std::vector<CreditCard> server_cards;
+ server_cards.push_back(CreditCard(CreditCard::MASKED_SERVER_CARD, "b459"));
+ test::SetCreditCardInfo(&server_cards.back(), "Emmet Dalton", "2110", "12",
+ "2999", "1");
+ server_cards.back().set_use_count(2);
+ server_cards.back().set_use_date(AutofillClock::Now() -
+ base::TimeDelta::FromDays(1));
+ server_cards.back().SetNetworkForMaskedCard(kVisaCard);
+ server_cards.back().set_bank_name("Chase");
+
+ test::SetServerCreditCards(autofill_table_, server_cards);
+ personal_data_->Refresh();
+ EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged())
+ .WillOnce(QuitMainMessageLoop());
+ base::RunLoop().Run();
+
+ std::vector<Suggestion> suggestions =
+ personal_data_->GetCreditCardSuggestions(
+ AutofillType(CREDIT_CARD_NUMBER),
+ /* field_contents= */ base::string16());
+ ASSERT_EQ(4U, suggestions.size());
+
+ // All cards should be ordered as expected.
sebsg 2017/06/13 13:36:04 Can you put emphasis on the bank name? Like the fi
Shanfeng 2017/06/13 20:39:58 Done.
+ EXPECT_EQ(
+ base::UTF8ToUTF16(std::string("Visa") + kUTF8MidlineEllipsis + "9012"),
+ suggestions[0].value);
+ EXPECT_EQ(
+ base::UTF8ToUTF16(std::string("Amex") + kUTF8MidlineEllipsis + "8555"),
+ suggestions[1].value);
+ EXPECT_EQ(
+ base::UTF8ToUTF16(std::string("Chase") + kUTF8MidlineEllipsis + "2110"),
+ suggestions[2].value);
+ EXPECT_EQ(base::UTF8ToUTF16(std::string("Mastercard") + kUTF8MidlineEllipsis +
+ "2109"),
+ suggestions[3].value);
+}
+
+// Tests that will show network if no bank name,
+TEST_F(PersonalDataManagerTest,
+ GetCreditCardSuggestions_ShowNetworkIfNoBankName) {
+ // Turn on feature flag.
+ base::test::ScopedFeatureList scoped_feature_list_;
+ scoped_feature_list_.InitAndEnableFeature(kAutofillCreditCardBankNameDisplay);
+
+ EnableWalletCardImport();
+ SetupReferenceLocalCreditCards();
+
+ // Add some server cards.
+ std::vector<CreditCard> server_cards;
+ server_cards.push_back(CreditCard(CreditCard::MASKED_SERVER_CARD, "b459"));
+ test::SetCreditCardInfo(&server_cards.back(), "Emmet Dalton", "2110", "12",
+ "2999", "1");
+ server_cards.back().set_use_count(2);
+ server_cards.back().set_use_date(AutofillClock::Now() -
+ base::TimeDelta::FromDays(1));
+ server_cards.back().SetNetworkForMaskedCard(kVisaCard);
+
+ test::SetServerCreditCards(autofill_table_, server_cards);
+ personal_data_->Refresh();
+ EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged())
+ .WillOnce(QuitMainMessageLoop());
+ base::RunLoop().Run();
+
+ std::vector<Suggestion> suggestions =
+ personal_data_->GetCreditCardSuggestions(
+ AutofillType(CREDIT_CARD_NUMBER),
+ /* field_contents= */ base::string16());
+ ASSERT_EQ(4U, suggestions.size());
+
+ // All cards should be ordered as expected.
+ EXPECT_EQ(
+ base::UTF8ToUTF16(std::string("Visa") + kUTF8MidlineEllipsis + "9012"),
sebsg 2017/06/13 13:36:04 The test above already tests this right? If you ch
Shanfeng 2017/06/13 20:39:58 Done.
+ suggestions[0].value);
+ EXPECT_EQ(
+ base::UTF8ToUTF16(std::string("Amex") + kUTF8MidlineEllipsis + "8555"),
+ suggestions[1].value);
+ EXPECT_EQ(
+ base::UTF8ToUTF16(std::string("Visa") + kUTF8MidlineEllipsis + "2110"),
+ suggestions[2].value);
+ EXPECT_EQ(base::UTF8ToUTF16(std::string("Mastercard") + kUTF8MidlineEllipsis +
+ "2109"),
+ suggestions[3].value);
+}
+
// Tests that only the full server card is kept when deduping with a local
// duplicate of it.
TEST_F(PersonalDataManagerTest,

Powered by Google App Engine
This is Rietveld 408576698