| 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> |
| (...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 731 ui::TouchEvent touch_event_copy(touch_event); | 731 ui::TouchEvent touch_event_copy(touch_event); |
| 732 EXPECT_EQ(touch_event.pointer_details(), touch_event_copy.pointer_details()); | 732 EXPECT_EQ(touch_event.pointer_details(), touch_event_copy.pointer_details()); |
| 733 } | 733 } |
| 734 | 734 |
| 735 TEST(EventTest, PointerEventCanConvertFrom) { | 735 TEST(EventTest, PointerEventCanConvertFrom) { |
| 736 const gfx::Point point; | 736 const gfx::Point point; |
| 737 const base::TimeTicks time; | 737 const base::TimeTicks time; |
| 738 | 738 |
| 739 // Common mouse events can be converted. | 739 // Common mouse events can be converted. |
| 740 const EventType mouse_allowed[] = { | 740 const EventType mouse_allowed[] = { |
| 741 ET_MOUSE_PRESSED, ET_MOUSE_DRAGGED, ET_MOUSE_MOVED, | 741 ET_MOUSE_PRESSED, ET_MOUSE_DRAGGED, ET_MOUSE_MOVED, |
| 742 ET_MOUSE_ENTERED, ET_MOUSE_EXITED, ET_MOUSE_RELEASED, | 742 ET_MOUSE_ENTERED, ET_MOUSE_EXITED, ET_MOUSE_RELEASED, |
| 743 ET_MOUSEWHEEL, ET_MOUSE_CAPTURE_CHANGED, | 743 ET_MOUSE_CAPTURE_CHANGED, |
| 744 }; | 744 }; |
| 745 for (size_t i = 0; i < arraysize(mouse_allowed); i++) { | 745 for (size_t i = 0; i < arraysize(mouse_allowed); i++) { |
| 746 MouseEvent event(mouse_allowed[i], point, point, time, 0, 0); | 746 MouseEvent event(mouse_allowed[i], point, point, time, 0, 0); |
| 747 EXPECT_TRUE(PointerEvent::CanConvertFrom(event)); | 747 EXPECT_TRUE(PointerEvent::CanConvertFrom(event)); |
| 748 } | 748 } |
| 749 // Mouse wheel events can be converted. |
| 750 MouseWheelEvent event(gfx::Vector2d(), point, point, time, 0, 0); |
| 751 EXPECT_TRUE(PointerEvent::CanConvertFrom(event)); |
| 749 | 752 |
| 750 // Common touch events can be converted. | 753 // Common touch events can be converted. |
| 751 const EventType touch_allowed[] = { | 754 const EventType touch_allowed[] = { |
| 752 ET_TOUCH_PRESSED, | 755 ET_TOUCH_PRESSED, |
| 753 ET_TOUCH_MOVED, | 756 ET_TOUCH_MOVED, |
| 754 ET_TOUCH_RELEASED, | 757 ET_TOUCH_RELEASED, |
| 755 ET_TOUCH_CANCELLED | 758 ET_TOUCH_CANCELLED |
| 756 }; | 759 }; |
| 757 for (size_t i = 0; i < arraysize(touch_allowed); i++) { | 760 for (size_t i = 0; i < arraysize(touch_allowed); i++) { |
| 758 TouchEvent event(touch_allowed[i], point, 0, time); | 761 TouchEvent event(touch_allowed[i], point, 0, time); |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1010 XButtonEvent* button_event = &(native_event.xbutton); | 1013 XButtonEvent* button_event = &(native_event.xbutton); |
| 1011 button_event->type = ButtonPress; | 1014 button_event->type = ButtonPress; |
| 1012 button_event->button = 4; // A valid wheel button number between min and max. | 1015 button_event->button = 4; // A valid wheel button number between min and max. |
| 1013 MouseWheelEvent mouse_ev(&native_event); | 1016 MouseWheelEvent mouse_ev(&native_event); |
| 1014 | 1017 |
| 1015 histogram_tester.ExpectTotalCount("Event.Latency.OS.MOUSE_WHEEL", 1); | 1018 histogram_tester.ExpectTotalCount("Event.Latency.OS.MOUSE_WHEEL", 1); |
| 1016 #endif | 1019 #endif |
| 1017 } | 1020 } |
| 1018 | 1021 |
| 1019 } // namespace ui | 1022 } // namespace ui |
| OLD | NEW |