diff options
author | joi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-06 12:23:48 +0000 |
---|---|---|
committer | joi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-06 12:23:48 +0000 |
commit | ccf2231b71685fedbd0a9effdce6875a77a27ccc (patch) | |
tree | 34c4eb7684a25adad0c690b60026fa9f9891ee01 | |
parent | 1def7bde8cb1b33e7cc033aef1881b64505a7447 (diff) | |
download | chromium_src-ccf2231b71685fedbd0a9effdce6875a77a27ccc.zip chromium_src-ccf2231b71685fedbd0a9effdce6875a77a27ccc.tar.gz chromium_src-ccf2231b71685fedbd0a9effdce6875a77a27ccc.tar.bz2 |
Revert 113183 - Revert 113177 - process all ui events before posting closure because menu depends on ui events to quit.
Add new RunClosureAfterAllPendingUIEvents for toolkit views.
BUG=104359
TEST=BookmarkBarViewTest in interactive_ui_tests will pass
Review URL: http://codereview.chromium.org/8799020
Reason for revert: http://build.chromium.org/p/chromium.chromiumos/builders/Linux%20ChromeOS%20Aura/builds/1514
Reason for un-revert: The test succeeded before the original revert, looks like it's just flaky.
TBR=oshima@chromium.org
Review URL: http://codereview.chromium.org/8821012
TBR=joi@chromium.org
Review URL: http://codereview.chromium.org/8820010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@113189 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/automation/ui_controls.h | 5 | ||||
-rw-r--r-- | chrome/browser/automation/ui_controls_aurawin.cc | 6 | ||||
-rw-r--r-- | chrome/browser/automation/ui_controls_aurax11.cc | 42 | ||||
-rw-r--r-- | chrome/browser/automation/ui_controls_gtk.cc | 9 | ||||
-rw-r--r-- | chrome/browser/automation/ui_controls_internal.h | 1 | ||||
-rw-r--r-- | chrome/browser/automation/ui_controls_win.cc | 6 | ||||
-rw-r--r-- | chrome/test/base/view_event_test_base.cc | 8 |
7 files changed, 52 insertions, 25 deletions
diff --git a/chrome/browser/automation/ui_controls.h b/chrome/browser/automation/ui_controls.h index 19e215a..270e18d 100644 --- a/chrome/browser/automation/ui_controls.h +++ b/chrome/browser/automation/ui_controls.h @@ -97,6 +97,11 @@ void MoveMouseToCenterAndPress( int state, const base::Closure& task); +#if defined(TOOLKIT_VIEWS) +// Runs |closure| after processing all pending ui events. +void RunClosureAfterAllPendingUIEvents(const base::Closure& closure); +#endif + } // ui_controls #endif // CHROME_BROWSER_AUTOMATION_UI_CONTROLS_H_ diff --git a/chrome/browser/automation/ui_controls_aurawin.cc b/chrome/browser/automation/ui_controls_aurawin.cc index 50e5f87..31c92b4 100644 --- a/chrome/browser/automation/ui_controls_aurawin.cc +++ b/chrome/browser/automation/ui_controls_aurawin.cc @@ -5,6 +5,7 @@ #include "chrome/browser/automation/ui_controls.h" #include "base/logging.h" +#include "base/message_loop.h" #include "chrome/browser/automation/ui_controls_internal.h" #include "ui/aura/desktop.h" #include "ui/views/view.h" @@ -69,4 +70,9 @@ void MoveMouseToCenterAndPress(views::View* view, SendMouseEventsNotifyWhenDone(button, state, task); } +void RunClosureAfterAllPendingUIEvents(const base::Closure& task) { + // On windows, posting UI events is synchronous so just post the closure. + MessageLoopForUI::current()->PostTask(FROM_HERE, task); +} + } // namespace ui_controls diff --git a/chrome/browser/automation/ui_controls_aurax11.cc b/chrome/browser/automation/ui_controls_aurax11.cc index d7dbe69..20c4c17 100644 --- a/chrome/browser/automation/ui_controls_aurax11.cc +++ b/chrome/browser/automation/ui_controls_aurax11.cc @@ -70,22 +70,6 @@ bool Matcher(const base::NativeEvent& event) { event->xclient.message_type == MarkerEventAtom(); } -void RunClosureAfterEvents(const base::Closure closure) { - if (closure.is_null()) - return; - static XEvent* marker_event = NULL; - if (!marker_event) { - marker_event = new XEvent(); - marker_event->xclient.type = ClientMessage; - marker_event->xclient.display = NULL; - marker_event->xclient.window = None; - marker_event->xclient.format = 8; - } - marker_event->xclient.message_type = MarkerEventAtom(); - aura::Desktop::GetInstance()->PostNativeEvent(marker_event); - new EventWaiter(closure, &Matcher); -} - } // namespace namespace ui_controls { @@ -133,9 +117,7 @@ bool SendKeyPressNotifyWhenDone(gfx::NativeWindow window, SetMaskAndKeycodeThenSend(&xevent, ShiftMask, XK_Shift_L); if (alt) SetMaskAndKeycodeThenSend(&xevent, Mod1Mask, XK_Alt_L); - xevent.xkey.keycode = - XKeysymToKeycode(base::MessagePumpX::GetDefaultXDisplay(), - ui::XKeysymForWindowsKeyCode(key, shift)); + xevent.xkey.keycode = ui::XKeysymForWindowsKeyCode(key, shift); aura::Desktop::GetInstance()->PostNativeEvent(&xevent); // Send key release events. @@ -148,7 +130,7 @@ bool SendKeyPressNotifyWhenDone(gfx::NativeWindow window, if (control) SetKeycodeAndSendThenUnmask(&xevent, ControlMask, XK_Control_L); DCHECK(!xevent.xkey.state); - RunClosureAfterEvents(closure); + RunClosureAfterAllPendingUIEvents(closure); return true; } @@ -165,7 +147,7 @@ bool SendMouseMoveNotifyWhenDone(long x, long y, const base::Closure& closure) { xmotion->same_screen = True; // Desktop will take care of other necessary fields. aura::Desktop::GetInstance()->PostNativeEvent(&xevent); - RunClosureAfterEvents(closure); + RunClosureAfterAllPendingUIEvents(closure); return false; } @@ -208,7 +190,7 @@ bool SendMouseEventsNotifyWhenDone(MouseButton type, xevent.xbutton.type = ButtonRelease; desktop->PostNativeEvent(&xevent); } - RunClosureAfterEvents(closure); + RunClosureAfterAllPendingUIEvents(closure); return false; } @@ -226,4 +208,20 @@ void MoveMouseToCenterAndPress(views::View* view, MouseButton button, SendMouseEventsNotifyWhenDone(button, state, closure); } +void RunClosureAfterAllPendingUIEvents(const base::Closure& closure) { + if (closure.is_null()) + return; + static XEvent* marker_event = NULL; + if (!marker_event) { + marker_event = new XEvent(); + marker_event->xclient.type = ClientMessage; + marker_event->xclient.display = NULL; + marker_event->xclient.window = None; + marker_event->xclient.format = 8; + } + marker_event->xclient.message_type = MarkerEventAtom(); + aura::Desktop::GetInstance()->PostNativeEvent(marker_event); + new EventWaiter(closure, &Matcher); +} + } // namespace ui_controls diff --git a/chrome/browser/automation/ui_controls_gtk.cc b/chrome/browser/automation/ui_controls_gtk.cc index 32e3100..8826609 100644 --- a/chrome/browser/automation/ui_controls_gtk.cc +++ b/chrome/browser/automation/ui_controls_gtk.cc @@ -310,4 +310,13 @@ void MoveMouseToCenterAndPress(GtkWidget* widget, } #endif +#if defined(TOOLKIT_VIEWS) +void RunClosureAfterAllPendingUIEvents(const base::Closure& task) { + // Send noop event and run task. + int x, y; + gdk_window_at_pointer(&x, &y); + SendMouseMoveNotifyWhenDone(x, y, task); +} +#endif + } // namespace ui_controls diff --git a/chrome/browser/automation/ui_controls_internal.h b/chrome/browser/automation/ui_controls_internal.h index cf87d49..e0f5a78 100644 --- a/chrome/browser/automation/ui_controls_internal.h +++ b/chrome/browser/automation/ui_controls_internal.h @@ -27,6 +27,7 @@ bool SendMouseMoveImpl(long x, long y, const base::Closure& task); bool SendMouseEventsImpl(MouseButton type, int state, const base::Closure& task); +void RunClosureAfterAllPendingUITasksImpl(const base::Closure& task); #endif } // namespace internal diff --git a/chrome/browser/automation/ui_controls_win.cc b/chrome/browser/automation/ui_controls_win.cc index 5d2c873..744928f 100644 --- a/chrome/browser/automation/ui_controls_win.cc +++ b/chrome/browser/automation/ui_controls_win.cc @@ -5,6 +5,7 @@ #include "chrome/browser/automation/ui_controls.h" #include "base/callback.h" +#include "base/message_loop.h" #include "chrome/browser/automation/ui_controls_internal.h" #include "ui/gfx/point.h" #include "ui/views/view.h" @@ -65,4 +66,9 @@ void MoveMouseToCenterAndPress(views::View* view, SendMouseEventsNotifyWhenDone(button, state, task); } +void RunClosureAfterAllPendingUIEvents(const base::Closure& closure) { + // On windows, posting UI events is synchronous so just post the closure. + MessageLoopForUI::current()->PostTask(FROM_HERE, closure); +} + } // ui_controls diff --git a/chrome/test/base/view_event_test_base.cc b/chrome/test/base/view_event_test_base.cc index f370e3d..facfd59 100644 --- a/chrome/test/base/view_event_test_base.cc +++ b/chrome/test/base/view_event_test_base.cc @@ -70,9 +70,11 @@ void ViewEventTestBase::Done() { PostMessage(window_->GetNativeWindow(), WM_USER, 0, 0); #endif - // If we're in a nested message loop, as is the case with menus, we need - // to quit twice. The second quit does that for us. - MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); + // If we're in a nested message loop, as is the case with menus, we + // need to quit twice. The second quit does that for us. Finish all + // pending UI events before posting closure because events it may be + // executed before UI events are executed. + ui_controls::RunClosureAfterAllPendingUIEvents(MessageLoop::QuitClosure()); } void ViewEventTestBase::SetUp() { |