Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1813)

Unified Diff: net/proxy/proxy_script_fetcher_unittest.cc

Issue 118032: Disable the http cache when fetching PAC scripts. Also adds an extra log stat... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: [nochange] moved the CL to another computer Created 11 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/proxy/proxy_script_fetcher.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/proxy/proxy_script_fetcher_unittest.cc
===================================================================
--- net/proxy/proxy_script_fetcher_unittest.cc (revision 17543)
+++ net/proxy/proxy_script_fetcher_unittest.cc (working copy)
@@ -8,6 +8,8 @@
#include "base/compiler_specific.h"
#include "base/path_service.h"
#include "net/base/net_util.h"
+#include "net/disk_cache/disk_cache.h"
+#include "net/http/http_cache.h"
#include "net/url_request/url_request_unittest.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"
@@ -29,8 +31,10 @@
RequestContext() {
net::ProxyConfig no_proxy;
proxy_service_ = net::ProxyService::CreateFixed(no_proxy);
- http_transaction_factory_ = net::HttpNetworkLayer::CreateFactory(
- proxy_service_);
+
+ http_transaction_factory_ =
+ new net::HttpCache(net::HttpNetworkLayer::CreateFactory(proxy_service_),
+ disk_cache::CreateInMemoryCacheBackend(0));
}
~RequestContext() {
delete http_transaction_factory_;
@@ -240,6 +244,30 @@
EXPECT_EQ("-downloadable.pac-\n", result.bytes);
}
+TEST_F(ProxyScriptFetcherTest, NoCache) {
+ scoped_refptr<HTTPTestServer> server =
+ HTTPTestServer::CreateServer(kDocRoot, NULL);
+ ASSERT_TRUE(NULL != server.get());
+ SynchFetcher pac_fetcher;
+
+ // Fetch a PAC script whose HTTP headers make it cacheable for 1 hour.
+ GURL url = server->TestServerPage("files/cacheable_1hr.pac");
+ FetchResult result = pac_fetcher.Fetch(url);
+ EXPECT_EQ(net::OK, result.code);
+ EXPECT_EQ("-cacheable_1hr.pac-\n", result.bytes);
+
+ // Now kill the HTTP server.
+ server->SendQuit();
+ EXPECT_TRUE(server->WaitToFinish(20000));
+ server = NULL;
+
+ // Try to fetch the file again -- if should fail, since the server is not
+ // running anymore. (If it were instead being loaded from cache, we would
+ // get a success.
+ result = pac_fetcher.Fetch(url);
+ EXPECT_EQ(net::ERR_CONNECTION_REFUSED, result.code);
+}
+
TEST_F(ProxyScriptFetcherTest, TooLarge) {
scoped_refptr<HTTPTestServer> server =
HTTPTestServer::CreateServer(kDocRoot, NULL);
« no previous file with comments | « net/proxy/proxy_script_fetcher.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698