OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "content/browser/renderer_host/web_input_event_aura.h" |
| 6 |
| 7 #include "base/basictypes.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 #include "ui/aura/event.h" |
| 10 |
| 11 #if defined(USE_X11) |
| 12 #include <X11/Xlib.h> |
| 13 #include "ui/base/x/x11_util.h" |
| 14 #endif |
| 15 |
| 16 namespace content { |
| 17 |
| 18 // Checks that MakeWebKeyboardEvent makes a DOM3 spec compliant key event. |
| 19 // crbug.com/127142 |
| 20 TEST(WebInputEventAuraTest, TestMakeWebKeyboardEvent) { |
| 21 #if defined(USE_X11) |
| 22 XEvent xev; |
| 23 { |
| 24 // Press Ctrl. |
| 25 ui::InitXKeyEventForTesting(ui::ET_KEY_PRESSED, |
| 26 ui::VKEY_CONTROL, |
| 27 0, // X does not set ControlMask for KeyPress. |
| 28 &xev); |
| 29 aura::KeyEvent event(&xev, false /* is_char */); |
| 30 WebKit::WebKeyboardEvent webkit_event = MakeWebKeyboardEvent(&event); |
| 31 // However, modifier bit for Control in |webkit_event| should be set. |
| 32 EXPECT_EQ(webkit_event.modifiers, WebKit::WebInputEvent::ControlKey); |
| 33 } |
| 34 { |
| 35 // Release Ctrl. |
| 36 ui::InitXKeyEventForTesting(ui::ET_KEY_RELEASED, |
| 37 ui::VKEY_CONTROL, |
| 38 ControlMask, // X sets the mask for KeyRelease. |
| 39 &xev); |
| 40 aura::KeyEvent event(&xev, false /* is_char */); |
| 41 WebKit::WebKeyboardEvent webkit_event = MakeWebKeyboardEvent(&event); |
| 42 // However, modifier bit for Control in |webkit_event| shouldn't be set. |
| 43 EXPECT_EQ(webkit_event.modifiers, 0); |
| 44 } |
| 45 #endif |
| 46 } |
| 47 |
| 48 } // namespace content |
OLD | NEW |