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

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

Issue 2711543002: Experiment to add bank name in autofill ui. (Closed)
Patch Set: Add comments about the flag Created 3 years, 10 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 dc8454604eaa5f946d8040604ef89942bd64456b..cb79c5c1126ee04e72f34aee51c195c1848cb27c 100644
--- a/components/autofill/core/browser/personal_data_manager_unittest.cc
+++ b/components/autofill/core/browser/personal_data_manager_unittest.cc
@@ -23,6 +23,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"
@@ -3767,6 +3768,50 @@ 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");
+ server_cards.back().set_use_count(2);
+ server_cards.back().set_use_date(AutofillClock::Now() -
+ base::TimeDelta::FromDays(1));
+ server_cards.back().SetTypeForMaskedCard(kVisaCard);
+ server_cards.back().SetBankName("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.
+ EXPECT_EQ(UTF8ToUTF16("Visa" + kUTF8MidlineEllipsis + "9012"),
+ suggestions[0].value);
+ EXPECT_EQ(UTF8ToUTF16("Amex" + kUTF8MidlineEllipsis + "8555"),
+ suggestions[1].value);
+ EXPECT_EQ(UTF8ToUTF16("Chase" + kUTF8MidlineEllipsis + "2110"),
+ suggestions[2].value);
+ EXPECT_EQ(UTF8ToUTF16("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