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

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

Issue 5526008: Simplify the magic required to create IPC message headers a bit. (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/cfproxy_support.cc ('k') | ipc/ipc_fuzzing_tests.cc » ('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 "chrome_frame/test/automation_client_mock.h" 4 #include "chrome_frame/test/automation_client_mock.h"
5 5
6 #include "base/callback.h" 6 #include "base/callback.h"
7 #include "net/base/net_errors.h" 7 #include "net/base/net_errors.h"
8 #include "chrome_frame/custom_sync_call_context.h" 8 #include "chrome_frame/custom_sync_call_context.h"
9 #include "chrome_frame/test/chrome_frame_test_utils.h" 9 #include "chrome_frame/test/chrome_frame_test_utils.h"
10 10
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 CreateTab(); 246 CreateTab();
247 SetAutomationServerOk(1); 247 SetAutomationServerOk(1);
248 248
249 EXPECT_CALL(mock_proxy_, server_version()).Times(testing::AnyNumber()) 249 EXPECT_CALL(mock_proxy_, server_version()).Times(testing::AnyNumber())
250 .WillRepeatedly(Return("")); 250 .WillRepeatedly(Return(""));
251 251
252 // We need some valid HWNDs, when responding to CreateExternalTab 252 // We need some valid HWNDs, when responding to CreateExternalTab
253 HWND h1 = ::GetDesktopWindow(); 253 HWND h1 = ::GetDesktopWindow();
254 HWND h2 = ::GetDesktopWindow(); 254 HWND h2 = ::GetDesktopWindow();
255 EXPECT_CALL(mock_proxy_, SendAsAsync(testing::Property( 255 EXPECT_CALL(mock_proxy_, SendAsAsync(testing::Property(
256 &IPC::SyncMessage::type, AutomationMsg_CreateExternalTab__ID), 256 &IPC::SyncMessage::type, AutomationMsg_CreateExternalTab::ID),
257 testing::NotNull(), _)) 257 testing::NotNull(), _))
258 .Times(1).WillOnce(HandleCreateTab(tab_handle_, h1, h2, 99)); 258 .Times(1).WillOnce(HandleCreateTab(tab_handle_, h1, h2, 99));
259 259
260 EXPECT_CALL(mock_proxy_, CreateTabProxy(testing::Eq(tab_handle_))) 260 EXPECT_CALL(mock_proxy_, CreateTabProxy(testing::Eq(tab_handle_)))
261 .WillOnce(Return(tab_)); 261 .WillOnce(Return(tab_));
262 262
263 EXPECT_CALL(cfd_, OnAutomationServerReady()) 263 EXPECT_CALL(cfd_, OnAutomationServerReady())
264 .WillOnce(QUIT_LOOP(loop_)); 264 .WillOnce(QUIT_LOOP(loop_));
265 265
266 EXPECT_CALL(mock_proxy_, CancelAsync(_)).Times(testing::AnyNumber()); 266 EXPECT_CALL(mock_proxy_, CancelAsync(_)).Times(testing::AnyNumber());
(...skipping 13 matching lines...) Expand all
280 } 280 }
281 281
282 TEST_F(CFACMockTest, MockedCreateTabFailed) { 282 TEST_F(CFACMockTest, MockedCreateTabFailed) {
283 HWND null_wnd = NULL; 283 HWND null_wnd = NULL;
284 SetAutomationServerOk(1); 284 SetAutomationServerOk(1);
285 285
286 EXPECT_CALL(mock_proxy_, server_version()).Times(testing::AnyNumber()) 286 EXPECT_CALL(mock_proxy_, server_version()).Times(testing::AnyNumber())
287 .WillRepeatedly(Return("")); 287 .WillRepeatedly(Return(""));
288 288
289 EXPECT_CALL(mock_proxy_, SendAsAsync(testing::Property( 289 EXPECT_CALL(mock_proxy_, SendAsAsync(testing::Property(
290 &IPC::SyncMessage::type, AutomationMsg_CreateExternalTab__ID), 290 &IPC::SyncMessage::type, AutomationMsg_CreateExternalTab::ID),
291 testing::NotNull(), _)) 291 testing::NotNull(), _))
292 .Times(1).WillOnce(HandleCreateTab(tab_handle_, null_wnd, null_wnd, 292 .Times(1).WillOnce(HandleCreateTab(tab_handle_, null_wnd, null_wnd,
293 99)); 293 99));
294 294
295 EXPECT_CALL(mock_proxy_, CreateTabProxy(_)).Times(0); 295 EXPECT_CALL(mock_proxy_, CreateTabProxy(_)).Times(0);
296 296
297 EXPECT_CALL(mock_proxy_, CancelAsync(_)).Times(testing::AnyNumber()); 297 EXPECT_CALL(mock_proxy_, CancelAsync(_)).Times(testing::AnyNumber());
298 298
299 Set_CFD_LaunchFailed(AUTOMATION_CREATE_TAB_FAILED); 299 Set_CFD_LaunchFailed(AUTOMATION_CREATE_TAB_FAILED);
300 300
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 GURL empty; 343 GURL empty;
344 scoped_refptr<ChromeFrameLaunchParams> clp(new ChromeFrameLaunchParams( 344 scoped_refptr<ChromeFrameLaunchParams> clp(new ChromeFrameLaunchParams(
345 empty, empty, profile_path_, profile_path_.BaseName().value(), L"", L"", 345 empty, empty, profile_path_, profile_path_.BaseName().value(), L"", L"",
346 false, false, false)); 346 false, false, false));
347 clp->set_launch_timeout(1); // Unneeded timeout, but can't be 0. 347 clp->set_launch_timeout(1); // Unneeded timeout, but can't be 0.
348 clp->set_version_check(false); 348 clp->set_version_check(false);
349 349
350 HWND h1 = ::GetDesktopWindow(); 350 HWND h1 = ::GetDesktopWindow();
351 HWND h2 = ::GetDesktopWindow(); 351 HWND h2 = ::GetDesktopWindow();
352 EXPECT_CALL(proxy, SendAsAsync(testing::Property( 352 EXPECT_CALL(proxy, SendAsAsync(testing::Property(
353 &IPC::SyncMessage::type, AutomationMsg_CreateExternalTab__ID), 353 &IPC::SyncMessage::type, AutomationMsg_CreateExternalTab::ID),
354 testing::NotNull(), _)).Times(3) 354 testing::NotNull(), _)).Times(3)
355 .WillOnce(HandleCreateTab(tab_handle_, h1, h2, 99)) 355 .WillOnce(HandleCreateTab(tab_handle_, h1, h2, 99))
356 .WillOnce(HandleCreateTab(tab_handle_ * 2, h1, h2, 100)) 356 .WillOnce(HandleCreateTab(tab_handle_ * 2, h1, h2, 100))
357 .WillOnce(HandleCreateTab(tab_handle_ * 3, h1, h2, 101)); 357 .WillOnce(HandleCreateTab(tab_handle_ * 3, h1, h2, 101));
358 358
359 SetAutomationServerOk(3); 359 SetAutomationServerOk(3);
360 360
361 // First, try a single tab and make sure the notification find its way to the 361 // First, try a single tab and make sure the notification find its way to the
362 // Chrome Frame Delegate. 362 // Chrome Frame Delegate.
363 StrictMock<MockCFDelegate> cfd1; 363 StrictMock<MockCFDelegate> cfd1;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 CreateTab(); 423 CreateTab();
424 SetAutomationServerOk(1); 424 SetAutomationServerOk(1);
425 425
426 EXPECT_CALL(mock_proxy_, server_version()).Times(testing::AnyNumber()) 426 EXPECT_CALL(mock_proxy_, server_version()).Times(testing::AnyNumber())
427 .WillRepeatedly(Return("")); 427 .WillRepeatedly(Return(""));
428 428
429 // We need some valid HWNDs, when responding to CreateExternalTab 429 // We need some valid HWNDs, when responding to CreateExternalTab
430 HWND h1 = ::GetDesktopWindow(); 430 HWND h1 = ::GetDesktopWindow();
431 HWND h2 = ::GetDesktopWindow(); 431 HWND h2 = ::GetDesktopWindow();
432 EXPECT_CALL(mock_proxy_, SendAsAsync(testing::Property( 432 EXPECT_CALL(mock_proxy_, SendAsAsync(testing::Property(
433 &IPC::SyncMessage::type, AutomationMsg_CreateExternalTab__ID), 433 &IPC::SyncMessage::type, AutomationMsg_CreateExternalTab::ID),
434 testing::NotNull(), _)) 434 testing::NotNull(), _))
435 .Times(1).WillOnce(HandleCreateTab(tab_handle_, h1, h2, 99)); 435 .Times(1).WillOnce(HandleCreateTab(tab_handle_, h1, h2, 99));
436 436
437 EXPECT_CALL(mock_proxy_, CreateTabProxy(testing::Eq(tab_handle_))) 437 EXPECT_CALL(mock_proxy_, CreateTabProxy(testing::Eq(tab_handle_)))
438 .WillOnce(Return(tab_)); 438 .WillOnce(Return(tab_));
439 439
440 EXPECT_CALL(cfd_, OnAutomationServerReady()) 440 EXPECT_CALL(cfd_, OnAutomationServerReady())
441 .WillOnce(InitiateNavigation(client_.get(), 441 .WillOnce(InitiateNavigation(client_.get(),
442 std::string("http://www.nonexistent.com"), 442 std::string("http://www.nonexistent.com"),
443 std::string(), false)); 443 std::string(), false));
444 444
445 EXPECT_CALL(mock_proxy_, SendAsAsync(testing::Property( 445 EXPECT_CALL(mock_proxy_, SendAsAsync(testing::Property(
446 &IPC::SyncMessage::type, AutomationMsg_NavigateInExternalTab__ID), 446 &IPC::SyncMessage::type, AutomationMsg_NavigateInExternalTab::ID),
447 testing::NotNull(), _)) 447 testing::NotNull(), _))
448 .Times(1).WillOnce(QUIT_LOOP(loop_)); 448 .Times(1).WillOnce(QUIT_LOOP(loop_));
449 449
450 EXPECT_CALL(mock_proxy_, CancelAsync(_)).Times(testing::AnyNumber()); 450 EXPECT_CALL(mock_proxy_, CancelAsync(_)).Times(testing::AnyNumber());
451 451
452 EXPECT_CALL(mock_proxy_, Send( 452 EXPECT_CALL(mock_proxy_, Send(
453 testing::Property(&IPC::Message::type, AutomationMsg_TabReposition__ID))) 453 testing::Property(&IPC::Message::type, AutomationMsg_TabReposition::ID)))
454 .Times(1) 454 .Times(1)
455 .WillOnce(Return(true)); 455 .WillOnce(Return(true));
456 456
457 EXPECT_CALL(cfd_, GetBounds(_)).Times(1); 457 EXPECT_CALL(cfd_, GetBounds(_)).Times(1);
458 458
459 // Here we go! 459 // Here we go!
460 GURL empty; 460 GURL empty;
461 scoped_refptr<ChromeFrameLaunchParams> launch_params( 461 scoped_refptr<ChromeFrameLaunchParams> launch_params(
462 new ChromeFrameLaunchParams( 462 new ChromeFrameLaunchParams(
463 GURL("http://www.nonexistent.com"), empty, profile_path_, 463 GURL("http://www.nonexistent.com"), empty, profile_path_,
464 profile_path_.BaseName().value(), L"", L"", false, false, false)); 464 profile_path_.BaseName().value(), L"", L"", false, false, false));
465 launch_params->set_launch_timeout(timeout); 465 launch_params->set_launch_timeout(timeout);
466 launch_params->set_version_check(false); 466 launch_params->set_version_check(false);
467 EXPECT_TRUE(client_->Initialize(&cfd_, launch_params)); 467 EXPECT_TRUE(client_->Initialize(&cfd_, launch_params));
468 loop_.RunFor(10); 468 loop_.RunFor(10);
469 469
470 EXPECT_CALL(mock_proxy_, ReleaseTabProxy(testing::Eq(tab_handle_))).Times(1); 470 EXPECT_CALL(mock_proxy_, ReleaseTabProxy(testing::Eq(tab_handle_))).Times(1);
471 client_->Uninitialize(); 471 client_->Uninitialize();
472 } 472 }
OLDNEW
« no previous file with comments | « chrome_frame/cfproxy_support.cc ('k') | ipc/ipc_fuzzing_tests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698