| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome_frame/test/automation_client_mock.h" | 5 #include "chrome_frame/test/automation_client_mock.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" |
| 8 #include "chrome/common/automation_messages.h" | 9 #include "chrome/common/automation_messages.h" |
| 9 #include "chrome_frame/custom_sync_call_context.h" | 10 #include "chrome_frame/custom_sync_call_context.h" |
| 10 #include "chrome_frame/navigation_constraints.h" | 11 #include "chrome_frame/navigation_constraints.h" |
| 11 #include "chrome_frame/test/chrome_frame_test_utils.h" | 12 #include "chrome_frame/test/chrome_frame_test_utils.h" |
| 12 #include "net/base/net_errors.h" | 13 #include "net/base/net_errors.h" |
| 13 | 14 |
| 14 #define GMOCK_MUTANT_INCLUDE_LATE_OBJECT_BINDING | 15 #define GMOCK_MUTANT_INCLUDE_LATE_OBJECT_BINDING |
| 15 #include "testing/gmock_mutant.h" | 16 #include "testing/gmock_mutant.h" |
| 16 | 17 |
| 17 using testing::_; | 18 using testing::_; |
| 18 using testing::CreateFunctor; | 19 using testing::CreateFunctor; |
| 19 using testing::Return; | 20 using testing::Return; |
| 20 | 21 |
| 21 DISABLE_RUNNABLE_METHOD_REFCOUNT(LaunchDelegate); | |
| 22 DISABLE_RUNNABLE_METHOD_REFCOUNT(ChromeFrameAutomationClient); | |
| 23 DISABLE_RUNNABLE_METHOD_REFCOUNT(chrome_frame_test::TimedMsgLoop); | |
| 24 | |
| 25 MATCHER_P(LaunchParamProfileEq, profile_name, "Check for profile name") { | 22 MATCHER_P(LaunchParamProfileEq, profile_name, "Check for profile name") { |
| 26 return arg->profile_name().compare(profile_name) == 0; | 23 return arg->profile_name().compare(profile_name) == 0; |
| 27 } | 24 } |
| 28 | 25 |
| 29 void MockProxyFactory::GetServerImpl(ChromeFrameAutomationProxy* pxy, | 26 void MockProxyFactory::GetServerImpl(ChromeFrameAutomationProxy* pxy, |
| 30 void* proxy_id, | 27 void* proxy_id, |
| 31 AutomationLaunchResult result, | 28 AutomationLaunchResult result, |
| 32 LaunchDelegate* d, | 29 LaunchDelegate* d, |
| 33 ChromeFrameLaunchParams* params, | 30 ChromeFrameLaunchParams* params, |
| 34 void** automation_server_id) { | 31 void** automation_server_id) { |
| 35 *automation_server_id = proxy_id; | 32 *automation_server_id = proxy_id; |
| 36 Task* task = NewRunnableMethod(d, | 33 loop_->PostDelayedTask(FROM_HERE, |
| 37 &LaunchDelegate::LaunchComplete, pxy, result); | 34 base::Bind(&LaunchDelegate::LaunchComplete, |
| 38 loop_->PostDelayedTask(FROM_HERE, task, | 35 base::Unretained(d), pxy, result), |
| 39 params->launch_timeout() / 2); | 36 params->launch_timeout() / 2); |
| 40 } | 37 } |
| 41 | 38 |
| 42 void CFACMockTest::SetAutomationServerOk(int times) { | 39 void CFACMockTest::SetAutomationServerOk(int times) { |
| 43 EXPECT_CALL(factory_, GetAutomationServer(testing::NotNull(), | 40 EXPECT_CALL(factory_, GetAutomationServer(testing::NotNull(), |
| 44 LaunchParamProfileEq(profile_path_.BaseName().value()), | 41 LaunchParamProfileEq(profile_path_.BaseName().value()), |
| 45 testing::NotNull())) | 42 testing::NotNull())) |
| 46 .Times(times) | 43 .Times(times) |
| 47 .WillRepeatedly(testing::Invoke(CreateFunctor(&factory_, | 44 .WillRepeatedly(testing::Invoke(CreateFunctor(&factory_, |
| 48 &MockProxyFactory::GetServerImpl, get_proxy(), id_, | 45 &MockProxyFactory::GetServerImpl, get_proxy(), id_, |
| (...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 GURL("http://www.nonexistent.com"), empty, profile_path_, | 469 GURL("http://www.nonexistent.com"), empty, profile_path_, |
| 473 profile_path_.BaseName().value(), L"", L"", false, false, false)); | 470 profile_path_.BaseName().value(), L"", L"", false, false, false)); |
| 474 launch_params->set_launch_timeout(timeout); | 471 launch_params->set_launch_timeout(timeout); |
| 475 launch_params->set_version_check(false); | 472 launch_params->set_version_check(false); |
| 476 EXPECT_TRUE(client_->Initialize(&cfd_, launch_params)); | 473 EXPECT_TRUE(client_->Initialize(&cfd_, launch_params)); |
| 477 loop_.RunFor(10); | 474 loop_.RunFor(10); |
| 478 | 475 |
| 479 EXPECT_CALL(mock_proxy_, ReleaseTabProxy(testing::Eq(tab_handle_))).Times(1); | 476 EXPECT_CALL(mock_proxy_, ReleaseTabProxy(testing::Eq(tab_handle_))).Times(1); |
| 480 client_->Uninitialize(); | 477 client_->Uninitialize(); |
| 481 } | 478 } |
| OLD | NEW |