Index: chrome/browser/net/network_context_configuration_browsertest.cc |
diff --git a/chrome/browser/net/system_network_context_manager_browsertest.cc b/chrome/browser/net/network_context_configuration_browsertest.cc |
similarity index 50% |
rename from chrome/browser/net/system_network_context_manager_browsertest.cc |
rename to chrome/browser/net/network_context_configuration_browsertest.cc |
index 607bd6583f62a638d69a4c67a3b490b0a59948f5..9c5d61398d0fca2e754c781a5f00324b79c71273 100644 |
--- a/chrome/browser/net/system_network_context_manager_browsertest.cc |
+++ b/chrome/browser/net/network_context_configuration_browsertest.cc |
@@ -2,9 +2,12 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "chrome/browser/net/system_network_context_manager.h" |
- |
#include "base/test/scoped_feature_list.h" |
+#include "chrome/browser/net/profile_network_context_service.h" |
+#include "chrome/browser/net/profile_network_context_service_factory.h" |
+#include "chrome/browser/net/system_network_context_manager.h" |
+#include "chrome/browser/profiles/profile.h" |
+#include "chrome/browser/ui/browser.h" |
#include "chrome/test/base/in_process_browser_test.h" |
#include "content/public/common/content_features.h" |
#include "content/public/common/content_switches.h" |
@@ -27,23 +30,53 @@ enum class NetworkServiceState { |
kEnabled, |
}; |
-class SystemNetworkContextManagerTest |
+enum class NetworkContextType { |
+ kSystem, |
+ kProfile, |
+ kIncognitoProfile, |
+}; |
+ |
+struct TestCase { |
+ NetworkServiceState network_service_state; |
+ NetworkContextType network_context_type; |
+}; |
+ |
+// Tests the system, profile, and incognito profile NetworkContexts. |
+class NetworkContextConfigurationBrowserTest |
: public InProcessBrowserTest, |
- public testing::WithParamInterface<NetworkServiceState> { |
+ public testing::WithParamInterface<TestCase> { |
public: |
- SystemNetworkContextManagerTest() { |
+ NetworkContextConfigurationBrowserTest() { |
EXPECT_TRUE(embedded_test_server()->Start()); |
} |
- ~SystemNetworkContextManagerTest() override {} |
+ ~NetworkContextConfigurationBrowserTest() override {} |
void SetUpInProcessBrowserTestFixture() override { |
feature_list_.InitAndEnableFeature(features::kNetworkService); |
} |
void SetUpOnMainThread() override { |
- SystemNetworkContextManager::Context()->CreateURLLoaderFactory( |
- MakeRequest(&loader_factory_), 0); |
+ switch (GetParam().network_context_type) { |
+ case NetworkContextType::kSystem: { |
+ network_context_ = SystemNetworkContextManager::Context(); |
+ break; |
+ } |
+ case NetworkContextType::kProfile: { |
+ network_context_ = ProfileNetworkContextServiceFactory::GetInstance() |
+ ->GetForContext(browser()->profile()) |
+ ->MainContext(); |
+ break; |
+ } |
+ case NetworkContextType::kIncognitoProfile: { |
+ Browser* incognito = CreateIncognitoBrowser(); |
+ network_context_ = ProfileNetworkContextServiceFactory::GetInstance() |
+ ->GetForContext(incognito->profile()) |
+ ->MainContext(); |
+ break; |
+ } |
+ } |
+ network_context_->CreateURLLoaderFactory(MakeRequest(&loader_factory_), 0); |
} |
content::mojom::URLLoaderFactory* loader_factory() { |
@@ -51,11 +84,12 @@ class SystemNetworkContextManagerTest |
} |
private: |
+ content::mojom::NetworkContext* network_context_ = nullptr; |
content::mojom::URLLoaderFactoryPtr loader_factory_; |
base::test::ScopedFeatureList feature_list_; |
}; |
-IN_PROC_BROWSER_TEST_P(SystemNetworkContextManagerTest, BasicRequest) { |
+IN_PROC_BROWSER_TEST_P(NetworkContextConfigurationBrowserTest, BasicRequest) { |
content::mojom::URLLoaderAssociatedPtr loader; |
content::ResourceRequest request; |
content::TestURLLoaderClient client; |
@@ -83,9 +117,27 @@ IN_PROC_BROWSER_TEST_P(SystemNetworkContextManagerTest, BasicRequest) { |
} |
INSTANTIATE_TEST_CASE_P( |
- /* no prefix */, |
- SystemNetworkContextManagerTest, |
- ::testing::Values(NetworkServiceState::kDisabled, |
- NetworkServiceState::kEnabled)); |
+ SystemNetworkContext, |
+ NetworkContextConfigurationBrowserTest, |
+ ::testing::Values(TestCase({NetworkServiceState::kDisabled, |
+ NetworkContextType::kSystem}), |
+ TestCase({NetworkServiceState::kEnabled, |
+ NetworkContextType::kSystem}))); |
+ |
+INSTANTIATE_TEST_CASE_P( |
+ ProfileMainNetworkContext, |
+ NetworkContextConfigurationBrowserTest, |
+ ::testing::Values(TestCase({NetworkServiceState::kDisabled, |
+ NetworkContextType::kProfile}), |
+ TestCase({NetworkServiceState::kEnabled, |
+ NetworkContextType::kProfile}))); |
+ |
+INSTANTIATE_TEST_CASE_P( |
+ IncognitoProfileMainNetworkContext, |
+ NetworkContextConfigurationBrowserTest, |
+ ::testing::Values(TestCase({NetworkServiceState::kDisabled, |
+ NetworkContextType::kIncognitoProfile}), |
+ TestCase({NetworkServiceState::kEnabled, |
+ NetworkContextType::kIncognitoProfile}))); |
} // namespace |