Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1369)

Side by Side Diff: net/url_request/url_request_unittest.cc

Issue 12930: Third time's a charm?... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/net_unittests.scons ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
8
7 #if defined(OS_WIN) 9 #if defined(OS_WIN)
8 #include <windows.h> 10 #include <windows.h>
9 #include <shlobj.h> 11 #include <shlobj.h>
12 #elif defined(OS_LINUX)
13 #include "base/nss_init.h"
10 #endif 14 #endif
11 15
12 #include <algorithm> 16 #include <algorithm>
13 #include <string> 17 #include <string>
14 18
15 #include "base/message_loop.h" 19 #include "base/message_loop.h"
16 #include "base/path_service.h" 20 #include "base/path_service.h"
17 #include "base/process_util.h" 21 #include "base/process_util.h"
18 #include "base/string_piece.h" 22 #include "base/string_piece.h"
19 #include "base/string_util.h" 23 #include "base/string_util.h"
20 #include "net/base/load_flags.h" 24 #include "net/base/load_flags.h"
21 #include "net/base/net_errors.h" 25 #include "net/base/net_errors.h"
22 #include "net/base/net_module.h" 26 #include "net/base/net_module.h"
23 #include "net/base/net_util.h" 27 #include "net/base/net_util.h"
28 #include "net/base/ssl_test_util.h"
24 #include "net/disk_cache/disk_cache.h" 29 #include "net/disk_cache/disk_cache.h"
25 #include "net/http/http_cache.h" 30 #include "net/http/http_cache.h"
26 #include "net/http/http_network_layer.h" 31 #include "net/http/http_network_layer.h"
27 #include "net/url_request/url_request.h" 32 #include "net/url_request/url_request.h"
28 #include "testing/gtest/include/gtest/gtest.h" 33 #include "testing/gtest/include/gtest/gtest.h"
29 #include "testing/platform_test.h" 34 #include "testing/platform_test.h"
30 35
31 using base::Time; 36 using base::Time;
32 37
33 namespace { 38 namespace {
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 114
110 EXPECT_EQ(1, d.response_started_count()); 115 EXPECT_EQ(1, d.response_started_count());
111 EXPECT_FALSE(d.received_data_before_response()); 116 EXPECT_FALSE(d.received_data_before_response());
112 EXPECT_NE(0, d.bytes_received()); 117 EXPECT_NE(0, d.bytes_received());
113 } 118 }
114 #ifndef NDEBUG 119 #ifndef NDEBUG
115 DCHECK_EQ(url_request_metrics.object_count,0); 120 DCHECK_EQ(url_request_metrics.object_count,0);
116 #endif 121 #endif
117 } 122 }
118 123
124 class HTTPSRequestTest : public testing::Test {
125 protected:
126 HTTPSRequestTest() : util_() {};
127
128 SSLTestUtil util_;
129 };
130
131 #if defined(OS_MACOSX)
132 // TODO(port): support temporary root cert on mac
133 #define MAYBE_HTTPSGetTest DISABLED_HTTPSGetTest
134 #else
135 #define MAYBE_HTTPSGetTest HTTPSGetTest
136 #endif
137
138 TEST_F(HTTPSRequestTest, MAYBE_HTTPSGetTest) {
139 // Note: tools/testserver/testserver.py does not need
140 // a working document root to server the pages / and /hello.html,
141 // so this test doesn't really need to specify a document root.
142 // But if it did, a good one would be net/data/ssl.
143 HTTPSTestServer https_server(util_.kHostName, util_.kOKHTTPSPort,
144 L"net/data/ssl",
145 util_.GetOKCertPath().ToWStringHack());
146
147 EXPECT_TRUE(util_.CheckCATrusted());
148 TestDelegate d;
149 {
150 TestURLRequest r(https_server.TestServerPage(""), &d);
151
152 r.Start();
153 EXPECT_TRUE(r.is_pending());
154
155 MessageLoop::current()->Run();
156
157 EXPECT_EQ(1, d.response_started_count());
158 EXPECT_FALSE(d.received_data_before_response());
159 EXPECT_NE(0, d.bytes_received());
160 }
161 #ifndef NDEBUG
162 DCHECK_EQ(url_request_metrics.object_count,0);
163 #endif
164 }
165
119 TEST_F(URLRequestTest, CancelTest) { 166 TEST_F(URLRequestTest, CancelTest) {
120 TestDelegate d; 167 TestDelegate d;
121 { 168 {
122 TestURLRequest r(GURL("http://www.google.com/"), &d); 169 TestURLRequest r(GURL("http://www.google.com/"), &d);
123 170
124 r.Start(); 171 r.Start();
125 EXPECT_TRUE(r.is_pending()); 172 EXPECT_TRUE(r.is_pending());
126 173
127 r.Cancel(); 174 r.Cancel();
128 175
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after
827 EXPECT_FALSE(ContainsString(data, "Content-Length:")); 874 EXPECT_FALSE(ContainsString(data, "Content-Length:"));
828 EXPECT_FALSE(ContainsString(data, "Content-Type:")); 875 EXPECT_FALSE(ContainsString(data, "Content-Type:"));
829 EXPECT_FALSE(ContainsString(data, "Origin:")); 876 EXPECT_FALSE(ContainsString(data, "Origin:"));
830 877
831 // These extra request headers should not have been stripped. 878 // These extra request headers should not have been stripped.
832 EXPECT_TRUE(ContainsString(data, "Accept:")); 879 EXPECT_TRUE(ContainsString(data, "Accept:"));
833 EXPECT_TRUE(ContainsString(data, "Accept-Language:")); 880 EXPECT_TRUE(ContainsString(data, "Accept-Language:"));
834 EXPECT_TRUE(ContainsString(data, "Accept-Charset:")); 881 EXPECT_TRUE(ContainsString(data, "Accept-Charset:"));
835 } 882 }
836 883
OLDNEW
« no previous file with comments | « net/net_unittests.scons ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698