chromium/content/browser/back_forward_cache_test_util.h

// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CONTENT_BROWSER_BACK_FORWARD_CACHE_TEST_UTIL_H_
#define CONTENT_BROWSER_BACK_FORWARD_CACHE_TEST_UTIL_H_

#include <string_view>
#include <vector>

#include "base/location.h"
#include "base/test/metrics/histogram_tester.h"
#include "components/ukm/test_ukm_recorder.h"
#include "content/browser/renderer_host/back_forward_cache_metrics.h"
#include "content/browser/renderer_host/render_frame_host_impl.h"
#include "content/public/browser/back_forward_cache.h"
#include "third_party/blink/public/common/scheduler/web_scheduler_tracked_feature.h"

namespace content {

namespace {
// TODO(yuzus): Make a way to use a non sticky dummy feature.
constexpr auto* kBlockingPagePath =;
constexpr auto* kBlockingReasonString =;
constexpr auto kBlockingReasonEnum =;
constexpr auto* kBlockingScript =;
}  // namespace

// `BackForwardCacheMetricsTestMatcher` provides common matchers and
// expectations to help make test assertions on BackForwardCache-related
// metrics.
//
// This class tries to remove the efforts to reset HistogramTester by keeping
// local copies of expected metrics in expected_* members such that subsequent
// calls to Expect*() won't need to take previous metrics into account.
//
// For example:
// ...
//   DoActionCauseFeatureA();
//   // The implementation compares {FeatureA} with metrics from
//   // `histogram_tester()`, which is {FeatureA}.
//   // FeatureA will be stored in in `expected_blocklisted_features_`.
//   ExpectBlocklistedFeature(FeatureA);
//
//   // `histogram_tester()` keeps FeatureA and continues to accumulate metrics.
//
//   DoActionCauseFeatureB();
//   // The implementation compares {FeatureA, FeatureB} with accumulated
//   // metrics from `histogram_tester()`, which is also {FeatureA, FeatureB}.
//   ExpectBlocklistedFeature(FeatureB);
//
class BackForwardCacheMetricsTestMatcher {};

}  // namespace content

#endif  // CONTENT_BROWSER_BACK_FORWARD_CACHE_TEST_UTIL_H_