#include "components/optimization_guide/core/hint_cache.h"
#include <optional>
#include <string>
#include "base/files/scoped_temp_dir.h"
#include "base/functional/bind.h"
#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/task_environment.h"
#include "components/optimization_guide/core/optimization_guide_features.h"
#include "components/optimization_guide/core/optimization_guide_store.h"
#include "components/optimization_guide/core/proto_database_provider_test_base.h"
#include "components/optimization_guide/core/store_update_data.h"
#include "components/optimization_guide/proto/hint_cache.pb.h"
#include "components/optimization_guide/proto/hints.pb.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
namespace optimization_guide {
namespace {
std::string GetHostDomainOrg(int index) { … }
class HintCacheTest : public ProtoDatabaseProviderTestBase,
public testing::WithParamInterface<bool> { … };
INSTANTIATE_TEST_SUITE_P(…);
TEST_P(HintCacheTest, ComponentUpdate) { … }
TEST_P(HintCacheTest, ComponentUpdateWithSameVersionIgnored) { … }
TEST_P(HintCacheTest, ComponentUpdateWithEarlierVersionIgnored) { … }
TEST_P(HintCacheTest, ComponentUpdateWithLaterVersionProcessed) { … }
TEST_P(HintCacheTest, ComponentHintsAvailableAfterRestart) { … }
TEST_P(HintCacheTest, ComponentHintsUpdatableAfterRestartWithPurge) { … }
TEST_P(HintCacheTest, ComponentHintsNotRetainedAfterRestartWithPurge) { … }
TEST_P(HintCacheTest, TestMemoryCacheLeastRecentlyUsedPurge) { … }
TEST_P(HintCacheTest, TestHostNotInCache) { … }
TEST_P(HintCacheTest, TestMemoryCacheLoadCallback) { … }
TEST_P(HintCacheTest, StoreValidFetchedHints) { … }
TEST_P(HintCacheTest, ParseEmptyFetchedHints) { … }
TEST_P(HintCacheTest, StoreValidFetchedHintsWithServerProvidedExpiryTime) { … }
TEST_P(HintCacheTest, StoreValidFetchedHintsWithDefaultExpiryTime) { … }
TEST_P(HintCacheTest, CacheValidURLKeyedHint) { … }
TEST_P(HintCacheTest, URLKeyedHintExpired) { … }
TEST_P(HintCacheTest, PurgeExpiredFetchedHints) { … }
TEST_P(HintCacheTest, ClearFetchedHints) { … }
TEST_P(HintCacheTest, UnsupportedURLsForURLKeyedHints) { … }
TEST_P(HintCacheTest, URLsWithNoURLKeyedHints) { … }
TEST_P(HintCacheTest, ProcessHintsNoUpdateData) { … }
TEST_P(HintCacheTest,
ProcessHintsWithNoPageHintsOrAllowlistedOptimizationsAndUpdateData) { … }
TEST_P(HintCacheTest,
ProcessHintsWithNoPageHintsButHasAllowlistedOptimizationsAndUpdateData) { … }
TEST_P(HintCacheTest, ProcessHintsWithPageHintsAndUpdateData) { … }
TEST_P(HintCacheTest, RemoveHintsForURLs) { … }
TEST_P(HintCacheTest, RemoveHintsForHosts) { … }
TEST_P(HintCacheTest, URLsWithNoURLKeyedHintsFetchedURLWasFragment) { … }
}
}