diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-18 02:16:21 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-18 02:16:21 +0000 |
commit | 22cdd93852c8f0782cb86b066cfcd95a9121912b (patch) | |
tree | be0f742437de0f4bd0e9753270c22998d02fd947 /chrome/browser/automation/ui_controls_linux.cc | |
parent | d3eb7bb27945410cb5d1f5d84f15f9c7017d519e (diff) | |
download | chromium_src-22cdd93852c8f0782cb86b066cfcd95a9121912b.zip chromium_src-22cdd93852c8f0782cb86b066cfcd95a9121912b.tar.gz chromium_src-22cdd93852c8f0782cb86b066cfcd95a9121912b.tar.bz2 |
more linux automation porting: SendKeyPressNotifyWhenDone
also change the interface for SimulateOSKeyPress()/SendKeyPress() to take a VKEY_ value (defined in base/keyboard_codes.h) rather than a VK_ value.
BUG=19076
Review URL: http://codereview.chromium.org/171079
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23611 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/automation/ui_controls_linux.cc')
-rw-r--r-- | chrome/browser/automation/ui_controls_linux.cc | 47 |
1 files changed, 34 insertions, 13 deletions
diff --git a/chrome/browser/automation/ui_controls_linux.cc b/chrome/browser/automation/ui_controls_linux.cc index e369ec7..53ba6fd 100644 --- a/chrome/browser/automation/ui_controls_linux.cc +++ b/chrome/browser/automation/ui_controls_linux.cc @@ -8,26 +8,45 @@ #include <gdk/gdkkeysyms.h> #include "base/logging.h" +#include "base/message_loop.h" #include "chrome/test/automation/automation_constants.h" namespace { -int GdkKeycodeForWindowsKeycode(wchar_t windows_keyval) { - switch (windows_keyval) { - case VK_SPACE: - return GDK_space; - default: - NOTREACHED() << "Unsupported keyval: " << windows_keyval; - return 0; +class EventWaiter : public MessageLoopForUI::Observer { + public: + EventWaiter(Task* task, GdkEventType type) : task_(task), type_(type) { + MessageLoopForUI::current()->AddObserver(this); + } + + virtual ~EventWaiter() { + MessageLoopForUI::current()->RemoveObserver(this); } -} -} // namespace + // MessageLoop::Observer implementation: + virtual void WillProcessEvent(GdkEvent* event) { + // No-op. + } + + virtual void DidProcessEvent(GdkEvent* event) { + if (event->any.type == type_) { + task_->Run(); + delete this; + } + } + + private: + Task* task_; + GdkEventType type_; +}; + +} namespace ui_controls { bool SendKeyPress(gfx::NativeWindow window, wchar_t key, bool control, bool shift, bool alt) { + // TODO(estade): send a release as well? GdkEvent* event = gdk_event_new(GDK_KEY_PRESS); event->key.type = GDK_KEY_PRESS; @@ -41,7 +60,7 @@ bool SendKeyPress(gfx::NativeWindow window, event->key.state = (control ? GDK_CONTROL_MASK : 0) | (shift ? GDK_SHIFT_MASK : 0) | (alt ? GDK_MOD1_MASK : 0); - event->key.keyval = GdkKeycodeForWindowsKeycode(key); + event->key.keyval = key; // TODO(estade): fill in the string? GdkKeymapKey* keys; @@ -60,10 +79,12 @@ bool SendKeyPress(gfx::NativeWindow window, return true; } -bool SendKeyPressNotifyWhenDone(wchar_t key, bool control, bool shift, +bool SendKeyPressNotifyWhenDone(gfx::NativeWindow window, wchar_t key, + bool control, bool shift, bool alt, Task* task) { - NOTIMPLEMENTED(); - return false; + // This object will delete itself after running |task|. + new EventWaiter(task, GDK_KEY_PRESS); + return SendKeyPress(window, key, control, shift, alt); } // TODO(estade): this appears to be unused on Windows. Can we remove it? |