| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 EXPECT_EQ(1, d.response_started_count()); | 173 EXPECT_EQ(1, d.response_started_count()); |
| 174 EXPECT_FALSE(d.received_data_before_response()); | 174 EXPECT_FALSE(d.received_data_before_response()); |
| 175 EXPECT_NE(0, d.bytes_received()); | 175 EXPECT_NE(0, d.bytes_received()); |
| 176 } | 176 } |
| 177 #ifndef NDEBUG | 177 #ifndef NDEBUG |
| 178 DCHECK_EQ(url_request_metrics.object_count, 0); | 178 DCHECK_EQ(url_request_metrics.object_count, 0); |
| 179 #endif | 179 #endif |
| 180 } | 180 } |
| 181 | 181 |
| 182 class HTTPSRequestTest : public testing::Test { | 182 class HTTPSRequestTest : public testing::Test { |
| 183 protected: | |
| 184 HTTPSRequestTest() : util_() {} | |
| 185 | |
| 186 SSLTestUtil util_; | |
| 187 }; | 183 }; |
| 188 | 184 |
| 189 #if defined(OS_MACOSX) | 185 #if defined(OS_MACOSX) |
| 190 // TODO(port): support temporary root cert on mac | 186 // ssl_client_socket_mac.cc crashes currently in GetSSLInfo |
| 191 #define MAYBE_HTTPSGetTest DISABLED_HTTPSGetTest | 187 // when called on a connection with an unrecognized certificate |
| 188 #define MAYBE_HTTPSGetTest DISABLED_HTTPSGetTest |
| 192 #else | 189 #else |
| 193 #define MAYBE_HTTPSGetTest HTTPSGetTest | 190 #define MAYBE_HTTPSGetTest HTTPSGetTest |
| 194 #endif | 191 #endif |
| 195 | 192 |
| 196 TEST_F(HTTPSRequestTest, MAYBE_HTTPSGetTest) { | 193 TEST_F(HTTPSRequestTest, MAYBE_HTTPSGetTest) { |
| 197 // Note: tools/testserver/testserver.py does not need | 194 // Note: tools/testserver/testserver.py does not need |
| 198 // a working document root to server the pages / and /hello.html, | 195 // a working document root to server the pages / and /hello.html, |
| 199 // so this test doesn't really need to specify a document root. | 196 // so this test doesn't really need to specify a document root. |
| 200 // But if it did, a good one would be net/data/ssl. | 197 // But if it did, a good one would be net/data/ssl. |
| 201 scoped_refptr<HTTPSTestServer> server = | 198 scoped_refptr<HTTPSTestServer> server = |
| 202 HTTPSTestServer::CreateServer(util_.kHostName, util_.kOKHTTPSPort, | 199 HTTPSTestServer::CreateGoodServer(L"net/data/ssl"); |
| 203 L"net/data/ssl", util_.GetOKCertPath().ToWStringHack()); | |
| 204 ASSERT_TRUE(NULL != server.get()); | 200 ASSERT_TRUE(NULL != server.get()); |
| 205 | 201 |
| 206 EXPECT_TRUE(util_.CheckCATrusted()); | |
| 207 TestDelegate d; | 202 TestDelegate d; |
| 208 { | 203 { |
| 209 TestURLRequest r(server->TestServerPage(""), &d); | 204 TestURLRequest r(server->TestServerPage(""), &d); |
| 210 | 205 |
| 211 r.Start(); | 206 r.Start(); |
| 212 EXPECT_TRUE(r.is_pending()); | 207 EXPECT_TRUE(r.is_pending()); |
| 213 | 208 |
| 214 MessageLoop::current()->Run(); | 209 MessageLoop::current()->Run(); |
| 215 | 210 |
| 216 EXPECT_EQ(1, d.response_started_count()); | 211 EXPECT_EQ(1, d.response_started_count()); |
| 217 EXPECT_FALSE(d.received_data_before_response()); | 212 EXPECT_FALSE(d.received_data_before_response()); |
| 218 EXPECT_NE(0, d.bytes_received()); | 213 EXPECT_NE(0, d.bytes_received()); |
| 219 } | 214 } |
| 220 #ifndef NDEBUG | 215 #ifndef NDEBUG |
| 221 DCHECK_EQ(url_request_metrics.object_count, 0); | 216 DCHECK_EQ(url_request_metrics.object_count, 0); |
| 222 #endif | 217 #endif |
| 223 } | 218 } |
| 224 | 219 |
| 220 // TODO(dkegel): add test for expired and mismatched certificates here |
| 221 |
| 225 TEST_F(URLRequestTest, CancelTest) { | 222 TEST_F(URLRequestTest, CancelTest) { |
| 226 TestDelegate d; | 223 TestDelegate d; |
| 227 { | 224 { |
| 228 TestURLRequest r(GURL("http://www.google.com/"), &d); | 225 TestURLRequest r(GURL("http://www.google.com/"), &d); |
| 229 | 226 |
| 230 r.Start(); | 227 r.Start(); |
| 231 EXPECT_TRUE(r.is_pending()); | 228 EXPECT_TRUE(r.is_pending()); |
| 232 | 229 |
| 233 r.Cancel(); | 230 r.Cancel(); |
| 234 | 231 |
| (...skipping 849 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1084 int64 file_size = 0; | 1081 int64 file_size = 0; |
| 1085 file_util::GetFileSize(app_path, &file_size); | 1082 file_util::GetFileSize(app_path, &file_size); |
| 1086 | 1083 |
| 1087 EXPECT_TRUE(!r.is_pending()); | 1084 EXPECT_TRUE(!r.is_pending()); |
| 1088 EXPECT_EQ(1, d.response_started_count()); | 1085 EXPECT_EQ(1, d.response_started_count()); |
| 1089 EXPECT_FALSE(d.received_data_before_response()); | 1086 EXPECT_FALSE(d.received_data_before_response()); |
| 1090 EXPECT_EQ(d.bytes_received(), 0); | 1087 EXPECT_EQ(d.bytes_received(), 0); |
| 1091 } | 1088 } |
| 1092 } | 1089 } |
| 1093 | 1090 |
| OLD | NEW |