diff options
author | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-29 21:46:21 +0000 |
---|---|---|
committer | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-29 21:46:21 +0000 |
commit | cb4b1e0d5f1e80938a19fbe837b5a1535cd80b60 (patch) | |
tree | f4b556d31ef4d6625370b30e29e99dcb724d319a /chrome_frame/test/chrome_frame_test_utils.cc | |
parent | 3782951259d8a3ab02c379754e6c55b622d2bc8e (diff) | |
download | chromium_src-cb4b1e0d5f1e80938a19fbe837b5a1535cd80b60.zip chromium_src-cb4b1e0d5f1e80938a19fbe837b5a1535cd80b60.tar.gz chromium_src-cb4b1e0d5f1e80938a19fbe837b5a1535cd80b60.tar.bz2 |
Added unit tests for ChromeFrame IE full tab mode. These test the following cases:-
1. A window.open call issued from a page within ChromeFrame in IE full tab mode makes it back
to IE before being shunted into Chrome.
2. Brings up the chrome frame context menu in full tab mode and invokes the About Chrome frame
option.
While I was working on these tests based on a lot of help from Stoyan, we had these tests use gmock
and I also changed the disallowed URL test to use gmock.
The other changes are to always run the chrome frame tests in the STA apartment as the newly added
full tab mode tests cannot handle calls coming in from background RPC worker threads.
Bug=26066,26172
Review URL: http://codereview.chromium.org/340029
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30520 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame/test/chrome_frame_test_utils.cc')
-rw-r--r-- | chrome_frame/test/chrome_frame_test_utils.cc | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/chrome_frame/test/chrome_frame_test_utils.cc b/chrome_frame/test/chrome_frame_test_utils.cc index 2b350dd..bd33db6 100644 --- a/chrome_frame/test/chrome_frame_test_utils.cc +++ b/chrome_frame/test/chrome_frame_test_utils.cc @@ -8,12 +8,14 @@ #include <atlwin.h> #include <iepmapi.h> +#include "base/message_loop.h" #include "base/registry.h" // to find IE and firefox #include "base/scoped_handle.h" #include "base/scoped_comptr_win.h" #include "base/string_util.h" #include "base/win_util.h" #include "chrome/common/chrome_switches.h" +#include "testing/gtest/include/gtest/gtest.h" namespace chrome_frame_test { @@ -412,4 +414,65 @@ int CloseAllIEWindows() { return ret; } +void ShowChromeFrameContextMenuTask() { + static const int kChromeFrameContextMenuTimeout = 500; + HWND renderer_window = GetChromeRendererWindow(); + EXPECT_TRUE(IsWindow(renderer_window)); + + // Bring up the context menu in the Chrome renderer window. + PostMessage(renderer_window, WM_RBUTTONDOWN, MK_RBUTTON, MAKELPARAM(50, 50)); + PostMessage(renderer_window, WM_RBUTTONUP, MK_RBUTTON, MAKELPARAM(50, 50)); + + MessageLoop::current()->PostDelayedTask( + FROM_HERE, + NewRunnableFunction(SelectAboutChromeFrame), + kChromeFrameContextMenuTimeout); +} + +void ShowChromeFrameContextMenu() { + static const int kContextMenuDelay = 5000; + + MessageLoop::current()->PostDelayedTask( + FROM_HERE, + NewRunnableFunction(ShowChromeFrameContextMenuTask), + kContextMenuDelay); +} + +void SelectAboutChromeFrame() { + // Send a key up message to enable the About chrome frame option to be + // selected followed by a return to select it. + chrome_frame_test::SendVirtualKey(VK_UP); + chrome_frame_test::SendVirtualKey(VK_RETURN); +} + +BOOL CALLBACK FindChromeRendererWindowProc( + HWND window, LPARAM lParam) { + HWND* target_window = reinterpret_cast<HWND*>(lParam); + wchar_t class_name[MAX_PATH] = {0}; + + GetClassName(window, class_name, arraysize(class_name)); + if (!_wcsicmp(class_name, L"Chrome_RenderWidgetHostHWND")) { + *target_window = window; + return FALSE; + } + + return TRUE; +} + +BOOL CALLBACK EnumHostBrowserWindowProc( + HWND window, LPARAM lParam) { + EnumChildWindows(window, FindChromeRendererWindowProc, lParam); + HWND* target_window = reinterpret_cast<HWND*>(lParam); + if (IsWindow(*target_window)) + return FALSE; + return TRUE; +} + +HWND GetChromeRendererWindow() { + HWND chrome_window = NULL; + EnumWindows(EnumHostBrowserWindowProc, + reinterpret_cast<LPARAM>(&chrome_window)); + return chrome_window; +} + } // namespace chrome_frame_test |