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

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

Issue 5998006: Clean up Automation and Chrome Frame IPC code. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 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 | « chrome_frame/test/chrome_frame_automation_mock.h ('k') | chrome_frame/urlmon_url_request.h » ('j') | 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #include <atlbase.h> 4 #include <atlbase.h>
5 #include <atlcom.h> 5 #include <atlcom.h>
6 6
7 #include "app/win_util.h" 7 #include "app/win_util.h"
8 #include "chrome_frame/test/test_server.h" 8 #include "chrome_frame/test/test_server.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "testing/gmock/include/gmock/gmock.h" 10 #include "testing/gmock/include/gmock/gmock.h"
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 // is supposed to be delivered. 233 // is supposed to be delivered.
234 EXPECT_CALL(mock, OnResponseEnd(1, testing::Property( 234 EXPECT_CALL(mock, OnResponseEnd(1, testing::Property(
235 &URLRequestStatus::is_success, true))) 235 &URLRequestStatus::is_success, true)))
236 .Times(1); 236 .Times(1);
237 request.Read(512); 237 request.Read(512);
238 request.Release(); 238 request.Release();
239 } 239 }
240 240
241 ACTION_P4(ManagerRead, loop, mgr, request_id, bytes_to_read) { 241 ACTION_P4(ManagerRead, loop, mgr, request_id, bytes_to_read) {
242 loop->PostDelayedTask(FROM_HERE, NewRunnableMethod(mgr, 242 loop->PostDelayedTask(FROM_HERE, NewRunnableMethod(mgr,
243 &UrlmonUrlRequestManager::ReadUrlRequest, 0, request_id, 243 &UrlmonUrlRequestManager::ReadUrlRequest, request_id,
244 bytes_to_read), 0); 244 bytes_to_read), 0);
245 } 245 }
246 ACTION_P3(ManagerEndRequest, loop, mgr, request_id) { 246 ACTION_P3(ManagerEndRequest, loop, mgr, request_id) {
247 loop->PostDelayedTask(FROM_HERE, NewRunnableMethod(mgr, 247 loop->PostDelayedTask(FROM_HERE, NewRunnableMethod(mgr,
248 &UrlmonUrlRequestManager::EndUrlRequest, 0, request_id, 248 &UrlmonUrlRequestManager::EndUrlRequest, request_id,
249 URLRequestStatus()), 0); 249 URLRequestStatus()), 0);
250 } 250 }
251 251
252 // Simplest test - retrieve file from local web server. 252 // Simplest test - retrieve file from local web server.
253 TEST(UrlmonUrlRequestManagerTest, Simple1) { 253 TEST(UrlmonUrlRequestManagerTest, Simple1) {
254 MockUrlDelegate mock; 254 MockUrlDelegate mock;
255 chrome_frame_test::TimedMsgLoop loop; 255 chrome_frame_test::TimedMsgLoop loop;
256 256
257 testing::StrictMock<MockWebServer> mock_server(1337, L"127.0.0.1", 257 testing::StrictMock<MockWebServer> mock_server(1337, L"127.0.0.1",
258 chrome_frame_test::GetTestDataFolder()); 258 chrome_frame_test::GetTestDataFolder());
259 mock_server.ExpectAndServeAnyRequests(CFInvocation(CFInvocation::NONE)); 259 mock_server.ExpectAndServeAnyRequests(CFInvocation(CFInvocation::NONE));
260 260
261 scoped_ptr<UrlmonUrlRequestManager> mgr(new UrlmonUrlRequestManager()); 261 scoped_ptr<UrlmonUrlRequestManager> mgr(new UrlmonUrlRequestManager());
262 mgr->set_delegate(&mock); 262 mgr->set_delegate(&mock);
263 IPC::AutomationURLRequest r1( 263 AutomationURLRequest r1(
264 WideToUTF8(mock_server.Resolve(L"chrome_frame_window_open.html")), 264 WideToUTF8(mock_server.Resolve(L"chrome_frame_window_open.html")),
265 "get", "", "", NULL, 0, 0); 265 "get", "", "", NULL, 0, 0);
266 266
267 EXPECT_CALL(mock, OnResponseStarted(1, testing::_, testing::_, testing::_, 267 EXPECT_CALL(mock, OnResponseStarted(1, testing::_, testing::_, testing::_,
268 testing::_, testing::_, testing::_)) 268 testing::_, testing::_, testing::_))
269 .Times(1) 269 .Times(1)
270 .WillOnce(ManagerRead(&loop, mgr.get(), 1, 512)); 270 .WillOnce(ManagerRead(&loop, mgr.get(), 1, 512));
271 271
272 EXPECT_CALL(mock, OnReadComplete(1, testing::Property(&std::string::size, 272 EXPECT_CALL(mock, OnReadComplete(1, testing::Property(&std::string::size,
273 testing::Gt(0u)))) 273 testing::Gt(0u))))
274 .Times(testing::AtLeast(1)) 274 .Times(testing::AtLeast(1))
275 .WillRepeatedly(ManagerRead(&loop, mgr.get(), 1, 2)); 275 .WillRepeatedly(ManagerRead(&loop, mgr.get(), 1, 2));
276 276
277 EXPECT_CALL(mock, OnResponseEnd(1, testing::_)) 277 EXPECT_CALL(mock, OnResponseEnd(1, testing::_))
278 .Times(1) 278 .Times(1)
279 .WillOnce(QUIT_LOOP_SOON(loop, 2)); 279 .WillOnce(QUIT_LOOP_SOON(loop, 2));
280 280
281 mgr->StartUrlRequest(0, 1, r1); 281 mgr->StartUrlRequest(1, r1);
282 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); 282 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds);
283 mgr.reset(); 283 mgr.reset();
284 } 284 }
285 285
286 TEST(UrlmonUrlRequestManagerTest, Abort1) { 286 TEST(UrlmonUrlRequestManagerTest, Abort1) {
287 MockUrlDelegate mock; 287 MockUrlDelegate mock;
288 chrome_frame_test::TimedMsgLoop loop; 288 chrome_frame_test::TimedMsgLoop loop;
289 289
290 testing::StrictMock<MockWebServer> mock_server(1337, L"127.0.0.1", 290 testing::StrictMock<MockWebServer> mock_server(1337, L"127.0.0.1",
291 chrome_frame_test::GetTestDataFolder()); 291 chrome_frame_test::GetTestDataFolder());
292 mock_server.ExpectAndServeAnyRequests(CFInvocation(CFInvocation::NONE)); 292 mock_server.ExpectAndServeAnyRequests(CFInvocation(CFInvocation::NONE));
293 293
294 scoped_ptr<UrlmonUrlRequestManager> mgr(new UrlmonUrlRequestManager()); 294 scoped_ptr<UrlmonUrlRequestManager> mgr(new UrlmonUrlRequestManager());
295 mgr->set_delegate(&mock); 295 mgr->set_delegate(&mock);
296 IPC::AutomationURLRequest r1( 296 AutomationURLRequest r1(
297 WideToUTF8(mock_server.Resolve(L"chrome_frame_window_open.html")), 297 WideToUTF8(mock_server.Resolve(L"chrome_frame_window_open.html")),
298 "get", "", "", NULL, 0, 0); 298 "get", "", "", NULL, 0, 0);
299 299
300 EXPECT_CALL(mock, OnResponseStarted(1, testing::_, testing::_, testing::_, 300 EXPECT_CALL(mock, OnResponseStarted(1, testing::_, testing::_, testing::_,
301 testing::_, testing::_, testing::_)) 301 testing::_, testing::_, testing::_))
302 .Times(1) 302 .Times(1)
303 .WillOnce(testing::DoAll( 303 .WillOnce(testing::DoAll(
304 ManagerEndRequest(&loop, mgr.get(), 1), 304 ManagerEndRequest(&loop, mgr.get(), 1),
305 QUIT_LOOP_SOON(loop, 3))); 305 QUIT_LOOP_SOON(loop, 3)));
306 306
307 EXPECT_CALL(mock, OnReadComplete(1, testing::_)) 307 EXPECT_CALL(mock, OnReadComplete(1, testing::_))
308 .Times(0); 308 .Times(0);
309 309
310 EXPECT_CALL(mock, OnResponseEnd(1, testing::_)) 310 EXPECT_CALL(mock, OnResponseEnd(1, testing::_))
311 .Times(0); 311 .Times(0);
312 312
313 mgr->StartUrlRequest(0, 1, r1); 313 mgr->StartUrlRequest(1, r1);
314 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); 314 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds);
315 mgr.reset(); 315 mgr.reset();
316 } 316 }
OLDNEW
« no previous file with comments | « chrome_frame/test/chrome_frame_automation_mock.h ('k') | chrome_frame/urlmon_url_request.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698