#include "chrome/browser/predictors/resource_prefetch_predictor.h"
#include <algorithm>
#include <iostream>
#include <memory>
#include <utility>
#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted.h"
#include "base/strings/stringprintf.h"
#include "base/task/sequenced_task_runner.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/test_simple_task_runner.h"
#include "base/time/time.h"
#include "chrome/browser/history/history_service_factory.h"
#include "chrome/browser/predictors/loading_predictor.h"
#include "chrome/browser/predictors/loading_test_util.h"
#include "chrome/browser/predictors/predictors_features.h"
#include "chrome/browser/predictors/resource_prefetch_predictor_tables.h"
#include "chrome/test/base/testing_profile.h"
#include "components/history/core/browser/history_service.h"
#include "components/history/core/browser/history_types.h"
#include "components/sessions/core/session_id.h"
#include "content/public/test/browser_task_environment.h"
#include "content/public/test/test_utils.h"
#include "net/base/network_isolation_key.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/features.h"
#include "url/gurl.h"
#include "url/origin.h"
StrictMock;
UnorderedElementsAre;
namespace predictors {
namespace {
RedirectDataMap;
OriginDataMap;
template <typename T>
class FakeLoadingPredictorKeyValueTable
: public sqlite_proto::KeyValueTable<T> { … };
class MockResourcePrefetchPredictorTables
: public ResourcePrefetchPredictorTables { … };
class MockResourcePrefetchPredictorObserver : public TestObserver { … };
}
class ResourcePrefetchPredictorTest : public testing::Test { … };
ResourcePrefetchPredictorTest::ResourcePrefetchPredictorTest()
: … { … }
ResourcePrefetchPredictorTest::~ResourcePrefetchPredictorTest() = default;
void ResourcePrefetchPredictorTest::SetUp() { … }
void ResourcePrefetchPredictorTest::TearDown() { … }
void ResourcePrefetchPredictorTest::InitializeSampleData() { … }
TEST_F(ResourcePrefetchPredictorTest, LazilyInitializeEmpty) { … }
TEST_F(ResourcePrefetchPredictorTest, LazilyInitializeWithData) { … }
TEST_F(ResourcePrefetchPredictorTest, NavigationUrlNotInDB) { … }
TEST_F(ResourcePrefetchPredictorTest,
NavigationUrlNotInDB_LoadingPredictorDisregardAlwaysAccessesNetwork) { … }
TEST_F(ResourcePrefetchPredictorTest, NavigationUrlInDB) { … }
TEST_F(ResourcePrefetchPredictorTest, NavigationUrlNotInDBAndDBFull) { … }
TEST_F(ResourcePrefetchPredictorTest,
NavigationManyResourcesWithDifferentOrigins) { … }
TEST_F(ResourcePrefetchPredictorTest, RedirectUrlNotInDB) { … }
TEST_F(ResourcePrefetchPredictorTest, RedirectUrlInDB) { … }
TEST_F(ResourcePrefetchPredictorTest, RedirectUrlInDB_MultipleSchemes) { … }
TEST_F(ResourcePrefetchPredictorTest, DeleteUrls) { … }
TEST_F(ResourcePrefetchPredictorTest, DeleteAllUrlsUninitialized) { … }
TEST_F(ResourcePrefetchPredictorTest, GetRedirectOrigin) { … }
class ResourcePrefetchPredictorPreconnectToRedirectTargetTest
: public ResourcePrefetchPredictorTest,
public ::testing::WithParamInterface<bool> { … };
INSTANTIATE_TEST_SUITE_P(…);
TEST_P(ResourcePrefetchPredictorPreconnectToRedirectTargetTest,
TestPredictPreconnectOrigins) { … }
TEST_F(ResourcePrefetchPredictorTest,
TestPredictPreconnectOrigins_RedirectsToNewOrigin) { … }
}