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 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 } | 305 } |
306 ASSERT_EQ(1u, | 306 ASSERT_EQ(1u, |
307 URLRequest::InstanceTracker::Get()->GetRecentlyDeceased().size()); | 307 URLRequest::InstanceTracker::Get()->GetRecentlyDeceased().size()); |
308 // The +1 is because GURL canonicalizes with a trailing '/' ... maybe | 308 // The +1 is because GURL canonicalizes with a trailing '/' ... maybe |
309 // we should just save the std::string rather than the GURL. | 309 // we should just save the std::string rather than the GURL. |
310 EXPECT_EQ(kMaxURLLen + 1, | 310 EXPECT_EQ(kMaxURLLen + 1, |
311 URLRequest::InstanceTracker::Get()->GetRecentlyDeceased()[0] | 311 URLRequest::InstanceTracker::Get()->GetRecentlyDeceased()[0] |
312 .original_url.spec().size()); | 312 .original_url.spec().size()); |
313 } | 313 } |
314 | 314 |
315 TEST_F(URLRequestTestHTTP, SetExplicitlyAllowedPortsTest) { | |
316 std::wstring invalid[] = { L"1,2,a", L"'1','2'", L"1, 2, 3", L"1 0,11,12" }; | |
317 std::wstring valid[] = { L"", L"1", L"1,2", L"1,2,3", L"10,11,12,13" }; | |
318 | |
319 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(invalid); ++i) { | |
320 URLRequestHttpJob::SetExplicitlyAllowedPorts(invalid[i]); | |
321 EXPECT_EQ(0, static_cast<int>( | |
322 URLRequestHttpJob::explicitly_allowed_ports().size())); | |
323 } | |
324 | |
325 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(valid); ++i) { | |
326 URLRequestHttpJob::SetExplicitlyAllowedPorts(valid[i]); | |
327 EXPECT_EQ(i, URLRequestHttpJob::explicitly_allowed_ports().size()); | |
328 } | |
329 } | |
330 | |
331 TEST_F(URLRequestTest, QuitTest) { | 315 TEST_F(URLRequestTest, QuitTest) { |
332 // Don't use shared server here because we order it to quit. | 316 // Don't use shared server here because we order it to quit. |
333 // It would impact other tests. | 317 // It would impact other tests. |
334 scoped_refptr<HTTPTestServer> server = | 318 scoped_refptr<HTTPTestServer> server = |
335 HTTPTestServer::CreateServer(L"", NULL); | 319 HTTPTestServer::CreateServer(L"", NULL); |
336 ASSERT_TRUE(NULL != server.get()); | 320 ASSERT_TRUE(NULL != server.get()); |
337 server->SendQuit(); | 321 server->SendQuit(); |
338 EXPECT_TRUE(server->WaitToFinish(20000)); | 322 EXPECT_TRUE(server->WaitToFinish(20000)); |
339 } | 323 } |
340 | 324 |
(...skipping 1751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2092 | 2076 |
2093 int64 file_size = 0; | 2077 int64 file_size = 0; |
2094 file_util::GetFileSize(app_path, &file_size); | 2078 file_util::GetFileSize(app_path, &file_size); |
2095 | 2079 |
2096 EXPECT_FALSE(r.is_pending()); | 2080 EXPECT_FALSE(r.is_pending()); |
2097 EXPECT_EQ(1, d.response_started_count()); | 2081 EXPECT_EQ(1, d.response_started_count()); |
2098 EXPECT_FALSE(d.received_data_before_response()); | 2082 EXPECT_FALSE(d.received_data_before_response()); |
2099 EXPECT_EQ(d.bytes_received(), static_cast<int>(file_size)); | 2083 EXPECT_EQ(d.bytes_received(), static_cast<int>(file_size)); |
2100 } | 2084 } |
2101 } | 2085 } |
OLD | NEW |