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

Side by Side Diff: chrome_frame/test/url_request_test.cc

Issue 10825073: Stop using ScopedAllowIO in content::ResourceDispatcherHostImpl (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Chrome Frame fix Created 8 years, 4 months 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <atlbase.h> 5 #include <atlbase.h>
6 #include <atlcom.h> 6 #include <atlcom.h>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/win/scoped_com_initializer.h" 10 #include "base/win/scoped_com_initializer.h"
(...skipping 21 matching lines...) Expand all
32 // Seek to the end. 32 // Seek to the end.
33 ASSERT_HRESULT_SUCCEEDED(s->Seek(zero, STREAM_SEEK_END, NULL)); 33 ASSERT_HRESULT_SUCCEEDED(s->Seek(zero, STREAM_SEEK_END, NULL));
34 ASSERT_HRESULT_SUCCEEDED(s->Write(buffer, cb, &bytes_written)); 34 ASSERT_HRESULT_SUCCEEDED(s->Write(buffer, cb, &bytes_written));
35 ASSERT_EQ(cb, bytes_written); 35 ASSERT_EQ(cb, bytes_written);
36 // Seek to original position. 36 // Seek to original position.
37 ASSERT_HRESULT_SUCCEEDED(s->Seek(current_pos, STREAM_SEEK_SET, NULL)); 37 ASSERT_HRESULT_SUCCEEDED(s->Seek(current_pos, STREAM_SEEK_SET, NULL));
38 } 38 }
39 39
40 class MockUrlDelegate : public PluginUrlRequestDelegate { 40 class MockUrlDelegate : public PluginUrlRequestDelegate {
41 public: 41 public:
42 MOCK_METHOD8(OnResponseStarted, void(int request_id, const char* mime_type, 42 MOCK_METHOD9(OnResponseStarted, void(int request_id, const char* mime_type,
43 const char* headers, int size, base::Time last_modified, 43 const char* headers, int size, base::Time last_modified,
44 const std::string& redirect_url, int redirect_status, 44 const std::string& redirect_url, int redirect_status,
45 const net::HostPortPair& socket_address)); 45 const net::HostPortPair& socket_address, uint64 upload_size));
46 MOCK_METHOD2(OnReadComplete, void(int request_id, const std::string& data)); 46 MOCK_METHOD2(OnReadComplete, void(int request_id, const std::string& data));
47 MOCK_METHOD2(OnResponseEnd, void(int request_id, 47 MOCK_METHOD2(OnResponseEnd, void(int request_id,
48 const net::URLRequestStatus& status)); 48 const net::URLRequestStatus& status));
49 MOCK_METHOD4(OnCookiesRetrieved, void(bool success, const GURL& url, 49 MOCK_METHOD4(OnCookiesRetrieved, void(bool success, const GURL& url,
50 const std::string& cookie, int cookie_id)); 50 const std::string& cookie, int cookie_id));
51 51
52 void PostponeReadRequest(chrome_frame_test::TimedMsgLoop* loop, 52 void PostponeReadRequest(chrome_frame_test::TimedMsgLoop* loop,
53 UrlmonUrlRequest* request, int bytes_to_read) { 53 UrlmonUrlRequest* request, int bytes_to_read) {
54 loop->PostTask(FROM_HERE, 54 loop->PostTask(FROM_HERE,
55 base::Bind(&MockUrlDelegate::RequestRead, 55 base::Bind(&MockUrlDelegate::RequestRead,
(...skipping 25 matching lines...) Expand all
81 "", // referrer 81 "", // referrer
82 "", // extra request 82 "", // extra request
83 NULL, // upload data 83 NULL, // upload data
84 ResourceType::MAIN_FRAME, // resource type 84 ResourceType::MAIN_FRAME, // resource type
85 true, 85 true,
86 0); // frame busting 86 0); // frame busting
87 87
88 testing::InSequence s; 88 testing::InSequence s;
89 EXPECT_CALL(mock, OnResponseStarted(1, testing::_, testing::_, testing::_, 89 EXPECT_CALL(mock, OnResponseStarted(1, testing::_, testing::_, testing::_,
90 testing::_, testing::_, testing::_, 90 testing::_, testing::_, testing::_,
91 testing::_)) 91 testing::_, testing::_))
92 .Times(1) 92 .Times(1)
93 .WillOnce(testing::IgnoreResult(testing::InvokeWithoutArgs(CreateFunctor( 93 .WillOnce(testing::IgnoreResult(testing::InvokeWithoutArgs(CreateFunctor(
94 &request, &UrlmonUrlRequest::Read, 512)))); 94 &request, &UrlmonUrlRequest::Read, 512))));
95 95
96 96
97 EXPECT_CALL(mock, OnReadComplete(1, testing::Property(&std::string::size, 97 EXPECT_CALL(mock, OnReadComplete(1, testing::Property(&std::string::size,
98 testing::Gt(0u)))) 98 testing::Gt(0u))))
99 .Times(testing::AtLeast(1)) 99 .Times(testing::AtLeast(1))
100 .WillRepeatedly(testing::InvokeWithoutArgs(CreateFunctor(&mock, 100 .WillRepeatedly(testing::InvokeWithoutArgs(CreateFunctor(&mock,
101 &MockUrlDelegate::PostponeReadRequest, &loop, &request, 64))); 101 &MockUrlDelegate::PostponeReadRequest, &loop, &request, 64)));
(...skipping 28 matching lines...) Expand all
130 "", // referrer 130 "", // referrer
131 "", // extra request 131 "", // extra request
132 NULL, // upload data 132 NULL, // upload data
133 ResourceType::MAIN_FRAME, // resource type 133 ResourceType::MAIN_FRAME, // resource type
134 true, 134 true,
135 0); // frame busting 135 0); // frame busting
136 136
137 testing::InSequence s; 137 testing::InSequence s;
138 EXPECT_CALL(mock, OnResponseStarted(1, testing::_, testing::_, testing::_, 138 EXPECT_CALL(mock, OnResponseStarted(1, testing::_, testing::_, testing::_,
139 testing::_, testing::_, testing::_, 139 testing::_, testing::_, testing::_,
140 testing::_)) 140 testing::_, testing::_))
141 .Times(1) 141 .Times(1)
142 .WillOnce(testing::IgnoreResult(testing::InvokeWithoutArgs(CreateFunctor( 142 .WillOnce(testing::IgnoreResult(testing::InvokeWithoutArgs(CreateFunctor(
143 &request, &UrlmonUrlRequest::Read, 512)))); 143 &request, &UrlmonUrlRequest::Read, 512))));
144 144
145 // For HEAD requests we don't expect content reads. 145 // For HEAD requests we don't expect content reads.
146 EXPECT_CALL(mock, OnReadComplete(1, testing::_)).Times(0); 146 EXPECT_CALL(mock, OnReadComplete(1, testing::_)).Times(0);
147 147
148 EXPECT_CALL(mock, OnResponseEnd(1, testing::_)) 148 EXPECT_CALL(mock, OnResponseEnd(1, testing::_))
149 .Times(1) 149 .Times(1)
150 .WillOnce(QUIT_LOOP_SOON(loop, base::TimeDelta::FromSeconds(2))); 150 .WillOnce(QUIT_LOOP_SOON(loop, base::TimeDelta::FromSeconds(2)));
(...skipping 23 matching lines...) Expand all
174 "", // extra request 174 "", // extra request
175 NULL, // upload data 175 NULL, // upload data
176 ResourceType::MAIN_FRAME, // resource type 176 ResourceType::MAIN_FRAME, // resource type
177 true, 177 true,
178 0); // frame busting 178 0); // frame busting
179 179
180 // Expect headers 180 // Expect headers
181 EXPECT_CALL(mock, OnResponseStarted(1, testing::_, 181 EXPECT_CALL(mock, OnResponseStarted(1, testing::_,
182 testing::StartsWith("HTTP/1.1 404"), 182 testing::StartsWith("HTTP/1.1 404"),
183 testing::_, testing::_, testing::_, 183 testing::_, testing::_, testing::_,
184 testing::_, testing::_)) 184 testing::_, testing::_, testing::_))
185 .Times(1) 185 .Times(1)
186 .WillOnce(QUIT_LOOP_SOON(loop, base::TimeDelta::FromSeconds(2))); 186 .WillOnce(QUIT_LOOP_SOON(loop, base::TimeDelta::FromSeconds(2)));
187 187
188 EXPECT_CALL(mock, OnResponseEnd(1, testing::Property( 188 EXPECT_CALL(mock, OnResponseEnd(1, testing::Property(
189 &net::URLRequestStatus::error, 189 &net::URLRequestStatus::error,
190 net::ERR_TUNNEL_CONNECTION_FAILED))) 190 net::ERR_TUNNEL_CONNECTION_FAILED)))
191 .Times(testing::AtMost(1)); 191 .Times(testing::AtMost(1));
192 192
193 request.Start(); 193 request.Start();
194 loop.RunFor(kChromeFrameLongNavigationTimeout); 194 loop.RunFor(kChromeFrameLongNavigationTimeout);
(...skipping 17 matching lines...) Expand all
212 "", // referrer 212 "", // referrer
213 "", // extra request 213 "", // extra request
214 NULL, // upload data 214 NULL, // upload data
215 ResourceType::MAIN_FRAME, // resource type 215 ResourceType::MAIN_FRAME, // resource type
216 true, 216 true,
217 0); // frame busting 217 0); // frame busting
218 218
219 // Expect headers 219 // Expect headers
220 EXPECT_CALL(mock, OnResponseStarted(1, testing::_, testing::_, testing::_, 220 EXPECT_CALL(mock, OnResponseStarted(1, testing::_, testing::_, testing::_,
221 testing::_, testing::_, testing::_, 221 testing::_, testing::_, testing::_,
222 testing::_)) 222 testing::_, testing::_))
223 .Times(1) 223 .Times(1)
224 .WillOnce(QUIT_LOOP(loop)); 224 .WillOnce(QUIT_LOOP(loop));
225 225
226 request.Start(); 226 request.Start();
227 loop.RunFor(kChromeFrameLongNavigationTimeout); 227 loop.RunFor(kChromeFrameLongNavigationTimeout);
228 EXPECT_FALSE(loop.WasTimedOut()); 228 EXPECT_FALSE(loop.WasTimedOut());
229 229
230 // Should stay quiet, since we do not ask for anything for awhile. 230 // Should stay quiet, since we do not ask for anything for awhile.
231 EXPECT_CALL(mock, OnResponseEnd(1, testing::_)).Times(0); 231 EXPECT_CALL(mock, OnResponseEnd(1, testing::_)).Times(0);
232 loop.RunFor(base::TimeDelta::FromSeconds(3)); 232 loop.RunFor(base::TimeDelta::FromSeconds(3));
(...skipping 28 matching lines...) Expand all
261 261
262 scoped_ptr<UrlmonUrlRequestManager> mgr(new UrlmonUrlRequestManager()); 262 scoped_ptr<UrlmonUrlRequestManager> mgr(new UrlmonUrlRequestManager());
263 mgr->set_delegate(&mock); 263 mgr->set_delegate(&mock);
264 AutomationURLRequest r1; 264 AutomationURLRequest r1;
265 r1.url = WideToUTF8(mock_server.Resolve(L"chrome_frame_window_open.html")); 265 r1.url = WideToUTF8(mock_server.Resolve(L"chrome_frame_window_open.html"));
266 r1.method = "get"; 266 r1.method = "get";
267 r1.resource_type = 0; 267 r1.resource_type = 0;
268 r1.load_flags = 0; 268 r1.load_flags = 0;
269 269
270 EXPECT_CALL(mock, OnResponseStarted(1, testing::_, testing::_, testing::_, 270 EXPECT_CALL(mock, OnResponseStarted(1, testing::_, testing::_, testing::_,
271 testing::_, testing::_, testing::_, testing::_)) 271 testing::_, testing::_, testing::_, testing::_,
272 testing::_))
272 .Times(1) 273 .Times(1)
273 .WillOnce(ManagerRead(&loop, mgr.get(), 1, 512)); 274 .WillOnce(ManagerRead(&loop, mgr.get(), 1, 512));
274 275
275 EXPECT_CALL(mock, OnReadComplete(1, testing::Property(&std::string::size, 276 EXPECT_CALL(mock, OnReadComplete(1, testing::Property(&std::string::size,
276 testing::Gt(0u)))) 277 testing::Gt(0u))))
277 .Times(testing::AtLeast(1)) 278 .Times(testing::AtLeast(1))
278 .WillRepeatedly(ManagerRead(&loop, mgr.get(), 1, 2)); 279 .WillRepeatedly(ManagerRead(&loop, mgr.get(), 1, 2));
279 280
280 EXPECT_CALL(mock, OnResponseEnd(1, testing::_)) 281 EXPECT_CALL(mock, OnResponseEnd(1, testing::_))
281 .Times(1) 282 .Times(1)
(...skipping 14 matching lines...) Expand all
296 297
297 scoped_ptr<UrlmonUrlRequestManager> mgr(new UrlmonUrlRequestManager()); 298 scoped_ptr<UrlmonUrlRequestManager> mgr(new UrlmonUrlRequestManager());
298 mgr->set_delegate(&mock); 299 mgr->set_delegate(&mock);
299 AutomationURLRequest r1; 300 AutomationURLRequest r1;
300 r1.url = WideToUTF8(mock_server.Resolve(L"chrome_frame_window_open.html")); 301 r1.url = WideToUTF8(mock_server.Resolve(L"chrome_frame_window_open.html"));
301 r1.method = "get"; 302 r1.method = "get";
302 r1.resource_type = 0; 303 r1.resource_type = 0;
303 r1.load_flags = 0; 304 r1.load_flags = 0;
304 305
305 EXPECT_CALL(mock, OnResponseStarted(1, testing::_, testing::_, testing::_, 306 EXPECT_CALL(mock, OnResponseStarted(1, testing::_, testing::_, testing::_,
306 testing::_, testing::_, testing::_, testing::_)) 307 testing::_, testing::_, testing::_, testing::_,
308 testing::_))
307 .Times(1) 309 .Times(1)
308 .WillOnce(testing::DoAll( 310 .WillOnce(testing::DoAll(
309 ManagerEndRequest(&loop, mgr.get(), 1), 311 ManagerEndRequest(&loop, mgr.get(), 1),
310 QUIT_LOOP_SOON(loop, base::TimeDelta::FromSeconds(3)))); 312 QUIT_LOOP_SOON(loop, base::TimeDelta::FromSeconds(3))));
311 313
312 EXPECT_CALL(mock, OnReadComplete(1, testing::_)) 314 EXPECT_CALL(mock, OnReadComplete(1, testing::_))
313 .Times(0); 315 .Times(0);
314 316
315 EXPECT_CALL(mock, OnResponseEnd(1, testing::_)) 317 EXPECT_CALL(mock, OnResponseEnd(1, testing::_))
316 .Times(0); 318 .Times(0);
317 319
318 mgr->StartUrlRequest(1, r1); 320 mgr->StartUrlRequest(1, r1);
319 loop.RunFor(kChromeFrameLongNavigationTimeout); 321 loop.RunFor(kChromeFrameLongNavigationTimeout);
320 mgr.reset(); 322 mgr.reset();
321 } 323 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698