| 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 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 701 EXPECT_EQ(0.0f, mouse_event.pointer_details().radius_y); | 701 EXPECT_EQ(0.0f, mouse_event.pointer_details().radius_y); |
| 702 EXPECT_TRUE(std::isnan(mouse_event.pointer_details().force)); | 702 EXPECT_TRUE(std::isnan(mouse_event.pointer_details().force)); |
| 703 EXPECT_EQ(0.0f, mouse_event.pointer_details().tilt_x); | 703 EXPECT_EQ(0.0f, mouse_event.pointer_details().tilt_x); |
| 704 EXPECT_EQ(0.0f, mouse_event.pointer_details().tilt_y); | 704 EXPECT_EQ(0.0f, mouse_event.pointer_details().tilt_y); |
| 705 | 705 |
| 706 ui::MouseEvent mouse_event_copy(mouse_event); | 706 ui::MouseEvent mouse_event_copy(mouse_event); |
| 707 EXPECT_EQ(mouse_event.pointer_details(), mouse_event_copy.pointer_details()); | 707 EXPECT_EQ(mouse_event.pointer_details(), mouse_event_copy.pointer_details()); |
| 708 } | 708 } |
| 709 | 709 |
| 710 TEST(EventTest, PointerDetailsStylus) { | 710 TEST(EventTest, PointerDetailsStylus) { |
| 711 ui::MouseEvent stylus_event(ET_MOUSE_PRESSED, gfx::Point(0, 0), | |
| 712 gfx::Point(0, 0), ui::EventTimeForNow(), 0, 0); | |
| 713 ui::PointerDetails pointer_details(EventPointerType::POINTER_TYPE_PEN, | 711 ui::PointerDetails pointer_details(EventPointerType::POINTER_TYPE_PEN, |
| 714 /* pointer_id*/ 0, | 712 /* pointer_id*/ 0, |
| 715 /* radius_x */ 0.0f, | 713 /* radius_x */ 0.0f, |
| 716 /* radius_y */ 0.0f, | 714 /* radius_y */ 0.0f, |
| 717 /* force */ 21.0f, | 715 /* force */ 21.0f, |
| 718 /* tilt_x */ 45.0f, | 716 /* tilt_x */ 45.0f, |
| 719 /* tilt_y */ -45.0f, | 717 /* tilt_y */ -45.0f, |
| 720 /* tangential_pressure */ 0.7f, | 718 /* tangential_pressure */ 0.7f, |
| 721 /* twist */ 196); | 719 /* twist */ 196); |
| 722 | 720 |
| 723 stylus_event.set_pointer_details(pointer_details); | 721 ui::MouseEvent stylus_event(ET_MOUSE_PRESSED, gfx::Point(0, 0), |
| 722 gfx::Point(0, 0), ui::EventTimeForNow(), 0, 0, |
| 723 pointer_details); |
| 724 EXPECT_EQ(EventPointerType::POINTER_TYPE_PEN, | 724 EXPECT_EQ(EventPointerType::POINTER_TYPE_PEN, |
| 725 stylus_event.pointer_details().pointer_type); | 725 stylus_event.pointer_details().pointer_type); |
| 726 EXPECT_EQ(21.0f, stylus_event.pointer_details().force); | 726 EXPECT_EQ(21.0f, stylus_event.pointer_details().force); |
| 727 EXPECT_EQ(45.0f, stylus_event.pointer_details().tilt_x); | 727 EXPECT_EQ(45.0f, stylus_event.pointer_details().tilt_x); |
| 728 EXPECT_EQ(-45.0f, stylus_event.pointer_details().tilt_y); | 728 EXPECT_EQ(-45.0f, stylus_event.pointer_details().tilt_y); |
| 729 EXPECT_EQ(0.0f, stylus_event.pointer_details().radius_x); | 729 EXPECT_EQ(0.0f, stylus_event.pointer_details().radius_x); |
| 730 EXPECT_EQ(0.0f, stylus_event.pointer_details().radius_y); | 730 EXPECT_EQ(0.0f, stylus_event.pointer_details().radius_y); |
| 731 EXPECT_EQ(0.7f, stylus_event.pointer_details().tangential_pressure); | 731 EXPECT_EQ(0.7f, stylus_event.pointer_details().tangential_pressure); |
| 732 EXPECT_EQ(196, stylus_event.pointer_details().twist); | 732 EXPECT_EQ(196, stylus_event.pointer_details().twist); |
| 733 | 733 |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 849 EXPECT_TRUE(pointer_event.IsPointerEvent()); | 849 EXPECT_TRUE(pointer_event.IsPointerEvent()); |
| 850 } | 850 } |
| 851 } | 851 } |
| 852 | 852 |
| 853 TEST(EventTest, PointerEventId) { | 853 TEST(EventTest, PointerEventId) { |
| 854 { | 854 { |
| 855 ui::MouseEvent mouse_event(ui::ET_MOUSE_PRESSED, gfx::Point(0, 0), | 855 ui::MouseEvent mouse_event(ui::ET_MOUSE_PRESSED, gfx::Point(0, 0), |
| 856 gfx::Point(0, 0), base::TimeTicks(), 0, 0); | 856 gfx::Point(0, 0), base::TimeTicks(), 0, 0); |
| 857 ui::PointerEvent pointer_event(mouse_event); | 857 ui::PointerEvent pointer_event(mouse_event); |
| 858 EXPECT_EQ(pointer_event.pointer_details().id, | 858 EXPECT_EQ(pointer_event.pointer_details().id, |
| 859 ui::PointerEvent::kMousePointerId); | 859 ui::MouseEvent::kMousePointerId); |
| 860 } | 860 } |
| 861 | 861 |
| 862 for (int touch_id = 0; touch_id < 8; touch_id++) { | 862 for (int touch_id = 0; touch_id < 8; touch_id++) { |
| 863 ui::TouchEvent touch_event( | 863 ui::TouchEvent touch_event( |
| 864 ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), base::TimeTicks(), | 864 ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), base::TimeTicks(), |
| 865 PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, touch_id)); | 865 PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, touch_id)); |
| 866 ui::PointerEvent pointer_event(touch_event); | 866 ui::PointerEvent pointer_event(touch_event); |
| 867 EXPECT_EQ(pointer_event.pointer_details().id, touch_id); | 867 EXPECT_EQ(pointer_event.pointer_details().id, touch_id); |
| 868 } | 868 } |
| 869 } | 869 } |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1092 XButtonEvent* button_event = &(native_event.xbutton); | 1092 XButtonEvent* button_event = &(native_event.xbutton); |
| 1093 button_event->type = ButtonPress; | 1093 button_event->type = ButtonPress; |
| 1094 button_event->button = 4; // A valid wheel button number between min and max. | 1094 button_event->button = 4; // A valid wheel button number between min and max. |
| 1095 MouseWheelEvent mouse_ev(&native_event); | 1095 MouseWheelEvent mouse_ev(&native_event); |
| 1096 | 1096 |
| 1097 histogram_tester.ExpectTotalCount("Event.Latency.OS.MOUSE_WHEEL", 1); | 1097 histogram_tester.ExpectTotalCount("Event.Latency.OS.MOUSE_WHEEL", 1); |
| 1098 #endif | 1098 #endif |
| 1099 } | 1099 } |
| 1100 | 1100 |
| 1101 } // namespace ui | 1101 } // namespace ui |
| OLD | NEW |