Index: chrome/test/render_view_test.cc |
diff --git a/chrome/test/render_view_test.cc b/chrome/test/render_view_test.cc |
index f920a2fa0e0cc73c1180a6843ad54ae9f2b529d8..d4eb90fd80f7410a3c243cabb04d045a40e8fd11 100644 |
--- a/chrome/test/render_view_test.cc |
+++ b/chrome/test/render_view_test.cc |
@@ -24,6 +24,10 @@ |
#include "third_party/WebKit/WebKit/chromium/public/WebView.h" |
#include "webkit/glue/webkit_glue.h" |
+#if defined(OS_LINUX) |
+#include "base/event_synthesis_gtk.h" |
+#endif |
+ |
using WebKit::WebFrame; |
using WebKit::WebScriptController; |
using WebKit::WebScriptSource; |
@@ -174,6 +178,39 @@ int RenderViewTest::SendKeyEvent(MockKeyboard::Layout layout, |
SendNativeKeyEvent(keyup_event); |
return length; |
+#elif defined(OS_LINUX) |
+ // We ignore |layout|, which means we are only testing the layout of the |
+ // current locale. TODO(estade): fix this to respect |layout|. |
+ std::vector<GdkEvent*> events; |
+ base::SynthesizeKeyPressEvents( |
+ NULL, static_cast<base::KeyboardCode>(key_code), |
+ modifiers & (MockKeyboard::LEFT_CONTROL | MockKeyboard::RIGHT_CONTROL), |
+ modifiers & (MockKeyboard::LEFT_SHIFT | MockKeyboard::RIGHT_SHIFT), |
+ modifiers & (MockKeyboard::LEFT_ALT | MockKeyboard::RIGHT_ALT), |
+ &events); |
+ |
+ guint32 unicode_key = 0; |
+ for (size_t i = 0; i < events.size(); ++i) { |
+ // Only send the up/down events for key press itself (skip the up/down |
+ // events for the modifier keys). |
+ if ((i + 1) == (events.size() / 2) || i == (events.size() / 2)) { |
+ unicode_key = gdk_keyval_to_unicode(events[i]->key.keyval); |
+ NativeWebKeyboardEvent webkit_event(&events[i]->key); |
+ SendNativeKeyEvent(webkit_event); |
+ |
+ // Need to add a char event after the key down. |
+ if (webkit_event.type == WebKit::WebInputEvent::RawKeyDown) { |
+ NativeWebKeyboardEvent char_event = webkit_event; |
+ char_event.type = WebKit::WebInputEvent::Char; |
+ char_event.skip_in_browser = true; |
+ SendNativeKeyEvent(char_event); |
+ } |
+ } |
+ gdk_event_free(events[i]); |
+ } |
+ |
+ *output = std::wstring(1, unicode_key); |
+ return 1; |
#else |
NOTIMPLEMENTED(); |
return L'\0'; |