Add support for NotRestoredReasons above 63 to BFCache tests.
Previously we only supported the enum values up to 63. This is being done to support https://crrev.com/c/6198936. This migrates the code to use EnumSet which matches the code in back_forward_cache_metrics.cc more closely. Change-Id: I1ba3e8a7e564b03a46cbd623466ffb891d1a694b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6217562 Commit-Queue: Fergal Daly <fergal@chromium.org> Auto-Submit: Fergal Daly <fergal@chromium.org> Reviewed-by: Rakina Zata Amni <rakina@chromium.org> Cr-Commit-Position: refs/heads/main@{#1414761}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
46c078f7f7
commit
fbb93e42a6
@ -2809,12 +2809,12 @@ IN_PROC_BROWSER_TEST_P(BackForwardCacheBrowserUnloadHandlerTest,
|
||||
// 1) Navigate to A.
|
||||
EXPECT_TRUE(NavigateToURL(shell(), url_a));
|
||||
|
||||
std::vector<BackForwardCacheMetrics::NotRestoredReason>
|
||||
BackForwardCacheCanStoreDocumentResult::NotRestoredReasons
|
||||
expected_blocking_reasons;
|
||||
std::vector<blink::scheduler::WebSchedulerTrackedFeature>
|
||||
expected_blocklisted_reason;
|
||||
if (IsUnloadBlocklisted()) {
|
||||
expected_blocking_reasons.push_back(
|
||||
expected_blocking_reasons.Put(
|
||||
BackForwardCacheMetrics::NotRestoredReason::kBlocklistedFeatures);
|
||||
expected_blocklisted_reason.push_back(
|
||||
blink::scheduler::WebSchedulerTrackedFeature::kUnloadHandler);
|
||||
@ -2822,15 +2822,13 @@ IN_PROC_BROWSER_TEST_P(BackForwardCacheBrowserUnloadHandlerTest,
|
||||
switch (GetTestFrameType()) {
|
||||
case content::TestFrameType::kMainFrame:
|
||||
InstallUnloadHandlerOnMainFrame();
|
||||
expected_blocking_reasons.push_back(
|
||||
BackForwardCacheMetrics::NotRestoredReason::
|
||||
kUnloadHandlerExistsInMainFrame);
|
||||
expected_blocking_reasons.Put(BackForwardCacheMetrics::NotRestoredReason::
|
||||
kUnloadHandlerExistsInMainFrame);
|
||||
break;
|
||||
case content::TestFrameType::kSubFrame:
|
||||
InstallUnloadHandlerOnSubFrame();
|
||||
expected_blocking_reasons.push_back(
|
||||
BackForwardCacheMetrics::NotRestoredReason::
|
||||
kUnloadHandlerExistsInSubFrame);
|
||||
expected_blocking_reasons.Put(BackForwardCacheMetrics::NotRestoredReason::
|
||||
kUnloadHandlerExistsInSubFrame);
|
||||
break;
|
||||
default:
|
||||
NOTREACHED();
|
||||
|
@ -78,7 +78,7 @@ void BackForwardCacheMetricsTestMatcher::ExpectRestored(
|
||||
}
|
||||
|
||||
void BackForwardCacheMetricsTestMatcher::ExpectNotRestored(
|
||||
std::vector<BackForwardCacheMetrics::NotRestoredReason> not_restored,
|
||||
BackForwardCacheCanStoreDocumentResult::NotRestoredReasons not_restored,
|
||||
std::vector<blink::scheduler::WebSchedulerTrackedFeature> block_listed,
|
||||
const std::vector<ShouldSwapBrowsingInstance>& not_swapped,
|
||||
const std::vector<BackForwardCache::DisabledReason>&
|
||||
@ -157,7 +157,7 @@ void BackForwardCacheMetricsTestMatcher::ExpectEvictedAfterCommitted(
|
||||
|
||||
void BackForwardCacheMetricsTestMatcher::ExpectOutcome(
|
||||
BackForwardCacheMetrics::HistoryNavigationOutcome outcome,
|
||||
std::vector<BackForwardCacheMetrics::NotRestoredReason> not_restored,
|
||||
BackForwardCacheCanStoreDocumentResult::NotRestoredReasons not_restored,
|
||||
base::Location location) {
|
||||
base::HistogramBase::Sample32 sample = base::HistogramBase::Sample32(outcome);
|
||||
AddSampleToBuckets(&expected_outcomes_, sample);
|
||||
@ -198,7 +198,7 @@ void BackForwardCacheMetricsTestMatcher::ExpectOutcome(
|
||||
}
|
||||
|
||||
void BackForwardCacheMetricsTestMatcher::ExpectReasons(
|
||||
std::vector<BackForwardCacheMetrics::NotRestoredReason> not_restored,
|
||||
BackForwardCacheCanStoreDocumentResult::NotRestoredReasons not_restored,
|
||||
std::vector<blink::scheduler::WebSchedulerTrackedFeature> block_listed,
|
||||
const std::vector<ShouldSwapBrowsingInstance>& not_swapped,
|
||||
const std::vector<BackForwardCache::DisabledReason>&
|
||||
@ -230,14 +230,12 @@ void BackForwardCacheMetricsTestMatcher::ExpectReasons(
|
||||
}
|
||||
|
||||
void BackForwardCacheMetricsTestMatcher::ExpectNotRestoredReasons(
|
||||
std::vector<BackForwardCacheMetrics::NotRestoredReason> reasons,
|
||||
BackForwardCacheCanStoreDocumentResult::NotRestoredReasons reasons,
|
||||
base::Location location) {
|
||||
uint64_t not_restored_reasons_bits = 0;
|
||||
for (BackForwardCacheMetrics::NotRestoredReason reason : reasons) {
|
||||
base::HistogramBase::Sample32 sample =
|
||||
base::HistogramBase::Sample32(reason);
|
||||
AddSampleToBuckets(&expected_not_restored_, sample);
|
||||
not_restored_reasons_bits |= 1ull << static_cast<int>(reason);
|
||||
}
|
||||
|
||||
auto delegate_disabled_idx =
|
||||
@ -266,11 +264,19 @@ void BackForwardCacheMetricsTestMatcher::ExpectNotRestoredReasons(
|
||||
|
||||
std::string not_restored_reasons = "BackForwardCache.NotRestoredReasons";
|
||||
expected_ukm_not_restored_reasons_.push_back(
|
||||
{{not_restored_reasons, not_restored_reasons_bits}});
|
||||
{{not_restored_reasons, reasons.GetNth64bitWordBitmask(0).value()}});
|
||||
EXPECT_THAT(
|
||||
ukm_recorder().GetMetrics("HistoryNavigation", {not_restored_reasons}),
|
||||
expected_ukm_not_restored_reasons_)
|
||||
<< location.ToString();
|
||||
|
||||
std::string not_restored_reasons2 = "BackForwardCache.NotRestoredReasons2";
|
||||
expected_ukm_not_restored_reasons2_.push_back(
|
||||
{{not_restored_reasons2, reasons.GetNth64bitWordBitmask(1).value()}});
|
||||
EXPECT_THAT(
|
||||
ukm_recorder().GetMetrics("HistoryNavigation", {not_restored_reasons2}),
|
||||
expected_ukm_not_restored_reasons2_)
|
||||
<< location.ToString();
|
||||
}
|
||||
|
||||
void BackForwardCacheMetricsTestMatcher::ExpectBlocklistedFeatures(
|
||||
|
@ -71,7 +71,7 @@ class BackForwardCacheMetricsTestMatcher {
|
||||
void ExpectRestored(base::Location location);
|
||||
|
||||
void ExpectNotRestored(
|
||||
std::vector<BackForwardCacheMetrics::NotRestoredReason> not_restored,
|
||||
BackForwardCacheCanStoreDocumentResult::NotRestoredReasons not_restored,
|
||||
std::vector<blink::scheduler::WebSchedulerTrackedFeature> block_listed,
|
||||
const std::vector<ShouldSwapBrowsingInstance>& not_swapped,
|
||||
const std::vector<BackForwardCache::DisabledReason>&
|
||||
@ -113,11 +113,11 @@ class BackForwardCacheMetricsTestMatcher {
|
||||
// tests that it occurred.
|
||||
void ExpectOutcome(
|
||||
BackForwardCacheMetrics::HistoryNavigationOutcome outcome,
|
||||
std::vector<BackForwardCacheMetrics::NotRestoredReason> not_restored,
|
||||
BackForwardCacheCanStoreDocumentResult::NotRestoredReasons not_restored,
|
||||
base::Location location);
|
||||
|
||||
void ExpectReasons(
|
||||
std::vector<BackForwardCacheMetrics::NotRestoredReason> not_restored,
|
||||
BackForwardCacheCanStoreDocumentResult::NotRestoredReasons not_restored,
|
||||
std::vector<blink::scheduler::WebSchedulerTrackedFeature> block_listed,
|
||||
const std::vector<ShouldSwapBrowsingInstance>& not_swapped,
|
||||
const std::vector<BackForwardCache::DisabledReason>&
|
||||
@ -126,7 +126,7 @@ class BackForwardCacheMetricsTestMatcher {
|
||||
base::Location location);
|
||||
|
||||
void ExpectNotRestoredReasons(
|
||||
std::vector<BackForwardCacheMetrics::NotRestoredReason> reasons,
|
||||
BackForwardCacheCanStoreDocumentResult::NotRestoredReasons reasons,
|
||||
base::Location location);
|
||||
|
||||
void ExpectBlocklistedFeatures(
|
||||
@ -154,6 +154,7 @@ class BackForwardCacheMetricsTestMatcher {
|
||||
|
||||
std::vector<UkmMetrics> expected_ukm_outcomes_;
|
||||
std::vector<UkmMetrics> expected_ukm_not_restored_reasons_;
|
||||
std::vector<UkmMetrics> expected_ukm_not_restored_reasons2_;
|
||||
|
||||
// Indicates whether metrics for all sites regardless of the domains are
|
||||
// checked or not.
|
||||
|
Reference in New Issue
Block a user