chromium/services/network/prefetch_cache_unittest.cc

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

#include "services/network/prefetch_cache.h"

#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "net/base/isolation_info.h"
#include "net/base/network_isolation_key.h"
#include "net/base/schemeful_site.h"
#include "net/cookies/site_for_cookies.h"
#include "services/network/prefetch_url_loader_client.h"
#include "services/network/public/cpp/features.h"
#include "services/network/public/cpp/resource_request.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
#include "url/origin.h"

namespace network {

namespace {

constexpr size_t kMaxSize =;

// These Test* functions return a value of the appropriate type useful for
// testing. By passing in an index, you can make them produce different
// hostnames that are not same-origin with each other.
GURL TestURL(int index = 0) {}

url::Origin TestOrigin(int index = 0) {}

net::IsolationInfo TestIsolationInfo(int index = 0) {}

net::NetworkIsolationKey TestNIK(int index = 0) {}

ResourceRequest MakeResourceRequest(GURL url,
                                    net::IsolationInfo isolation_info) {}

class PrefetchCacheTest : public ::testing::Test {};

TEST_F(PrefetchCacheTest, Emplace) {}

TEST_F(PrefetchCacheTest, EmplaceNoNIK) {}

TEST_F(PrefetchCacheTest, EmplaceTransientNIK) {}

TEST_F(PrefetchCacheTest, EmplaceFileURL) {}

TEST_F(PrefetchCacheTest, EmplaceSameURLNIK) {}

TEST_F(PrefetchCacheTest, EmplaceDifferentURLSameNIK) {}

TEST_F(PrefetchCacheTest, EmplaceSameURLDifferentNIK) {}

TEST_F(PrefetchCacheTest, SuccessfulLookup) {}

TEST_F(PrefetchCacheTest, FailedLookup) {}

TEST_F(PrefetchCacheTest, EmplaceRespectsMaxSize) {}

TEST_F(PrefetchCacheTest, ConsumedNodesNoLongerInCache) {}

TEST_F(PrefetchCacheTest, ConsumedNodesDontCountTowardsCacheSize) {}

TEST_F(PrefetchCacheTest, ExpiryHappens) {}

// Prefetches that are submitted close together are expired from the cache
// together, to reduce the number of unnecessary wake-ups.
TEST_F(PrefetchCacheTest, TimerSlackIsApplied) {}

TEST_F(PrefetchCacheTest, SeparatedPrefetchesExpiredSeparatedly) {}

TEST_F(PrefetchCacheTest, ConsumedPrefetchesAreNotExpired) {}

}  // namespace

}  // namespace network