OLD | NEW |
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 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 IPC::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" }; | 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)); |
(...skipping 10 matching lines...) Expand all Loading... |
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 IPC::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" }; | 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(0, 1, r1); |
314 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); | 314 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); |
315 mgr.reset(); | 315 mgr.reset(); |
316 } | 316 } |
317 | |
OLD | NEW |