chromium/chrome/browser/predictors/preconnect_manager_unittest.cc

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

#include "chrome/browser/predictors/preconnect_manager.h"

#include <map>
#include <utility>

#include "base/format_macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "base/ranges/algorithm.h"
#include "base/run_loop.h"
#include "base/strings/stringprintf.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "chrome/browser/predictors/loading_test_util.h"
#include "chrome/browser/predictors/predictors_features.h"
#include "chrome/browser/predictors/proxy_lookup_client_impl.h"
#include "chrome/browser/predictors/resolve_host_client_impl.h"
#include "chrome/browser/preloading/preloading_prefs.h"
#include "chrome/test/base/testing_profile.h"
#include "content/public/test/browser_task_environment.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "net/base/load_flags.h"
#include "net/base/network_anonymization_key.h"
#include "net/dns/public/resolve_error_info.h"
#include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
#include "services/network/test/test_network_context.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/origin.h"

_;
Mock;
SaveArg;
StrictMock;

namespace predictors {

namespace {

net::ProxyInfo GetIndirectProxyInfo() {}

net::ProxyInfo GetDirectProxyInfo() {}

class MockPreconnectManagerDelegate : public PreconnectManager::Delegate {};

class MockNetworkContext : public network::TestNetworkContext {};

// Creates a NetworkAnonymizationKey for a main frame navigation to URL.
net::NetworkAnonymizationKey CreateNetworkAnonymizationKey(
    const GURL& main_frame_url) {}

}  // namespace

class PreconnectManagerTest : public testing::Test {};

PreconnectManagerTest::PreconnectManagerTest()
    :{}

PreconnectManagerTest::~PreconnectManagerTest() {}

TEST_F(PreconnectManagerTest, TestStartOneUrlPreresolve) {}

TEST_F(PreconnectManagerTest, TestStartOneUrlPreconnect) {}

TEST_F(PreconnectManagerTest, TestLimitPreconnectCount) {}

TEST_F(PreconnectManagerTest,
       TestStartOneUrlPreconnectWithNetworkIsolationKey) {}

// Sends preconnect request for a webpage, and stops the request before
// all pertaining preconnect requests finish. Next, preconnect request
// for the same webpage is sent again. Verifies that all the preconnects
// related to the second request are dispatched on the network.
TEST_F(PreconnectManagerTest, TestStartOneUrlPreconnect_MultipleTimes) {}

// Sends preconnect request for two webpages, and stops one request before
// all pertaining preconnect requests finish. Next, preconnect request
// for the same webpage is sent again. Verifies that all the preconnects
// related to the second request are dispatched on the network.
TEST_F(PreconnectManagerTest, TestTwoConcurrentMainFrameUrls_MultipleTimes) {}

// Starts preconnect request for two webpages. The preconnect request for the
// second webpage is cancelled after one of its associated preconnect request
// goes in-flight.
// Verifies that if (i) Preconnect for a webpage is cancelled then its state is
// cleared after its associated in-flight requests finish; and, (ii) If the
// preconnect for that webpage is requested again, then
// the pertaining requests are dispatched to the network.
TEST_F(PreconnectManagerTest,
       TestStartOneUrlPreconnect_MultipleTimes_CancelledAfterInFlight) {}

// Sends a preconnect request again after the first request finishes. Verifies
// that the second preconnect request is dispatched to the network.
TEST_F(PreconnectManagerTest,
       TestStartOneUrlPreconnect_MultipleTimes_LessThanThree) {}

TEST_F(PreconnectManagerTest, TestStopOneUrlBeforePreconnect) {}

TEST_F(PreconnectManagerTest, TestGetCallbackAfterDestruction) {}

TEST_F(PreconnectManagerTest, TestUnqueuedPreresolvesCanceled) {}

TEST_F(PreconnectManagerTest, TestQueueingMetricsRecorded) {}

TEST_F(PreconnectManagerTest, TestTwoConcurrentMainFrameUrls) {}

// Checks that the PreconnectManager queues up preconnect requests for URLs
// with same host.
TEST_F(PreconnectManagerTest, TestTwoConcurrentSameHostMainFrameUrls) {}

TEST_F(PreconnectManagerTest, TestStartPreresolveHost) {}

TEST_F(PreconnectManagerTest, TestStartPreresolveHostDisabledViaUI) {}

TEST_F(PreconnectManagerTest, TestStartPreresolveHosts) {}

TEST_F(PreconnectManagerTest, TestStartPreresolveHostsDisabledViaUI) {}

TEST_F(PreconnectManagerTest, TestStartPreconnectUrl) {}

TEST_F(PreconnectManagerTest, TestStartPreconnectUrlDisabledViaUI) {}

TEST_F(PreconnectManagerTest, TestStartPreconnectUrlWithNetworkIsolationKey) {}

TEST_F(PreconnectManagerTest, TestDetachedRequestHasHigherPriority) {}

TEST_F(PreconnectManagerTest, TestSuccessfulProxyLookup) {}

TEST_F(PreconnectManagerTest, TestStartDisabledViaUI) {}

TEST_F(PreconnectManagerTest, TestSuccessfulHostLookupAfterProxyLookupFailure) {}

TEST_F(PreconnectManagerTest, TestBothProxyAndHostLookupFailed) {}

}  // namespace predictors