Commit f2f20681 authored by Jared Saul's avatar Jared Saul Committed by Commit Bot

[AF] Fix local card migration bubble not logging strikes for same tab

Fixes an issue where declining/ignoring the local card migration promo
bubble would only log strikes the first time for a given tab, but not
for subsequent times on that same tab.

Change-Id: If75c52a4315369820339fc8909b0881ca92adbc0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1827510Reviewed-by: default avatarEvan Stade <estade@chromium.org>
Commit-Queue: Jared Saul <jsaul@google.com>
Cr-Commit-Position: refs/heads/master@{#700470}
parent 79e8d212
......@@ -44,6 +44,7 @@ void LocalCardMigrationBubbleControllerImpl::ShowBubble(
return;
is_reshow_ = false;
should_add_strikes_on_bubble_close_ = true;
local_card_migration_bubble_closure_ =
std::move(local_card_migration_bubble_closure);
......
......@@ -903,6 +903,33 @@ IN_PROC_BROWSER_TEST_F(LocalCardMigrationBrowserTest,
ElementsAre(Bucket(2, 1)));
}
// Ensures that rejecting the migration bubble repeatedly adds 2 strikes every
// time, even for the same tab.
IN_PROC_BROWSER_TEST_F(LocalCardMigrationBrowserTest,
ClosingBubbleAgainAddsLocalCardMigrationStrikes) {
base::test::ScopedFeatureList scoped_feature_list;
scoped_feature_list.InitAndEnableFeature(
features::kAutofillLocalCardMigrationUsesStrikeSystemV2);
base::HistogramTester histogram_tester;
SaveLocalCard(kFirstCardNumber);
SaveLocalCard(kSecondCardNumber);
UseCardAndWaitForMigrationOffer(kFirstCardNumber);
ClickOnDialogViewAndWait(GetCloseButton(),
GetLocalCardMigrationOfferBubbleViews());
// Do it again for the same tab.
UseCardAndWaitForMigrationOffer(kFirstCardNumber);
ClickOnDialogViewAndWait(GetCloseButton(),
GetLocalCardMigrationOfferBubbleViews());
// No bubble should be showing.
EXPECT_EQ(nullptr, GetLocalCardMigrationOfferBubbleViews());
// Metrics: Added 2 strikes each time, for totals of 2 then 4.
EXPECT_THAT(histogram_tester.GetAllSamples(
"Autofill.StrikeDatabase.NthStrikeAdded.LocalCardMigration"),
ElementsAre(Bucket(2, 1), Bucket(4, 1)));
}
// Ensures that reshowing and closing bubble after previously closing it does
// not add strikes.
IN_PROC_BROWSER_TEST_F(LocalCardMigrationBrowserTest,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment