Commit b2f86997 authored by Yao Xiao's avatar Yao Xiao Committed by Commit Bot

Fill in the NIK in a test factory used in network_context_unittest.cc

This will fix some broken tests
(e.g. NetworkContextMockHostTest.CustomProxyConfigHeadersAddedBeforeCache)
when SplitCache feature is enabled.

Also fixed another test expectation to make it work when SplitCache is
enabled.

Bug: 1009597
Change-Id: Iff8e67e7791f4458941e25eeb4c29364057fabf9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1844474Reviewed-by: default avatarMatt Menke <mmenke@chromium.org>
Reviewed-by: default avatarShivani Sharma <shivanisha@chromium.org>
Commit-Queue: Yao Xiao <yaoxia@chromium.org>
Cr-Commit-Position: refs/heads/master@{#703934}
parent e0274db5
...@@ -213,6 +213,9 @@ std::unique_ptr<TestURLLoaderClient> FetchRequest( ...@@ -213,6 +213,9 @@ std::unique_ptr<TestURLLoaderClient> FetchRequest(
auto params = mojom::URLLoaderFactoryParams::New(); auto params = mojom::URLLoaderFactoryParams::New();
params->process_id = process_id; params->process_id = process_id;
params->is_corb_enabled = false; params->is_corb_enabled = false;
params->network_isolation_key =
net::NetworkIsolationKey(url::Origin::Create(GURL("https://abc.com")),
url::Origin::Create(GURL("https://xyz.com")));
network_context->CreateURLLoaderFactory(mojo::MakeRequest(&loader_factory), network_context->CreateURLLoaderFactory(mojo::MakeRequest(&loader_factory),
std::move(params)); std::move(params));
...@@ -1365,10 +1368,14 @@ TEST_F(NetworkContextTest, NotifyExternalCacheHit) { ...@@ -1365,10 +1368,14 @@ TEST_F(NetworkContextTest, NotifyExternalCacheHit) {
network_context->NotifyExternalCacheHit(test_url, test_url.scheme(), key); network_context->NotifyExternalCacheHit(test_url, test_url.scheme(), key);
EXPECT_EQ(i + 1, mock_cache.disk_cache()->GetExternalCacheHits().size()); EXPECT_EQ(i + 1, mock_cache.disk_cache()->GetExternalCacheHits().size());
// Potentially a brittle check as the value sent to disk_cache is a "key." // Note: if this breaks check HttpCache::GenerateCacheKey() for changes.
// This key just happens to be the same as the GURL from the test input. std::string expected_key_prefix =
// So if this breaks check HttpCache::GenerateCacheKey() for changes. base::FeatureList::IsEnabled(
EXPECT_EQ(test_url, mock_cache.disk_cache()->GetExternalCacheHits().back()); net::features::kSplitCacheByNetworkIsolationKey)
? base::StrCat({"_dk_", key.ToString(), " "})
: "";
EXPECT_EQ(expected_key_prefix + test_url.spec(),
mock_cache.disk_cache()->GetExternalCacheHits().back());
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment