diff options
Diffstat (limited to 'net/proxy')
-rw-r--r-- | net/proxy/proxy_script_fetcher_unittest.cc | 40 |
1 files changed, 15 insertions, 25 deletions
diff --git a/net/proxy/proxy_script_fetcher_unittest.cc b/net/proxy/proxy_script_fetcher_unittest.cc index 2139b6c..8507a86 100644 --- a/net/proxy/proxy_script_fetcher_unittest.cc +++ b/net/proxy/proxy_script_fetcher_unittest.cc @@ -181,25 +181,23 @@ TEST_F(ProxyScriptFetcherTest, FileUrl) { // Note that all mime types are allowed for PAC file, to be consistent // with other browsers. TEST_F(ProxyScriptFetcherTest, HttpMimeType) { - scoped_refptr<HTTPTestServer> server = - HTTPTestServer::CreateServer(kDocRoot); - ASSERT_TRUE(NULL != server.get()); + TestServer server(kDocRoot); SynchFetcher pac_fetcher; { // Fetch a PAC with mime type "text/plain" - GURL url = server->TestServerPage("files/pac.txt"); + GURL url = server.TestServerPage("files/pac.txt"); FetchResult result = pac_fetcher.Fetch(url); EXPECT_EQ(net::OK, result.code); EXPECT_EQ("-pac.txt-\n", result.bytes); } { // Fetch a PAC with mime type "text/html" - GURL url = server->TestServerPage("files/pac.html"); + GURL url = server.TestServerPage("files/pac.html"); FetchResult result = pac_fetcher.Fetch(url); EXPECT_EQ(net::OK, result.code); EXPECT_EQ("-pac.html-\n", result.bytes); } { // Fetch a PAC with mime type "application/x-ns-proxy-autoconfig" - GURL url = server->TestServerPage("files/pac.nsproxy"); + GURL url = server.TestServerPage("files/pac.nsproxy"); FetchResult result = pac_fetcher.Fetch(url); EXPECT_EQ(net::OK, result.code); EXPECT_EQ("-pac.nsproxy-\n", result.bytes); @@ -207,19 +205,17 @@ TEST_F(ProxyScriptFetcherTest, HttpMimeType) { } TEST_F(ProxyScriptFetcherTest, HttpStatusCode) { - scoped_refptr<HTTPTestServer> server = - HTTPTestServer::CreateServer(kDocRoot); - ASSERT_TRUE(NULL != server.get()); + TestServer server(kDocRoot); SynchFetcher pac_fetcher; { // Fetch a PAC which gives a 500 -- FAIL - GURL url = server->TestServerPage("files/500.pac"); + GURL url = server.TestServerPage("files/500.pac"); FetchResult result = pac_fetcher.Fetch(url); EXPECT_EQ(net::ERR_PAC_STATUS_NOT_OK, result.code); EXPECT_TRUE(result.bytes.empty()); } { // Fetch a PAC which gives a 404 -- FAIL - GURL url = server->TestServerPage("files/404.pac"); + GURL url = server.TestServerPage("files/404.pac"); FetchResult result = pac_fetcher.Fetch(url); EXPECT_EQ(net::ERR_PAC_STATUS_NOT_OK, result.code); EXPECT_TRUE(result.bytes.empty()); @@ -227,23 +223,19 @@ TEST_F(ProxyScriptFetcherTest, HttpStatusCode) { } TEST_F(ProxyScriptFetcherTest, ContentDisposition) { - scoped_refptr<HTTPTestServer> server = - HTTPTestServer::CreateServer(kDocRoot); - ASSERT_TRUE(NULL != server.get()); + TestServer server(kDocRoot); SynchFetcher pac_fetcher; // Fetch PAC scripts via HTTP with a Content-Disposition header -- should // have no effect. - GURL url = server->TestServerPage("files/downloadable.pac"); + GURL url = server.TestServerPage("files/downloadable.pac"); FetchResult result = pac_fetcher.Fetch(url); EXPECT_EQ(net::OK, result.code); EXPECT_EQ("-downloadable.pac-\n", result.bytes); } TEST_F(ProxyScriptFetcherTest, TooLarge) { - scoped_refptr<HTTPTestServer> server = - HTTPTestServer::CreateServer(kDocRoot); - ASSERT_TRUE(NULL != server.get()); + TestServer server(kDocRoot); SynchFetcher pac_fetcher; // Set the maximum response size to 50 bytes. @@ -251,7 +243,7 @@ TEST_F(ProxyScriptFetcherTest, TooLarge) { // These two URLs are the same file, but are http:// vs file:// GURL urls[] = { - server->TestServerPage("files/large-pac.nsproxy"), + server.TestServerPage("files/large-pac.nsproxy"), GetTestFileUrl("large-pac.nsproxy") }; @@ -268,7 +260,7 @@ TEST_F(ProxyScriptFetcherTest, TooLarge) { net::ProxyScriptFetcher::SetSizeConstraintForUnittest(prev_size); { // Make sure we can still fetch regular URLs. - GURL url = server->TestServerPage("files/pac.nsproxy"); + GURL url = server.TestServerPage("files/pac.nsproxy"); FetchResult result = pac_fetcher.Fetch(url); EXPECT_EQ(net::OK, result.code); EXPECT_EQ("-pac.nsproxy-\n", result.bytes); @@ -276,9 +268,7 @@ TEST_F(ProxyScriptFetcherTest, TooLarge) { } TEST_F(ProxyScriptFetcherTest, Hang) { - scoped_refptr<HTTPTestServer> server = - HTTPTestServer::CreateServer(kDocRoot); - ASSERT_TRUE(NULL != server.get()); + TestServer server(kDocRoot); SynchFetcher pac_fetcher; // Set the timeout period to 0.5 seconds. @@ -287,7 +277,7 @@ TEST_F(ProxyScriptFetcherTest, Hang) { // Try fetching a URL which takes 1.2 seconds. We should abort the request // after 500 ms, and fail with a timeout error. - { GURL url = server->TestServerPage("slow/proxy.pac?1.2"); + { GURL url = server.TestServerPage("slow/proxy.pac?1.2"); FetchResult result = pac_fetcher.Fetch(url); EXPECT_EQ(net::ERR_TIMED_OUT, result.code); EXPECT_TRUE(result.bytes.empty()); @@ -297,7 +287,7 @@ TEST_F(ProxyScriptFetcherTest, Hang) { net::ProxyScriptFetcher::SetTimeoutConstraintForUnittest(prev_timeout); { // Make sure we can still fetch regular URLs. - GURL url = server->TestServerPage("files/pac.nsproxy"); + GURL url = server.TestServerPage("files/pac.nsproxy"); FetchResult result = pac_fetcher.Fetch(url); EXPECT_EQ(net::OK, result.code); EXPECT_EQ("-pac.nsproxy-\n", result.bytes); |