| 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 "ui/events/event.h" | 5 #include "ui/events/event.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 | 11 |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 #include "ui/events/event_utils.h" | 15 #include "ui/events/event_utils.h" |
| 16 #include "ui/events/keycodes/dom/dom_code.h" | 16 #include "ui/events/keycodes/dom/dom_code.h" |
| 17 #include "ui/events/keycodes/dom/keycode_converter.h" | 17 #include "ui/events/keycodes/dom/keycode_converter.h" |
| 18 #include "ui/events/test/events_test_utils.h" | 18 #include "ui/events/test/events_test_utils.h" |
| 19 #include "ui/gfx/transform.h" |
| 19 | 20 |
| 20 #if defined(USE_X11) | 21 #if defined(USE_X11) |
| 21 #include <X11/Xlib.h> | 22 #include <X11/Xlib.h> |
| 22 #include "ui/events/test/events_test_utils_x11.h" | 23 #include "ui/events/test/events_test_utils_x11.h" |
| 23 #include "ui/gfx/x/x11_types.h" // nogncheck | 24 #include "ui/gfx/x/x11_types.h" // nogncheck |
| 24 #endif | 25 #endif |
| 25 | 26 |
| 26 namespace ui { | 27 namespace ui { |
| 27 | 28 |
| 28 TEST(EventTest, NoNativeEvent) { | 29 TEST(EventTest, NoNativeEvent) { |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 | 419 |
| 419 MSG native_event = { NULL, WM_KEYUP, VKEY_HOME, lParam }; | 420 MSG native_event = { NULL, WM_KEYUP, VKEY_HOME, lParam }; |
| 420 KeyEvent key(native_event); | 421 KeyEvent key(native_event); |
| 421 | 422 |
| 422 // KeyEvent converts from the native keycode (scan code) to the code. | 423 // KeyEvent converts from the native keycode (scan code) to the code. |
| 423 EXPECT_EQ(kCodeForHome, key.GetCodeString()); | 424 EXPECT_EQ(kCodeForHome, key.GetCodeString()); |
| 424 } | 425 } |
| 425 #endif // OS_WIN | 426 #endif // OS_WIN |
| 426 } | 427 } |
| 427 | 428 |
| 429 TEST(EventTest, LocatedEventTransform) { |
| 430 const gfx::Point root_location(10, 20); |
| 431 const gfx::Point location(0, 14); |
| 432 MouseEvent mouseev(ET_MOUSE_MOVED, location, root_location, |
| 433 EventTimeForNow(), EF_NONE, EF_NONE); |
| 434 gfx::Transform transform; |
| 435 transform.Scale(0.5, 0.5); |
| 436 mouseev.UpdateForRootTransform(transform); |
| 437 EXPECT_EQ(gfx::Point(5, 10).ToString(), |
| 438 mouseev.root_location().ToString()); |
| 439 EXPECT_EQ(gfx::Point(0, 7).ToString(), |
| 440 mouseev.location().ToString()); |
| 441 } |
| 442 |
| 428 namespace { | 443 namespace { |
| 429 #if defined(USE_X11) | 444 #if defined(USE_X11) |
| 430 void SetKeyEventTimestamp(XEvent* event, long time) { | 445 void SetKeyEventTimestamp(XEvent* event, long time) { |
| 431 event->xkey.time = time; | 446 event->xkey.time = time; |
| 432 } | 447 } |
| 433 | 448 |
| 434 void AdvanceKeyEventTimestamp(XEvent* event) { | 449 void AdvanceKeyEventTimestamp(XEvent* event) { |
| 435 event->xkey.time++; | 450 event->xkey.time++; |
| 436 } | 451 } |
| 437 | 452 |
| (...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 876 | 891 |
| 877 EXPECT_EQ(ptr_event.type(), clone_as_ptr->type()); | 892 EXPECT_EQ(ptr_event.type(), clone_as_ptr->type()); |
| 878 EXPECT_EQ(ptr_event.pointer_id(), clone_as_ptr->pointer_id()); | 893 EXPECT_EQ(ptr_event.pointer_id(), clone_as_ptr->pointer_id()); |
| 879 EXPECT_EQ(ptr_event.pointer_details(), clone_as_ptr->pointer_details()); | 894 EXPECT_EQ(ptr_event.pointer_details(), clone_as_ptr->pointer_details()); |
| 880 EXPECT_EQ(ptr_event.location(), clone_as_ptr->location()); | 895 EXPECT_EQ(ptr_event.location(), clone_as_ptr->location()); |
| 881 EXPECT_EQ(ptr_event.root_location(), clone_as_ptr->root_location()); | 896 EXPECT_EQ(ptr_event.root_location(), clone_as_ptr->root_location()); |
| 882 } | 897 } |
| 883 } | 898 } |
| 884 | 899 |
| 885 } // namespace ui | 900 } // namespace ui |
| OLD | NEW |