| 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 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 // tracking id. | 346 // tracking id. |
| 347 ui::ScopedXI2Event xrelease1; | 347 ui::ScopedXI2Event xrelease1; |
| 348 xrelease1.InitTouchEvent( | 348 xrelease1.InitTouchEvent( |
| 349 0, XI_TouchEnd, kTrackingId, gfx::Point(10, 10), valuators); | 349 0, XI_TouchEnd, kTrackingId, gfx::Point(10, 10), valuators); |
| 350 { | 350 { |
| 351 ui::TouchEvent urelease1(xrelease1); | 351 ui::TouchEvent urelease1(xrelease1); |
| 352 } | 352 } |
| 353 EXPECT_EQ(-1, GetTouchIdForTrackingId(kTrackingId)); | 353 EXPECT_EQ(-1, GetTouchIdForTrackingId(kTrackingId)); |
| 354 } | 354 } |
| 355 | 355 |
| 356 // Copied events should not remove native touch id mappings, as this causes a |
| 357 // crash (crbug.com/467102). Copied events do not contain a proper |
| 358 // base::NativeEvent and should not attempt to access it. |
| 359 TEST_F(EventsXTest, CopiedTouchEventNotRemovingFromNativeMapping) { |
| 360 std::vector<unsigned int> devices; |
| 361 devices.push_back(0); |
| 362 ui::SetUpTouchDevicesForTest(devices); |
| 363 std::vector<Valuator> valuators; |
| 364 |
| 365 // Create a release event which has a native touch id mapping. |
| 366 ui::ScopedXI2Event xrelease0; |
| 367 xrelease0.InitTouchEvent(0, XI_TouchEnd, 0, gfx::Point(10, 10), valuators); |
| 368 ui::TouchEvent urelease0(xrelease0); |
| 369 { |
| 370 // When the copy is destructed it should not attempt to remove the mapping. |
| 371 // Exiting this scope should not cause a crash. |
| 372 ui::TouchEvent copy = urelease0; |
| 373 } |
| 374 } |
| 375 |
| 356 TEST_F(EventsXTest, NumpadKeyEvents) { | 376 TEST_F(EventsXTest, NumpadKeyEvents) { |
| 357 XEvent event; | 377 XEvent event; |
| 358 Display* display = gfx::GetXDisplay(); | 378 Display* display = gfx::GetXDisplay(); |
| 359 | 379 |
| 360 struct { | 380 struct { |
| 361 bool is_numpad_key; | 381 bool is_numpad_key; |
| 362 int x_keysym; | 382 int x_keysym; |
| 363 } keys[] = { | 383 } keys[] = { |
| 364 // XK_KP_Space and XK_KP_Equal are the extrema in the conventional | 384 // XK_KP_Space and XK_KP_Equal are the extrema in the conventional |
| 365 // keysymdef.h numbering. | 385 // keysymdef.h numbering. |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 631 KeyEventTestApi test_event(&key_event); | 651 KeyEventTestApi test_event(&key_event); |
| 632 test_event.set_is_char(true); | 652 test_event.set_is_char(true); |
| 633 } | 653 } |
| 634 EXPECT_FALSE(key_event.flags() & ui::EF_IME_FABRICATED_KEY); | 654 EXPECT_FALSE(key_event.flags() & ui::EF_IME_FABRICATED_KEY); |
| 635 } | 655 } |
| 636 } | 656 } |
| 637 } | 657 } |
| 638 #endif | 658 #endif |
| 639 | 659 |
| 640 } // namespace ui | 660 } // namespace ui |
| OLD | NEW |