Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(474)

Unified Diff: chrome/browser/automation/ui_controls_linux.cc

Issue 171079: more linux automation porting: SendKeyPressNotifyWhenDone... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/automation/ui_controls.h ('k') | chrome/browser/automation/ui_controls_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/automation/ui_controls_linux.cc
===================================================================
--- chrome/browser/automation/ui_controls_linux.cc (revision 23591)
+++ chrome/browser/automation/ui_controls_linux.cc (working copy)
@@ -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);
+ }
+
+ // 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
-
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 @@
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 @@
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?
« no previous file with comments | « chrome/browser/automation/ui_controls.h ('k') | chrome/browser/automation/ui_controls_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698