diff options
author | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-30 21:10:01 +0000 |
---|---|---|
committer | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-30 21:10:01 +0000 |
commit | f544609583f22d951879060acabe02a49be5fe06 (patch) | |
tree | f691b0ff19eeec3ede89484e87a4056ce48b04ee /chrome/browser | |
parent | 6832cb1bcd81ed22537028d9fe5b108ffe345d41 (diff) | |
download | chromium_src-f544609583f22d951879060acabe02a49be5fe06.zip chromium_src-f544609583f22d951879060acabe02a49be5fe06.tar.gz chromium_src-f544609583f22d951879060acabe02a49be5fe06.tar.bz2 |
Add support for moving the mouse so that GetMessagePos would notice.
R=pkasting
BUG=18079
TEST=covered by TabDraggingTest.Tab2OutOfTabStrip
Review URL: http://codereview.chromium.org/160412
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22097 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/automation/automation_provider.cc | 29 | ||||
-rw-r--r-- | chrome/browser/views/tabs/tab_dragging_test.cc | 2 |
2 files changed, 26 insertions, 5 deletions
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc index 67ee526..d3d8cce 100644 --- a/chrome/browser/automation/automation_provider.cc +++ b/chrome/browser/automation/automation_provider.cc @@ -74,6 +74,27 @@ using base::Time; +#if defined(OS_WIN) +static void MoveMouse(const POINT& point) { + SetCursorPos(point.x, point.y); + + // Now, make sure that GetMessagePos returns the values we just set by + // simulating a mouse move. The value returned by GetMessagePos is updated + // when a mouse move event is removed from the event queue. + PostMessage(NULL, WM_MOUSEMOVE, 0, MAKELPARAM(point.x, point.y)); + MSG msg; + while (PeekMessage(&msg, NULL, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_REMOVE)) + ; + + // Verify +#ifndef NDEBUG + DWORD pos = GetMessagePos(); + DCHECK_EQ(point.x, GET_X_LPARAM(pos)); + DCHECK_EQ(point.y, GET_Y_LPARAM(pos)); +#endif +} +#endif + class InitialLoadObserver : public NotificationObserver { public: InitialLoadObserver(size_t tab_count, AutomationProvider* automation) @@ -1504,7 +1525,7 @@ class MouseEventTask : public Task { // monitors, so this only works reliably in a single monitor setup. gfx::Point screen_location(point_.x, point_.y); view_->ConvertPointToScreen(view_, &screen_location); - ::SetCursorPos(screen_location.x(), screen_location.y()); + MoveMouse(screen_location.ToPOINT()); switch (type_) { case views::Event::ET_MOUSE_PRESSED: view_->OnMousePressed(event); @@ -1652,19 +1673,19 @@ void AutomationProvider::WindowSimulateDrag(int handle, reinterpret_cast<HWND>(browser->window()->GetNativeHandle()); POINT temp = drag_path[0]; MapWindowPoints(top_level_hwnd, HWND_DESKTOP, &temp, 1); - SetCursorPos(temp.x, temp.y); + MoveMouse(temp); SendMessage(top_level_hwnd, down_message, wparam_flags, MAKELPARAM(drag_path[0].x, drag_path[0].y)); for (int i = 1; i < static_cast<int>(drag_path.size()); ++i) { temp = drag_path[i]; MapWindowPoints(top_level_hwnd, HWND_DESKTOP, &temp, 1); - SetCursorPos(temp.x, temp.y); + MoveMouse(temp); SendMessage(top_level_hwnd, WM_MOUSEMOVE, wparam_flags, MAKELPARAM(drag_path[i].x, drag_path[i].y)); } POINT end = drag_path[drag_path.size() - 1]; MapWindowPoints(top_level_hwnd, HWND_DESKTOP, &end, 1); - SetCursorPos(end.x, end.y); + MoveMouse(end); if (press_escape_en_route) { // Press Escape. diff --git a/chrome/browser/views/tabs/tab_dragging_test.cc b/chrome/browser/views/tabs/tab_dragging_test.cc index bf2653d..e187e71 100644 --- a/chrome/browser/views/tabs/tab_dragging_test.cc +++ b/chrome/browser/views/tabs/tab_dragging_test.cc @@ -346,7 +346,7 @@ TEST_F(TabDraggingTest, Tab1Tab3Escape) { } // Drag Tab_2 out of the Tab strip. A new window should open with this tab. -TEST_F(TabDraggingTest, DISABLED_Tab2OutOfTabStrip) { +TEST_F(TabDraggingTest, Tab2OutOfTabStrip) { scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); ASSERT_TRUE(browser.get()); scoped_refptr<WindowProxy> window(browser->GetWindow()); |