diff options
author | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-18 22:52:47 +0000 |
---|---|---|
committer | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-18 22:52:47 +0000 |
commit | 437aa724eacc818379953a76db151d2d79ec7b4d (patch) | |
tree | 2021dc6fe13ed3b4a751303c58a9fc01ca13cbc8 /chrome_frame | |
parent | f24de1ccd9217b496383ff222b37deb4c1811963 (diff) | |
download | chromium_src-437aa724eacc818379953a76db151d2d79ec7b4d.zip chromium_src-437aa724eacc818379953a76db151d2d79ec7b4d.tar.gz chromium_src-437aa724eacc818379953a76db151d2d79ec7b4d.tar.bz2 |
Fix ChromeFrame test failures on the builder caused by my CL to change the way the automation
launch parameters are propagated to the ChromeFrameAutomationClient object.
I also fixed the ChromeFrame automation mock tests which don't use gmock and instead relied
on an incorrect behavior in ChromeFrame where we would deny the navigation from the automation
client and still navigate in Chrome when the external tab is created.
Will work on changing these tests to gmock in a subsequent CL.
TBR=stoyan and thanks to him for helping debug the gmock failures.
Review URL: http://codereview.chromium.org/500143
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@34996 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame')
-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); } |