IndexedDBFactory now ForceCloses databases.
[chromium-blink-merge.git] / content / browser / renderer_host / web_input_event_aura_unittest.cc
blobd67d0cd22780fa356b3a93d64fedcd2ce9bd5e46
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.
5 #include "content/browser/renderer_host/web_input_event_aura.h"
7 #include "base/basictypes.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "ui/events/event.h"
11 #if defined(USE_X11)
12 #include <X11/keysym.h>
13 #include <X11/Xlib.h>
14 #include "ui/events/test/events_test_utils_x11.h"
15 #include "ui/gfx/x/x11_types.h"
16 #endif
18 namespace content {
20 // Checks that MakeWebKeyboardEvent makes a DOM3 spec compliant key event.
21 // crbug.com/127142
22 TEST(WebInputEventAuraTest, TestMakeWebKeyboardEvent) {
23 #if defined(USE_X11)
24 ui::ScopedXI2Event xev;
26 // Press Ctrl.
27 xev.InitKeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_CONTROL, 0);
28 ui::KeyEvent event(xev, false /* is_char */);
29 blink::WebKeyboardEvent webkit_event = MakeWebKeyboardEvent(&event);
30 // However, modifier bit for Control in |webkit_event| should be set.
31 EXPECT_EQ(webkit_event.modifiers, blink::WebInputEvent::ControlKey);
34 // Release Ctrl.
35 xev.InitKeyEvent(ui::ET_KEY_RELEASED, ui::VKEY_CONTROL, ControlMask);
36 ui::KeyEvent event(xev, false /* is_char */);
37 blink::WebKeyboardEvent webkit_event = MakeWebKeyboardEvent(&event);
38 // However, modifier bit for Control in |webkit_event| shouldn't be set.
39 EXPECT_EQ(webkit_event.modifiers, 0);
41 #endif
44 // Checks that MakeWebKeyboardEvent returns a correct windowsKeyCode.
45 TEST(WebInputEventAuraTest, TestMakeWebKeyboardEventWindowsKeyCode) {
46 #if defined(USE_X11)
47 ui::ScopedXI2Event xev;
49 // Press left Ctrl.
50 xev.InitKeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_CONTROL, 0);
51 XEvent* xevent = xev;
52 xevent->xkey.keycode = XKeysymToKeycode(gfx::GetXDisplay(), XK_Control_L);
53 ui::KeyEvent event(xev, false /* is_char */);
54 blink::WebKeyboardEvent webkit_event = MakeWebKeyboardEvent(&event);
55 // ui::VKEY_LCONTROL, instead of ui::VKEY_CONTROL, should be filled.
56 EXPECT_EQ(ui::VKEY_LCONTROL, webkit_event.windowsKeyCode);
59 // Press right Ctrl.
60 xev.InitKeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_CONTROL, 0);
61 XEvent* xevent = xev;
62 xevent->xkey.keycode = XKeysymToKeycode(gfx::GetXDisplay(), XK_Control_R);
63 ui::KeyEvent event(xev, false /* is_char */);
64 blink::WebKeyboardEvent webkit_event = MakeWebKeyboardEvent(&event);
65 // ui::VKEY_RCONTROL, instead of ui::VKEY_CONTROL, should be filled.
66 EXPECT_EQ(ui::VKEY_RCONTROL, webkit_event.windowsKeyCode);
68 #elif defined(OS_WIN)
69 // TODO(yusukes): Add tests for win_aura once keyboardEvent() in
70 // third_party/WebKit/Source/web/win/WebInputEventFactory.cpp is modified
71 // to return VKEY_[LR]XXX instead of VKEY_XXX.
72 // https://bugs.webkit.org/show_bug.cgi?id=86694
73 #endif
76 } // namespace content