Commit 7aeb3c8f authored by Michael Crouse's avatar Michael Crouse Committed by Commit Bot

[LiteVide] Deflake HasHint browsertest.

The browser test times outs and causes flakes. There are 2 wait events
that could cause timeouts: blocklist loaded and a histogram check.

This CL uses the updated blocklist loaded provided by the delegate which
which more clearly marks when the blocklist is loaded.

This CL also shifts the tab closing later to remove potential race of
the hint check logic with the tab closing. A future change will remove
the tab closing logic that may improve this further.

Bug: 1122603
Change-Id: I898096f3350c057a14661163a8b99ac04fedd299
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2380153Reviewed-by: default avatarSophie Chang <sophiechang@chromium.org>
Commit-Queue: Michael Crouse <mcrouse@chromium.org>
Cr-Commit-Position: refs/heads/master@{#802341}
parent 60d9a482
......@@ -314,14 +314,12 @@ void LiteVideoDecider::OnOptimizationGuideHintAvailable(
std::move(callback).Run(hint, blocklist_reason, decision);
}
void LiteVideoDecider::OnUserBlocklistedStatusChange(bool blocklisted) {
void LiteVideoDecider::OnLoadingStateChanged(bool is_loaded) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
if (!blocklist_loaded_) {
blocklist_loaded_ = true;
// Local event used as a signal for testing.
blocklist_loaded_ = is_loaded;
if (blocklist_loaded_)
LOCAL_HISTOGRAM_BOOLEAN("LiteVideo.UserBlocklist.BlocklistLoaded", true);
}
}
void LiteVideoDecider::OnEffectiveConnectionTypeChanged(
......
......@@ -68,7 +68,7 @@ class LiteVideoDecider
}
// blocklist::OptOutBlocklistDelegate
void OnUserBlocklistedStatusChange(bool blocklisted) override;
void OnLoadingStateChanged(bool is_loaded) override;
void OnBlocklistCleared(base::Time time) override;
// network::NetworkConnectionTracker::NetworkConnectionObserver:
......
......@@ -305,9 +305,6 @@ IN_PROC_BROWSER_TEST_P(LiteVideoKeyedServiceBrowserTest,
// Navigate metrics get recorded.
ui_test_utils::NavigateToURL(browser(), navigation_url);
// Close the tab to flush the UKM metrics.
browser()->tab_strip_model()->GetActiveWebContents()->Close();
EXPECT_GT(RetryForHistogramUntilCountReached(
*histogram_tester(), "LiteVideo.HintAgent.HasHint", 1),
0);
......@@ -320,6 +317,10 @@ IN_PROC_BROWSER_TEST_P(LiteVideoKeyedServiceBrowserTest,
lite_video::LiteVideoBlocklistReason::kAllowed, 1);
histogram_tester()->ExpectTotalCount(
"LiteVideo.CanApplyLiteVideo.UserBlocklist.SubFrame", 0);
// Close the tab to flush the UKM metrics.
browser()->tab_strip_model()->GetActiveWebContents()->Close();
auto entries =
ukm_recorder.GetEntriesByName(ukm::builders::LiteVideo::kEntryName);
ASSERT_EQ(1u, entries.size());
......
......@@ -30,7 +30,7 @@ class OptOutBlocklistDelegate {
virtual void OnUserBlocklistedStatusChange(bool blocklisted) {}
// Notifies |this| the blocklist loaded state changed to |is_loaded|.
virtual void OnLoadingStateChanged(bool is_load) {}
virtual void OnLoadingStateChanged(bool is_loaded) {}
// Notifies |this| that the blocklist is cleared at |time|.
virtual void OnBlocklistCleared(base::Time time) {}
......
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