| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/events/platform/platform_event_builder.h" | 5 #include "ui/events/platform/platform_event_builder.h" |
| 6 | 6 |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 #include "ui/events/event.h" | 8 #include "ui/events/event.h" |
| 9 #include "ui/events/keycodes/dom4/keycode_converter.h" | 9 #include "ui/events/keycodes/dom4/keycode_converter.h" |
| 10 #include "ui/events/platform/x11/device_data_manager_x11.h" | 10 #include "ui/events/platform/x11/device_data_manager_x11.h" |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 ScopedXI2Event native_event_a_released; | 97 ScopedXI2Event native_event_a_released; |
| 98 native_event_a_released.InitKeyEvent(ET_KEY_RELEASED, VKEY_A, kNativeCodeA); | 98 native_event_a_released.InitKeyEvent(ET_KEY_RELEASED, VKEY_A, kNativeCodeA); |
| 99 ScopedXI2Event native_event_b_pressed; | 99 ScopedXI2Event native_event_b_pressed; |
| 100 native_event_b_pressed.InitKeyEvent(ET_KEY_PRESSED, VKEY_B, kNativeCodeB); | 100 native_event_b_pressed.InitKeyEvent(ET_KEY_PRESSED, VKEY_B, kNativeCodeB); |
| 101 ScopedXI2Event native_event_a_pressed_nonstandard_state; | 101 ScopedXI2Event native_event_a_pressed_nonstandard_state; |
| 102 native_event_a_pressed_nonstandard_state.InitKeyEvent(ET_KEY_PRESSED, VKEY_A, | 102 native_event_a_pressed_nonstandard_state.InitKeyEvent(ET_KEY_PRESSED, VKEY_A, |
| 103 kNativeCodeA); | 103 kNativeCodeA); |
| 104 // IBUS-GTK uses the mask (1 << 25) to detect reposted event. | 104 // IBUS-GTK uses the mask (1 << 25) to detect reposted event. |
| 105 static_cast<XEvent*>(native_event_a_pressed_nonstandard_state)->xkey.state |= | 105 static_cast<XEvent*>(native_event_a_pressed_nonstandard_state)->xkey.state |= |
| 106 1 << 25; | 106 1 << 25; |
| 107 #elif defined(OS_WIN) | |
| 108 const LPARAM lParam_a = GetLParamFromScanCode(kNativeCodeA); | |
| 109 const LPARAM lParam_b = GetLParamFromScanCode(kNativeCodeB); | |
| 110 MSG native_event_a_pressed = {NULL, WM_KEYDOWN, VKEY_A, lParam_a}; | |
| 111 MSG native_event_a_released = {NULL, WM_KEYUP, VKEY_A, lParam_a}; | |
| 112 MSG native_event_b_pressed = {NULL, WM_KEYUP, VKEY_B, lParam_b}; | |
| 113 #endif | 107 #endif |
| 114 KeyEvent key_a1 = PlatformEventBuilder::BuildKeyEvent(native_event_a_pressed); | 108 KeyEvent key_a1 = PlatformEventBuilder::BuildKeyEvent(native_event_a_pressed); |
| 115 EXPECT_FALSE(key_a1.IsRepeat()); | 109 EXPECT_FALSE(key_a1.IsRepeat()); |
| 116 KeyEvent key_a1_released = | 110 KeyEvent key_a1_released = |
| 117 PlatformEventBuilder::BuildKeyEvent(native_event_a_released); | 111 PlatformEventBuilder::BuildKeyEvent(native_event_a_released); |
| 118 EXPECT_FALSE(key_a1_released.IsRepeat()); | 112 EXPECT_FALSE(key_a1_released.IsRepeat()); |
| 119 | 113 |
| 120 KeyEvent key_a2 = PlatformEventBuilder::BuildKeyEvent(native_event_a_pressed); | 114 KeyEvent key_a2 = PlatformEventBuilder::BuildKeyEvent(native_event_a_pressed); |
| 121 EXPECT_FALSE(key_a2.IsRepeat()); | 115 EXPECT_FALSE(key_a2.IsRepeat()); |
| 122 KeyEvent key_a2_repeated = | 116 KeyEvent key_a2_repeated = |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 | 235 |
| 242 native_event.InitGenericButtonEvent(device_id, ET_MOUSE_PRESSED, origin, | 236 native_event.InitGenericButtonEvent(device_id, ET_MOUSE_PRESSED, origin, |
| 243 EF_LEFT_MOUSE_BUTTON); | 237 EF_LEFT_MOUSE_BUTTON); |
| 244 event = PlatformEventBuilder::BuildMouseEvent(native_event); | 238 event = PlatformEventBuilder::BuildMouseEvent(native_event); |
| 245 event.set_time_stamp(start); | 239 event.set_time_stamp(start); |
| 246 EXPECT_EQ(2, PlatformEventBuilder::GetRepeatCount(native_event, event)); | 240 EXPECT_EQ(2, PlatformEventBuilder::GetRepeatCount(native_event, event)); |
| 247 PlatformEventBuilder::ResetLastClickForTest(); | 241 PlatformEventBuilder::ResetLastClickForTest(); |
| 248 } | 242 } |
| 249 | 243 |
| 250 } // namespace ui | 244 } // namespace ui |
| OLD | NEW |