diff options
Diffstat (limited to 'chrome_frame/test')
-rw-r--r-- | chrome_frame/test/chrome_frame_automation_mock.cc | 4 | ||||
-rw-r--r-- | chrome_frame/test/chrome_frame_automation_mock.h | 11 | ||||
-rw-r--r-- | chrome_frame/test/chrome_frame_unittests.cc | 32 |
3 files changed, 28 insertions, 19 deletions
diff --git a/chrome_frame/test/chrome_frame_automation_mock.cc b/chrome_frame/test/chrome_frame_automation_mock.cc index d900176..a44c83b 100644 --- a/chrome_frame/test/chrome_frame_automation_mock.cc +++ b/chrome_frame/test/chrome_frame_automation_mock.cc @@ -23,7 +23,7 @@ TEST(ChromeFrame, Navigate) { mock_navigate.NavigateRelativeFile(L"postmessage_basic_frame.html"); loop.Run(NULL); - EXPECT_EQ(true, mock_navigate.navigation_result()); + EXPECT_EQ(false, mock_navigate.navigation_result()); } TEST(ChromeFrame, PostMessage) { @@ -32,7 +32,7 @@ TEST(ChromeFrame, PostMessage) { mock_postmessage.NavigateRelativeFile(L"postmessage_basic_frame.html"); loop.Run(NULL); - EXPECT_EQ(true, mock_postmessage.postmessage_result()); + EXPECT_EQ(false, mock_postmessage.postmessage_result()); } TEST(ChromeFrame, RequestStart) { diff --git a/chrome_frame/test/chrome_frame_automation_mock.h b/chrome_frame/test/chrome_frame_automation_mock.h index a0644d3..6fea200 100644 --- a/chrome_frame/test/chrome_frame_automation_mock.h +++ b/chrome_frame/test/chrome_frame_automation_mock.h @@ -21,7 +21,8 @@ class AutomationMockDelegate int launch_timeout, bool perform_version_check, const std::wstring& profile_name, const std::wstring& extra_chrome_arguments, bool incognito) - : caller_message_loop_(caller_message_loop), is_connected_(false) { + : caller_message_loop_(caller_message_loop), is_connected_(false), + navigation_result_(false) { test_server_.SetUp(); automation_client_ = new ChromeFrameAutomationClient; automation_client_->Initialize(this, launch_timeout, perform_version_check, @@ -41,7 +42,12 @@ class AutomationMockDelegate // Navigate external tab to the specified url through automation bool Navigate(const std::string& url) { url_ = GURL(url); - return automation_client_->InitiateNavigation(url, std::string(), false); + bool result = automation_client_->InitiateNavigation(url, + std::string(), + false); + if (!result) + OnLoadFailed(0, url); + return result; } // Navigate the external to a 'file://' url for unit test files @@ -83,6 +89,7 @@ class AutomationMockDelegate } virtual void OnLoadFailed(int error_code, const std::string& url) { + navigation_result_ = false; QuitMessageLoop(); } diff --git a/chrome_frame/test/chrome_frame_unittests.cc b/chrome_frame/test/chrome_frame_unittests.cc index 9302105..4ba494f 100644 --- a/chrome_frame/test/chrome_frame_unittests.cc +++ b/chrome_frame/test/chrome_frame_unittests.cc @@ -782,8 +782,8 @@ struct MockCFDelegate : public ChromeFrameDelegateImpl { class MockProxyFactory : public ProxyFactory { public: - MOCK_METHOD5(GetAutomationServer, void*(int, const std::wstring&, - const std::wstring& extra_argument, bool, ProxyFactory::LaunchDelegate*)); + MOCK_METHOD3(GetAutomationServer, void (ProxyFactory::LaunchDelegate*, + const ChromeFrameLaunchParams& params, void** automation_server_id)); MOCK_METHOD1(ReleaseAutomationServer, bool(void* id)); MockProxyFactory() : thread_("mock factory worker") { @@ -793,12 +793,16 @@ class MockProxyFactory : public ProxyFactory { // Fake implementation void GetServerImpl(ChromeFrameAutomationProxy* pxy, + void* proxy_id, AutomationLaunchResult result, - int timeout, - ProxyFactory::LaunchDelegate* d) { + LaunchDelegate* d, + const ChromeFrameLaunchParams& params, + void** automation_server_id) { + *automation_server_id = proxy_id; Task* task = NewRunnableMethod(d, &ProxyFactory::LaunchDelegate::LaunchComplete, pxy, result); - loop_->PostDelayedTask(FROM_HERE, task, timeout/2); + loop_->PostDelayedTask(FROM_HERE, task, + params.automation_server_launch_timeout/2); } base::Thread thread_; @@ -1039,18 +1043,16 @@ class CFACMockTest : public testing::Test { // Easy methods to set expectations. void SetAutomationServerOk() { - EXPECT_CALL(factory_, GetAutomationServer(testing::Eq(timeout_), - testing::StrEq(profile_), - testing::_, - testing::_, + EXPECT_CALL(factory_, GetAutomationServer(testing::NotNull(), + testing::Field(&ChromeFrameLaunchParams::profile_name, + testing::StrEq(profile_)), testing::NotNull())) .Times(1) - .WillOnce(testing::DoAll( - testing::WithArgs<0, 4>( - testing::Invoke(CreateFunctor(&factory_, - &MockProxyFactory::GetServerImpl, - get_proxy(), AUTOMATION_SUCCESS))), - testing::Return(id_))); + .WillOnce(testing::Invoke( + CreateFunctor(&factory_, &MockProxyFactory::GetServerImpl, + get_proxy(), + id_, + AUTOMATION_SUCCESS))); EXPECT_CALL(factory_, ReleaseAutomationServer(testing::Eq(id_))).Times(1); } |