Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/url_request/url_request_unittest.h" | 5 #include "net/url_request/url_request_unittest.h" |
| 6 | 6 |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 | 8 |
| 9 #if defined(OS_WIN) | 9 #if defined(OS_WIN) |
| 10 #include <windows.h> | 10 #include <windows.h> |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 22 #include "base/process_util.h" | 22 #include "base/process_util.h" |
| 23 #include "base/string_piece.h" | 23 #include "base/string_piece.h" |
| 24 #include "base/string_util.h" | 24 #include "base/string_util.h" |
| 25 #include "net/base/cookie_monster.h" | 25 #include "net/base/cookie_monster.h" |
| 26 #include "net/base/load_flags.h" | 26 #include "net/base/load_flags.h" |
| 27 #include "net/base/net_errors.h" | 27 #include "net/base/net_errors.h" |
| 28 #include "net/base/net_module.h" | 28 #include "net/base/net_module.h" |
| 29 #include "net/base/net_util.h" | 29 #include "net/base/net_util.h" |
| 30 #include "net/base/upload_data.h" | 30 #include "net/base/upload_data.h" |
| 31 #include "net/disk_cache/disk_cache.h" | 31 #include "net/disk_cache/disk_cache.h" |
| 32 #include "net/ftp/ftp_network_layer.h" | |
| 32 #include "net/http/http_cache.h" | 33 #include "net/http/http_cache.h" |
| 33 #include "net/http/http_network_layer.h" | 34 #include "net/http/http_network_layer.h" |
| 34 #include "net/http/http_response_headers.h" | 35 #include "net/http/http_response_headers.h" |
| 35 #include "net/proxy/proxy_service.h" | 36 #include "net/proxy/proxy_service.h" |
| 36 #include "net/socket/ssl_test_util.h" | 37 #include "net/socket/ssl_test_util.h" |
| 37 #include "net/url_request/url_request.h" | 38 #include "net/url_request/url_request.h" |
| 38 #include "net/url_request/url_request_test_job.h" | 39 #include "net/url_request/url_request_test_job.h" |
| 39 #include "testing/gtest/include/gtest/gtest.h" | 40 #include "testing/gtest/include/gtest/gtest.h" |
| 40 #include "testing/platform_test.h" | 41 #include "testing/platform_test.h" |
| 41 | 42 |
| 42 using base::Time; | 43 using base::Time; |
| 43 | 44 |
| 44 namespace { | 45 namespace { |
| 45 | 46 |
| 46 class URLRequestHttpCacheContext : public URLRequestContext { | 47 class URLRequestTestContext : public URLRequestContext { |
|
wtc
2009/07/30 22:16:32
I found that there is a TestURLRequestContext clas
| |
| 47 public: | 48 public: |
| 48 URLRequestHttpCacheContext() { | 49 URLRequestTestContext() { |
| 49 host_resolver_ = net::CreateSystemHostResolver(); | 50 host_resolver_ = net::CreateSystemHostResolver(); |
| 50 proxy_service_ = net::ProxyService::CreateNull(); | 51 proxy_service_ = net::ProxyService::CreateNull(); |
| 52 ftp_transaction_factory_ = new net::FtpNetworkLayer(host_resolver_); | |
| 51 http_transaction_factory_ = | 53 http_transaction_factory_ = |
| 52 new net::HttpCache( | 54 new net::HttpCache( |
| 53 net::HttpNetworkLayer::CreateFactory(host_resolver_, proxy_service_), | 55 net::HttpNetworkLayer::CreateFactory(host_resolver_, proxy_service_), |
| 54 disk_cache::CreateInMemoryCacheBackend(0)); | 56 disk_cache::CreateInMemoryCacheBackend(0)); |
| 55 // In-memory cookie store. | 57 // In-memory cookie store. |
| 56 cookie_store_ = new net::CookieMonster(); | 58 cookie_store_ = new net::CookieMonster(); |
| 57 } | 59 } |
| 58 | 60 |
| 59 virtual ~URLRequestHttpCacheContext() { | 61 virtual ~URLRequestTestContext() { |
| 60 delete cookie_store_; | 62 delete cookie_store_; |
| 63 delete ftp_transaction_factory_; | |
| 61 delete http_transaction_factory_; | 64 delete http_transaction_factory_; |
| 62 delete proxy_service_; | 65 delete proxy_service_; |
| 63 } | 66 } |
| 64 }; | 67 }; |
| 65 | 68 |
| 66 class TestURLRequest : public URLRequest { | 69 class TestURLRequest : public URLRequest { |
| 67 public: | 70 public: |
| 68 TestURLRequest(const GURL& url, Delegate* delegate) | 71 TestURLRequest(const GURL& url, Delegate* delegate) |
| 69 : URLRequest(url, delegate) { | 72 : URLRequest(url, delegate) { |
| 70 set_context(new URLRequestHttpCacheContext()); | 73 set_context(new URLRequestTestContext()); |
| 71 } | 74 } |
| 72 }; | 75 }; |
| 73 | 76 |
| 74 StringPiece TestNetResourceProvider(int key) { | 77 StringPiece TestNetResourceProvider(int key) { |
| 75 return "header"; | 78 return "header"; |
| 76 } | 79 } |
| 77 | 80 |
| 78 // Do a case-insensitive search through |haystack| for |needle|. | 81 // Do a case-insensitive search through |haystack| for |needle|. |
| 79 bool ContainsString(const std::string& haystack, const char* needle) { | 82 bool ContainsString(const std::string& haystack, const char* needle) { |
| 80 std::string::const_iterator it = | 83 std::string::const_iterator it = |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 447 // we won't actually get a received reponse here because we've never run the | 450 // we won't actually get a received reponse here because we've never run the |
| 448 // message loop | 451 // message loop |
| 449 EXPECT_FALSE(d.received_data_before_response()); | 452 EXPECT_FALSE(d.received_data_before_response()); |
| 450 EXPECT_EQ(0, d.bytes_received()); | 453 EXPECT_EQ(0, d.bytes_received()); |
| 451 } | 454 } |
| 452 | 455 |
| 453 TEST_F(URLRequestTest, CancelTest5) { | 456 TEST_F(URLRequestTest, CancelTest5) { |
| 454 scoped_refptr<HTTPTestServer> server = | 457 scoped_refptr<HTTPTestServer> server = |
| 455 HTTPTestServer::CreateServer(L"", NULL); | 458 HTTPTestServer::CreateServer(L"", NULL); |
| 456 ASSERT_TRUE(NULL != server.get()); | 459 ASSERT_TRUE(NULL != server.get()); |
| 457 scoped_refptr<URLRequestContext> context = new URLRequestHttpCacheContext(); | 460 scoped_refptr<URLRequestContext> context = new URLRequestTestContext(); |
| 458 | 461 |
| 459 // populate cache | 462 // populate cache |
| 460 { | 463 { |
| 461 TestDelegate d; | 464 TestDelegate d; |
| 462 URLRequest r(server->TestServerPage("cachetime"), &d); | 465 URLRequest r(server->TestServerPage("cachetime"), &d); |
| 463 r.set_context(context); | 466 r.set_context(context); |
| 464 r.Start(); | 467 r.Start(); |
| 465 MessageLoop::current()->Run(); | 468 MessageLoop::current()->Run(); |
| 466 EXPECT_EQ(URLRequestStatus::SUCCESS, r.status().status()); | 469 EXPECT_EQ(URLRequestStatus::SUCCESS, r.status().status()); |
| 467 } | 470 } |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 500 ptr += 10; | 503 ptr += 10; |
| 501 if (idx % 100 == 0) { | 504 if (idx % 100 == 0) { |
| 502 ptr--; | 505 ptr--; |
| 503 *ptr++ = marker; | 506 *ptr++ = marker; |
| 504 if (++marker > 'z') | 507 if (++marker > 'z') |
| 505 marker = 'a'; | 508 marker = 'a'; |
| 506 } | 509 } |
| 507 } | 510 } |
| 508 uploadBytes[kMsgSize] = '\0'; | 511 uploadBytes[kMsgSize] = '\0'; |
| 509 | 512 |
| 510 scoped_refptr<URLRequestContext> context = | 513 scoped_refptr<URLRequestContext> context = new URLRequestTestContext(); |
| 511 new URLRequestHttpCacheContext(); | |
| 512 | 514 |
| 513 for (int i = 0; i < kIterations; ++i) { | 515 for (int i = 0; i < kIterations; ++i) { |
| 514 TestDelegate d; | 516 TestDelegate d; |
| 515 URLRequest r(server->TestServerPage("echo"), &d); | 517 URLRequest r(server->TestServerPage("echo"), &d); |
| 516 r.set_context(context); | 518 r.set_context(context); |
| 517 r.set_method("POST"); | 519 r.set_method("POST"); |
| 518 | 520 |
| 519 r.AppendBytesToUpload(uploadBytes, kMsgSize); | 521 r.AppendBytesToUpload(uploadBytes, kMsgSize); |
| 520 | 522 |
| 521 r.Start(); | 523 r.Start(); |
| (...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1134 EXPECT_FALSE(d.received_data_before_response()); | 1136 EXPECT_FALSE(d.received_data_before_response()); |
| 1135 EXPECT_EQ(URLRequestStatus::CANCELED, req.status().status()); | 1137 EXPECT_EQ(URLRequestStatus::CANCELED, req.status().status()); |
| 1136 } | 1138 } |
| 1137 } | 1139 } |
| 1138 | 1140 |
| 1139 TEST_F(URLRequestTest, VaryHeader) { | 1141 TEST_F(URLRequestTest, VaryHeader) { |
| 1140 scoped_refptr<HTTPTestServer> server = | 1142 scoped_refptr<HTTPTestServer> server = |
| 1141 HTTPTestServer::CreateServer(L"net/data/url_request_unittest", NULL); | 1143 HTTPTestServer::CreateServer(L"net/data/url_request_unittest", NULL); |
| 1142 ASSERT_TRUE(NULL != server.get()); | 1144 ASSERT_TRUE(NULL != server.get()); |
| 1143 | 1145 |
| 1144 scoped_refptr<URLRequestContext> context = new URLRequestHttpCacheContext(); | 1146 scoped_refptr<URLRequestContext> context = new URLRequestTestContext(); |
| 1145 | 1147 |
| 1146 Time response_time; | 1148 Time response_time; |
| 1147 | 1149 |
| 1148 // populate the cache | 1150 // populate the cache |
| 1149 { | 1151 { |
| 1150 TestDelegate d; | 1152 TestDelegate d; |
| 1151 URLRequest req(server->TestServerPage("echoheader?foo"), &d); | 1153 URLRequest req(server->TestServerPage("echoheader?foo"), &d); |
| 1152 req.set_context(context); | 1154 req.set_context(context); |
| 1153 req.SetExtraRequestHeaders("foo:1"); | 1155 req.SetExtraRequestHeaders("foo:1"); |
| 1154 req.Start(); | 1156 req.Start(); |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 1180 req.set_context(context); | 1182 req.set_context(context); |
| 1181 req.SetExtraRequestHeaders("foo:2"); | 1183 req.SetExtraRequestHeaders("foo:2"); |
| 1182 req.Start(); | 1184 req.Start(); |
| 1183 MessageLoop::current()->Run(); | 1185 MessageLoop::current()->Run(); |
| 1184 | 1186 |
| 1185 EXPECT_FALSE(req.response_time() == response_time); | 1187 EXPECT_FALSE(req.response_time() == response_time); |
| 1186 } | 1188 } |
| 1187 } | 1189 } |
| 1188 | 1190 |
| 1189 TEST_F(URLRequestTest, BasicAuth) { | 1191 TEST_F(URLRequestTest, BasicAuth) { |
| 1190 scoped_refptr<URLRequestContext> context = new URLRequestHttpCacheContext(); | 1192 scoped_refptr<URLRequestContext> context = new URLRequestTestContext(); |
| 1191 scoped_refptr<HTTPTestServer> server = | 1193 scoped_refptr<HTTPTestServer> server = |
| 1192 HTTPTestServer::CreateServer(L"", NULL); | 1194 HTTPTestServer::CreateServer(L"", NULL); |
| 1193 ASSERT_TRUE(NULL != server.get()); | 1195 ASSERT_TRUE(NULL != server.get()); |
| 1194 | 1196 |
| 1195 Time response_time; | 1197 Time response_time; |
| 1196 | 1198 |
| 1197 // populate the cache | 1199 // populate the cache |
| 1198 { | 1200 { |
| 1199 TestDelegate d; | 1201 TestDelegate d; |
| 1200 d.set_username(L"user"); | 1202 d.set_username(L"user"); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1244 scoped_refptr<HTTPTestServer> server = | 1246 scoped_refptr<HTTPTestServer> server = |
| 1245 HTTPTestServer::CreateServer(L"", NULL); | 1247 HTTPTestServer::CreateServer(L"", NULL); |
| 1246 ASSERT_TRUE(NULL != server.get()); | 1248 ASSERT_TRUE(NULL != server.get()); |
| 1247 | 1249 |
| 1248 GURL url_requiring_auth = | 1250 GURL url_requiring_auth = |
| 1249 server->TestServerPage("auth-basic?set-cookie-if-challenged"); | 1251 server->TestServerPage("auth-basic?set-cookie-if-challenged"); |
| 1250 | 1252 |
| 1251 // Request a page that will give a 401 containing a Set-Cookie header. | 1253 // Request a page that will give a 401 containing a Set-Cookie header. |
| 1252 // Verify that when the transaction is restarted, it includes the new cookie. | 1254 // Verify that when the transaction is restarted, it includes the new cookie. |
| 1253 { | 1255 { |
| 1254 scoped_refptr<URLRequestContext> context = new URLRequestHttpCacheContext(); | 1256 scoped_refptr<URLRequestContext> context = new URLRequestTestContext(); |
| 1255 TestDelegate d; | 1257 TestDelegate d; |
| 1256 d.set_username(L"user"); | 1258 d.set_username(L"user"); |
| 1257 d.set_password(L"secret"); | 1259 d.set_password(L"secret"); |
| 1258 | 1260 |
| 1259 URLRequest r(url_requiring_auth, &d); | 1261 URLRequest r(url_requiring_auth, &d); |
| 1260 r.set_context(context); | 1262 r.set_context(context); |
| 1261 r.Start(); | 1263 r.Start(); |
| 1262 | 1264 |
| 1263 MessageLoop::current()->Run(); | 1265 MessageLoop::current()->Run(); |
| 1264 | 1266 |
| 1265 EXPECT_TRUE(d.data_received().find("user/secret") != std::string::npos); | 1267 EXPECT_TRUE(d.data_received().find("user/secret") != std::string::npos); |
| 1266 | 1268 |
| 1267 // Make sure we sent the cookie in the restarted transaction. | 1269 // Make sure we sent the cookie in the restarted transaction. |
| 1268 EXPECT_TRUE(d.data_received().find("Cookie: got_challenged=true") | 1270 EXPECT_TRUE(d.data_received().find("Cookie: got_challenged=true") |
| 1269 != std::string::npos); | 1271 != std::string::npos); |
| 1270 } | 1272 } |
| 1271 | 1273 |
| 1272 // Same test as above, except this time the restart is initiated earlier | 1274 // Same test as above, except this time the restart is initiated earlier |
| 1273 // (without user intervention since identity is embedded in the URL). | 1275 // (without user intervention since identity is embedded in the URL). |
| 1274 { | 1276 { |
| 1275 scoped_refptr<URLRequestContext> context = new URLRequestHttpCacheContext(); | 1277 scoped_refptr<URLRequestContext> context = new URLRequestTestContext(); |
| 1276 TestDelegate d; | 1278 TestDelegate d; |
| 1277 | 1279 |
| 1278 GURL::Replacements replacements; | 1280 GURL::Replacements replacements; |
| 1279 std::string username("user2"); | 1281 std::string username("user2"); |
| 1280 std::string password("secret"); | 1282 std::string password("secret"); |
| 1281 replacements.SetUsernameStr(username); | 1283 replacements.SetUsernameStr(username); |
| 1282 replacements.SetPasswordStr(password); | 1284 replacements.SetPasswordStr(password); |
| 1283 GURL url_with_identity = url_requiring_auth.ReplaceComponents(replacements); | 1285 GURL url_with_identity = url_requiring_auth.ReplaceComponents(replacements); |
| 1284 | 1286 |
| 1285 URLRequest r(url_with_identity, &d); | 1287 URLRequest r(url_with_identity, &d); |
| (...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1800 | 1802 |
| 1801 // Check the interceptor got called as expected | 1803 // Check the interceptor got called as expected |
| 1802 EXPECT_TRUE(interceptor.did_cancel_then_restart_main_); | 1804 EXPECT_TRUE(interceptor.did_cancel_then_restart_main_); |
| 1803 EXPECT_FALSE(interceptor.did_intercept_final_); | 1805 EXPECT_FALSE(interceptor.did_intercept_final_); |
| 1804 | 1806 |
| 1805 // Check we see a canceled request | 1807 // Check we see a canceled request |
| 1806 EXPECT_FALSE(req.status().is_success()); | 1808 EXPECT_FALSE(req.status().is_success()); |
| 1807 EXPECT_EQ(URLRequestStatus::CANCELED, req.status().status()); | 1809 EXPECT_EQ(URLRequestStatus::CANCELED, req.status().status()); |
| 1808 } | 1810 } |
| 1809 | 1811 |
| 1810 // FTP tests appear to be hanging some of the time | 1812 TEST_F(URLRequestTest, FTPGetTestAnonymous) { |
| 1811 #if 1 // !defined(OS_WIN) | |
| 1812 #define MAYBE_FTPGetTestAnonymous DISABLED_FTPGetTestAnonymous | |
| 1813 #define MAYBE_FTPGetTest DISABLED_FTPGetTest | |
| 1814 #define MAYBE_FTPCheckWrongUser DISABLED_FTPCheckWrongUser | |
| 1815 #define MAYBE_FTPCheckWrongPassword DISABLED_FTPCheckWrongPassword | |
| 1816 #else | |
| 1817 #define MAYBE_FTPGetTestAnonymous FTPGetTestAnonymous | |
| 1818 #define MAYBE_FTPGetTest FTPGetTest | |
| 1819 #define MAYBE_FTPCheckWrongUser FTPCheckWrongUser | |
| 1820 #define MAYBE_FTPCheckWrongPassword FTPCheckWrongPassword | |
| 1821 #endif | |
| 1822 | |
| 1823 TEST_F(URLRequestTest, MAYBE_FTPGetTestAnonymous) { | |
| 1824 scoped_refptr<FTPTestServer> server = FTPTestServer::CreateServer(L""); | 1813 scoped_refptr<FTPTestServer> server = FTPTestServer::CreateServer(L""); |
| 1825 ASSERT_TRUE(NULL != server.get()); | 1814 ASSERT_TRUE(NULL != server.get()); |
| 1826 FilePath app_path; | 1815 FilePath app_path; |
| 1827 PathService::Get(base::DIR_SOURCE_ROOT, &app_path); | 1816 PathService::Get(base::DIR_SOURCE_ROOT, &app_path); |
| 1828 app_path = app_path.AppendASCII("LICENSE"); | 1817 app_path = app_path.AppendASCII("LICENSE"); |
| 1829 TestDelegate d; | 1818 TestDelegate d; |
| 1830 { | 1819 { |
| 1831 TestURLRequest r(server->TestServerPage("/LICENSE"), &d); | 1820 TestURLRequest r(server->TestServerPage("/LICENSE"), &d); |
| 1832 r.Start(); | 1821 r.Start(); |
| 1833 EXPECT_TRUE(r.is_pending()); | 1822 EXPECT_TRUE(r.is_pending()); |
| 1834 | 1823 |
| 1835 MessageLoop::current()->Run(); | 1824 MessageLoop::current()->Run(); |
| 1836 | 1825 |
| 1837 int64 file_size = 0; | 1826 int64 file_size = 0; |
| 1838 file_util::GetFileSize(app_path, &file_size); | 1827 file_util::GetFileSize(app_path, &file_size); |
| 1839 | 1828 |
| 1840 EXPECT_TRUE(!r.is_pending()); | 1829 EXPECT_FALSE(r.is_pending()); |
| 1841 EXPECT_EQ(1, d.response_started_count()); | 1830 EXPECT_EQ(1, d.response_started_count()); |
| 1842 EXPECT_FALSE(d.received_data_before_response()); | 1831 EXPECT_FALSE(d.received_data_before_response()); |
| 1843 EXPECT_EQ(d.bytes_received(), static_cast<int>(file_size)); | 1832 EXPECT_EQ(d.bytes_received(), static_cast<int>(file_size)); |
| 1844 } | 1833 } |
| 1845 } | 1834 } |
| 1846 | 1835 |
| 1847 TEST_F(URLRequestTest, MAYBE_FTPGetTest) { | 1836 TEST_F(URLRequestTest, FTPGetTest) { |
| 1848 scoped_refptr<FTPTestServer> server = | 1837 scoped_refptr<FTPTestServer> server = |
| 1849 FTPTestServer::CreateServer(L"", "chrome", "chrome"); | 1838 FTPTestServer::CreateServer(L"", "chrome", "chrome"); |
| 1850 ASSERT_TRUE(NULL != server.get()); | 1839 ASSERT_TRUE(NULL != server.get()); |
| 1851 FilePath app_path; | 1840 FilePath app_path; |
| 1852 PathService::Get(base::DIR_SOURCE_ROOT, &app_path); | 1841 PathService::Get(base::DIR_SOURCE_ROOT, &app_path); |
| 1853 app_path = app_path.AppendASCII("LICENSE"); | 1842 app_path = app_path.AppendASCII("LICENSE"); |
| 1854 TestDelegate d; | 1843 TestDelegate d; |
| 1855 { | 1844 { |
| 1856 TestURLRequest r(server->TestServerPage("/LICENSE"), &d); | 1845 TestURLRequest r(server->TestServerPage("/LICENSE"), &d); |
| 1857 r.Start(); | 1846 r.Start(); |
| 1858 EXPECT_TRUE(r.is_pending()); | 1847 EXPECT_TRUE(r.is_pending()); |
| 1859 | 1848 |
| 1860 MessageLoop::current()->Run(); | 1849 MessageLoop::current()->Run(); |
| 1861 | 1850 |
| 1862 int64 file_size = 0; | 1851 int64 file_size = 0; |
| 1863 file_util::GetFileSize(app_path, &file_size); | 1852 file_util::GetFileSize(app_path, &file_size); |
| 1864 | 1853 |
| 1865 EXPECT_TRUE(!r.is_pending()); | 1854 EXPECT_FALSE(r.is_pending()); |
| 1866 EXPECT_EQ(1, d.response_started_count()); | 1855 EXPECT_EQ(1, d.response_started_count()); |
| 1867 EXPECT_FALSE(d.received_data_before_response()); | 1856 EXPECT_FALSE(d.received_data_before_response()); |
| 1868 EXPECT_EQ(d.bytes_received(), static_cast<int>(file_size)); | 1857 EXPECT_EQ(d.bytes_received(), static_cast<int>(file_size)); |
| 1869 } | 1858 } |
| 1870 } | 1859 } |
| 1871 | 1860 |
| 1872 TEST_F(URLRequestTest, MAYBE_FTPCheckWrongPassword) { | 1861 // Needs more work, tracked in http://crbug.com/18036. |
| 1862 TEST_F(URLRequestTest, DISABLED_FTPCheckWrongPassword) { | |
| 1873 scoped_refptr<FTPTestServer> server = | 1863 scoped_refptr<FTPTestServer> server = |
| 1874 FTPTestServer::CreateServer(L"", "chrome", "wrong_password"); | 1864 FTPTestServer::CreateServer(L"", "chrome", "wrong_password"); |
| 1875 ASSERT_TRUE(NULL != server.get()); | 1865 ASSERT_TRUE(NULL != server.get()); |
| 1876 FilePath app_path; | 1866 FilePath app_path; |
| 1877 PathService::Get(base::DIR_SOURCE_ROOT, &app_path); | 1867 PathService::Get(base::DIR_SOURCE_ROOT, &app_path); |
| 1878 app_path = app_path.AppendASCII("LICENSE"); | 1868 app_path = app_path.AppendASCII("LICENSE"); |
| 1879 TestDelegate d; | 1869 TestDelegate d; |
| 1880 { | 1870 { |
| 1881 TestURLRequest r(server->TestServerPage("/LICENSE"), &d); | 1871 TestURLRequest r(server->TestServerPage("/LICENSE"), &d); |
| 1882 r.Start(); | 1872 r.Start(); |
| 1883 EXPECT_TRUE(r.is_pending()); | 1873 EXPECT_TRUE(r.is_pending()); |
| 1884 | 1874 |
| 1885 MessageLoop::current()->Run(); | 1875 MessageLoop::current()->Run(); |
| 1886 | 1876 |
| 1887 int64 file_size = 0; | 1877 int64 file_size = 0; |
| 1888 file_util::GetFileSize(app_path, &file_size); | 1878 file_util::GetFileSize(app_path, &file_size); |
| 1889 | 1879 |
| 1890 EXPECT_TRUE(!r.is_pending()); | 1880 EXPECT_FALSE(r.is_pending()); |
| 1891 EXPECT_EQ(1, d.response_started_count()); | 1881 EXPECT_EQ(1, d.response_started_count()); |
| 1892 EXPECT_FALSE(d.received_data_before_response()); | 1882 EXPECT_FALSE(d.received_data_before_response()); |
| 1893 EXPECT_EQ(d.bytes_received(), 0); | 1883 EXPECT_EQ(d.bytes_received(), 0); |
| 1894 } | 1884 } |
| 1895 } | 1885 } |
| 1896 | 1886 |
| 1897 TEST_F(URLRequestTest, MAYBE_FTPCheckWrongUser) { | 1887 // Needs more work, tracked in http://crbug.com/18036. |
| 1888 TEST_F(URLRequestTest, DISABLED_FTPCheckWrongUser) { | |
| 1898 scoped_refptr<FTPTestServer> server = | 1889 scoped_refptr<FTPTestServer> server = |
| 1899 FTPTestServer::CreateServer(L"", "wrong_user", "chrome"); | 1890 FTPTestServer::CreateServer(L"", "wrong_user", "chrome"); |
| 1900 ASSERT_TRUE(NULL != server.get()); | 1891 ASSERT_TRUE(NULL != server.get()); |
| 1901 FilePath app_path; | 1892 FilePath app_path; |
| 1902 PathService::Get(base::DIR_SOURCE_ROOT, &app_path); | 1893 PathService::Get(base::DIR_SOURCE_ROOT, &app_path); |
| 1903 app_path = app_path.AppendASCII("LICENSE"); | 1894 app_path = app_path.AppendASCII("LICENSE"); |
| 1904 TestDelegate d; | 1895 TestDelegate d; |
| 1905 { | 1896 { |
| 1906 TestURLRequest r(server->TestServerPage("/LICENSE"), &d); | 1897 TestURLRequest r(server->TestServerPage("/LICENSE"), &d); |
| 1907 r.Start(); | 1898 r.Start(); |
| 1908 EXPECT_TRUE(r.is_pending()); | 1899 EXPECT_TRUE(r.is_pending()); |
| 1909 | 1900 |
| 1910 MessageLoop::current()->Run(); | 1901 MessageLoop::current()->Run(); |
| 1911 | 1902 |
| 1912 int64 file_size = 0; | 1903 int64 file_size = 0; |
| 1913 file_util::GetFileSize(app_path, &file_size); | 1904 file_util::GetFileSize(app_path, &file_size); |
| 1914 | 1905 |
| 1915 EXPECT_TRUE(!r.is_pending()); | 1906 EXPECT_FALSE(r.is_pending()); |
| 1916 EXPECT_EQ(1, d.response_started_count()); | 1907 EXPECT_EQ(1, d.response_started_count()); |
| 1917 EXPECT_FALSE(d.received_data_before_response()); | 1908 EXPECT_FALSE(d.received_data_before_response()); |
| 1918 EXPECT_EQ(d.bytes_received(), 0); | 1909 EXPECT_EQ(d.bytes_received(), 0); |
| 1919 } | 1910 } |
| 1920 } | 1911 } |
| OLD | NEW |