| 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 19 matching lines...) Expand all Loading... |
| 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/ftp/ftp_network_layer.h" |
| 33 #include "net/http/http_cache.h" | 33 #include "net/http/http_cache.h" |
| 34 #include "net/http/http_network_layer.h" | 34 #include "net/http/http_network_layer.h" |
| 35 #include "net/http/http_response_headers.h" | 35 #include "net/http/http_response_headers.h" |
| 36 #include "net/proxy/proxy_service.h" | 36 #include "net/proxy/proxy_service.h" |
| 37 #include "net/socket/ssl_test_util.h" | 37 #include "net/socket/ssl_test_util.h" |
| 38 #include "net/url_request/url_request.h" | 38 #include "net/url_request/url_request.h" |
| 39 #include "net/url_request/url_request_file_dir_job.h" | 39 #include "net/url_request/url_request_file_dir_job.h" |
| 40 #include "net/url_request/url_request_http_job.h" |
| 40 #include "net/url_request/url_request_test_job.h" | 41 #include "net/url_request/url_request_test_job.h" |
| 41 #include "testing/gtest/include/gtest/gtest.h" | 42 #include "testing/gtest/include/gtest/gtest.h" |
| 42 #include "testing/platform_test.h" | 43 #include "testing/platform_test.h" |
| 43 | 44 |
| 44 using base::Time; | 45 using base::Time; |
| 45 | 46 |
| 46 namespace { | 47 namespace { |
| 47 | 48 |
| 48 class URLRequestTestContext : public URLRequestContext { | 49 class URLRequestTestContext : public URLRequestContext { |
| 49 public: | 50 public: |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 | 217 |
| 217 EXPECT_EQ(1, d.response_started_count()); | 218 EXPECT_EQ(1, d.response_started_count()); |
| 218 EXPECT_FALSE(d.received_data_before_response()); | 219 EXPECT_FALSE(d.received_data_before_response()); |
| 219 EXPECT_NE(0, d.bytes_received()); | 220 EXPECT_NE(0, d.bytes_received()); |
| 220 } | 221 } |
| 221 #ifndef NDEBUG | 222 #ifndef NDEBUG |
| 222 DCHECK_EQ(url_request_metrics.object_count, 0); | 223 DCHECK_EQ(url_request_metrics.object_count, 0); |
| 223 #endif | 224 #endif |
| 224 } | 225 } |
| 225 | 226 |
| 227 TEST_F(URLRequestTestHTTP, SetExplicitlyAllowedPortsTest) { |
| 228 std::wstring invalid[] = { L"1,2,a", L"'1','2'", L"1, 2, 3", L"1 0,11,12" }; |
| 229 std::wstring valid[] = { L"", L"1", L"1,2", L"1,2,3", L"10,11,12,13" }; |
| 230 |
| 231 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(invalid); ++i) { |
| 232 URLRequestHttpJob::SetExplicitlyAllowedPorts(invalid[i]); |
| 233 EXPECT_EQ(0, URLRequestHttpJob::explicitly_allowed_ports().size()); |
| 234 } |
| 235 |
| 236 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(valid); ++i) { |
| 237 URLRequestHttpJob::SetExplicitlyAllowedPorts(valid[i]); |
| 238 EXPECT_EQ(i, URLRequestHttpJob::explicitly_allowed_ports().size()); |
| 239 } |
| 240 } |
| 241 |
| 226 TEST_F(URLRequestTest, QuitTest) { | 242 TEST_F(URLRequestTest, QuitTest) { |
| 227 // Don't use shared server here because we order it to quit. | 243 // Don't use shared server here because we order it to quit. |
| 228 // It would impact other tests. | 244 // It would impact other tests. |
| 229 scoped_refptr<HTTPTestServer> server = | 245 scoped_refptr<HTTPTestServer> server = |
| 230 HTTPTestServer::CreateServer(L"", NULL); | 246 HTTPTestServer::CreateServer(L"", NULL); |
| 231 ASSERT_TRUE(NULL != server.get()); | 247 ASSERT_TRUE(NULL != server.get()); |
| 232 server->SendQuit(); | 248 server->SendQuit(); |
| 233 EXPECT_TRUE(server->WaitToFinish(20000)); | 249 EXPECT_TRUE(server->WaitToFinish(20000)); |
| 234 | 250 |
| 235 #ifndef NDEBUG | 251 #ifndef NDEBUG |
| (...skipping 1753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1989 | 2005 |
| 1990 int64 file_size = 0; | 2006 int64 file_size = 0; |
| 1991 file_util::GetFileSize(app_path, &file_size); | 2007 file_util::GetFileSize(app_path, &file_size); |
| 1992 | 2008 |
| 1993 EXPECT_FALSE(r.is_pending()); | 2009 EXPECT_FALSE(r.is_pending()); |
| 1994 EXPECT_EQ(1, d.response_started_count()); | 2010 EXPECT_EQ(1, d.response_started_count()); |
| 1995 EXPECT_FALSE(d.received_data_before_response()); | 2011 EXPECT_FALSE(d.received_data_before_response()); |
| 1996 EXPECT_EQ(d.bytes_received(), 0); | 2012 EXPECT_EQ(d.bytes_received(), 0); |
| 1997 } | 2013 } |
| 1998 } | 2014 } |
| OLD | NEW |