OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 <cstring> | 5 #include <cstring> |
6 #include <set> | 6 #include <set> |
7 | 7 |
8 #include <X11/extensions/XInput2.h> | 8 #include <X11/extensions/XInput2.h> |
9 #include <X11/Xlib.h> | 9 #include <X11/Xlib.h> |
10 #include <X11/Xutil.h> | 10 #include <X11/Xutil.h> |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 | 208 |
209 InitButtonEvent(&event, false, location, 1, 0); | 209 InitButtonEvent(&event, false, location, 1, 0); |
210 { | 210 { |
211 MouseEvent mouseev(&event); | 211 MouseEvent mouseev(&event); |
212 EXPECT_EQ(ui::ET_MOUSE_RELEASED, mouseev.type()); | 212 EXPECT_EQ(ui::ET_MOUSE_RELEASED, mouseev.type()); |
213 EXPECT_EQ(i, mouseev.GetClickCount()); | 213 EXPECT_EQ(i, mouseev.GetClickCount()); |
214 } | 214 } |
215 } | 215 } |
216 } | 216 } |
217 | 217 |
218 #if defined(USE_XI2_MT) | |
219 TEST_F(EventsXTest, TouchEventBasic) { | 218 TEST_F(EventsXTest, TouchEventBasic) { |
220 std::vector<unsigned int> devices; | 219 std::vector<unsigned int> devices; |
221 devices.push_back(0); | 220 devices.push_back(0); |
222 ui::SetUpTouchDevicesForTest(devices); | 221 ui::SetUpTouchDevicesForTest(devices); |
223 std::vector<Valuator> valuators; | 222 std::vector<Valuator> valuators; |
224 | 223 |
225 // Init touch begin with tracking id 5, touch id 0. | 224 // Init touch begin with tracking id 5, touch id 0. |
226 valuators.push_back(Valuator(DeviceDataManagerX11::DT_TOUCH_MAJOR, 20)); | 225 valuators.push_back(Valuator(DeviceDataManagerX11::DT_TOUCH_MAJOR, 20)); |
227 valuators.push_back( | 226 valuators.push_back( |
228 Valuator(DeviceDataManagerX11::DT_TOUCH_ORIENTATION, 0.3f)); | 227 Valuator(DeviceDataManagerX11::DT_TOUCH_ORIENTATION, 0.3f)); |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 EXPECT_EQ(-1, GetTouchIdForTrackingId(kTrackingId1)); | 342 EXPECT_EQ(-1, GetTouchIdForTrackingId(kTrackingId1)); |
344 | 343 |
345 // This should clear the touch id of the first touch. | 344 // This should clear the touch id of the first touch. |
346 ui::ScopedXI2Event xrelease0; | 345 ui::ScopedXI2Event xrelease0; |
347 xrelease0.InitTouchEvent( | 346 xrelease0.InitTouchEvent( |
348 0, XI_TouchEnd, kTrackingId0, gfx::Point(10, 10), valuators); | 347 0, XI_TouchEnd, kTrackingId0, gfx::Point(10, 10), valuators); |
349 scoped_ptr<ui::TouchEvent> urelease0(new ui::TouchEvent(xrelease0)); | 348 scoped_ptr<ui::TouchEvent> urelease0(new ui::TouchEvent(xrelease0)); |
350 urelease0.reset(); | 349 urelease0.reset(); |
351 EXPECT_EQ(-1, GetTouchIdForTrackingId(kTrackingId0)); | 350 EXPECT_EQ(-1, GetTouchIdForTrackingId(kTrackingId0)); |
352 } | 351 } |
353 #endif | |
354 | 352 |
355 TEST_F(EventsXTest, NumpadKeyEvents) { | 353 TEST_F(EventsXTest, NumpadKeyEvents) { |
356 XEvent event; | 354 XEvent event; |
357 Display* display = gfx::GetXDisplay(); | 355 Display* display = gfx::GetXDisplay(); |
358 | 356 |
359 struct { | 357 struct { |
360 bool is_numpad_key; | 358 bool is_numpad_key; |
361 int x_keysym; | 359 int x_keysym; |
362 } keys[] = { | 360 } keys[] = { |
363 // XK_KP_Space and XK_KP_Equal are the extrema in the conventional | 361 // XK_KP_Space and XK_KP_Equal are the extrema in the conventional |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 EXPECT_TRUE(HasFunctionKeyFlagSetIfSupported(display, XK_F30)); | 499 EXPECT_TRUE(HasFunctionKeyFlagSetIfSupported(display, XK_F30)); |
502 EXPECT_TRUE(HasFunctionKeyFlagSetIfSupported(display, XK_F31)); | 500 EXPECT_TRUE(HasFunctionKeyFlagSetIfSupported(display, XK_F31)); |
503 EXPECT_TRUE(HasFunctionKeyFlagSetIfSupported(display, XK_F32)); | 501 EXPECT_TRUE(HasFunctionKeyFlagSetIfSupported(display, XK_F32)); |
504 EXPECT_TRUE(HasFunctionKeyFlagSetIfSupported(display, XK_F33)); | 502 EXPECT_TRUE(HasFunctionKeyFlagSetIfSupported(display, XK_F33)); |
505 EXPECT_TRUE(HasFunctionKeyFlagSetIfSupported(display, XK_F34)); | 503 EXPECT_TRUE(HasFunctionKeyFlagSetIfSupported(display, XK_F34)); |
506 EXPECT_TRUE(HasFunctionKeyFlagSetIfSupported(display, XK_F35)); | 504 EXPECT_TRUE(HasFunctionKeyFlagSetIfSupported(display, XK_F35)); |
507 // Max function key code plus 1. | 505 // Max function key code plus 1. |
508 EXPECT_FALSE(HasFunctionKeyFlagSetIfSupported(display, XK_F35 + 1)); | 506 EXPECT_FALSE(HasFunctionKeyFlagSetIfSupported(display, XK_F35 + 1)); |
509 } | 507 } |
510 | 508 |
511 #if defined(USE_XI2_MT) | |
512 // Verifies that the type of events from a disabled keyboard is ET_UNKNOWN, but | 509 // Verifies that the type of events from a disabled keyboard is ET_UNKNOWN, but |
513 // that an exception list of keys can still be processed. | 510 // that an exception list of keys can still be processed. |
514 TEST_F(EventsXTest, DisableKeyboard) { | 511 TEST_F(EventsXTest, DisableKeyboard) { |
515 DeviceDataManagerX11* device_data_manager = | 512 DeviceDataManagerX11* device_data_manager = |
516 static_cast<DeviceDataManagerX11*>( | 513 static_cast<DeviceDataManagerX11*>( |
517 DeviceDataManager::GetInstance()); | 514 DeviceDataManager::GetInstance()); |
518 unsigned int blocked_device_id = 1; | 515 unsigned int blocked_device_id = 1; |
519 unsigned int other_device_id = 2; | 516 unsigned int other_device_id = 2; |
520 unsigned int master_device_id = 3; | 517 unsigned int master_device_id = 3; |
521 device_data_manager->DisableDevice(blocked_device_id); | 518 device_data_manager->DisableDevice(blocked_device_id); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
590 xev.InitGenericButtonEvent(other_device_id, ET_MOUSE_PRESSED, gfx::Point(), | 587 xev.InitGenericButtonEvent(other_device_id, ET_MOUSE_PRESSED, gfx::Point(), |
591 EF_LEFT_MOUSE_BUTTON); | 588 EF_LEFT_MOUSE_BUTTON); |
592 EXPECT_EQ(ui::ET_MOUSE_PRESSED, ui::EventTypeFromNative(xev)); | 589 EXPECT_EQ(ui::ET_MOUSE_PRESSED, ui::EventTypeFromNative(xev)); |
593 | 590 |
594 device_data_manager->EnableDevice(blocked_device_id); | 591 device_data_manager->EnableDevice(blocked_device_id); |
595 | 592 |
596 xev.InitGenericButtonEvent(blocked_device_id, ET_MOUSE_PRESSED, gfx::Point(), | 593 xev.InitGenericButtonEvent(blocked_device_id, ET_MOUSE_PRESSED, gfx::Point(), |
597 EF_LEFT_MOUSE_BUTTON); | 594 EF_LEFT_MOUSE_BUTTON); |
598 EXPECT_EQ(ui::ET_MOUSE_PRESSED, ui::EventTypeFromNative(xev)); | 595 EXPECT_EQ(ui::ET_MOUSE_PRESSED, ui::EventTypeFromNative(xev)); |
599 } | 596 } |
600 #endif // defined(USE_XI2_MT) | |
601 | 597 |
602 #if !defined(OS_CHROMEOS) | 598 #if !defined(OS_CHROMEOS) |
603 TEST_F(EventsXTest, ImeFabricatedKeyEvents) { | 599 TEST_F(EventsXTest, ImeFabricatedKeyEvents) { |
604 Display* display = gfx::GetXDisplay(); | 600 Display* display = gfx::GetXDisplay(); |
605 | 601 |
606 unsigned int state_to_be_fabricated[] = { | 602 unsigned int state_to_be_fabricated[] = { |
607 0, ShiftMask, LockMask, ShiftMask | LockMask, | 603 0, ShiftMask, LockMask, ShiftMask | LockMask, |
608 }; | 604 }; |
609 for (size_t i = 0; i < arraysize(state_to_be_fabricated); ++i) { | 605 for (size_t i = 0; i < arraysize(state_to_be_fabricated); ++i) { |
610 unsigned int state = state_to_be_fabricated[i]; | 606 unsigned int state = state_to_be_fabricated[i]; |
(...skipping 22 matching lines...) Expand all Loading... |
633 KeyEventTestApi test_event(&key_event); | 629 KeyEventTestApi test_event(&key_event); |
634 test_event.set_is_char(true); | 630 test_event.set_is_char(true); |
635 } | 631 } |
636 EXPECT_FALSE(key_event.flags() & ui::EF_IME_FABRICATED_KEY); | 632 EXPECT_FALSE(key_event.flags() & ui::EF_IME_FABRICATED_KEY); |
637 } | 633 } |
638 } | 634 } |
639 } | 635 } |
640 #endif | 636 #endif |
641 | 637 |
642 } // namespace ui | 638 } // namespace ui |
OLD | NEW |