| 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 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 673 EXPECT_EQ(0.0f, mouse_event.pointer_details().tilt_y); | 673 EXPECT_EQ(0.0f, mouse_event.pointer_details().tilt_y); |
| 674 | 674 |
| 675 ui::MouseEvent mouse_event_copy(mouse_event); | 675 ui::MouseEvent mouse_event_copy(mouse_event); |
| 676 EXPECT_EQ(mouse_event.pointer_details(), mouse_event_copy.pointer_details()); | 676 EXPECT_EQ(mouse_event.pointer_details(), mouse_event_copy.pointer_details()); |
| 677 } | 677 } |
| 678 | 678 |
| 679 TEST(EventTest, PointerDetailsStylus) { | 679 TEST(EventTest, PointerDetailsStylus) { |
| 680 ui::MouseEvent stylus_event(ET_MOUSE_PRESSED, gfx::Point(0, 0), | 680 ui::MouseEvent stylus_event(ET_MOUSE_PRESSED, gfx::Point(0, 0), |
| 681 gfx::Point(0, 0), ui::EventTimeForNow(), 0, 0); | 681 gfx::Point(0, 0), ui::EventTimeForNow(), 0, 0); |
| 682 ui::PointerDetails pointer_details(EventPointerType::POINTER_TYPE_PEN, | 682 ui::PointerDetails pointer_details(EventPointerType::POINTER_TYPE_PEN, |
| 683 /* radius_x */ 0.0f, | 683 /* radius_x */ 0.0f, |
| 684 /* radius_y */ 0.0f, | 684 /* radius_y */ 0.0f, |
| 685 /* force */ 21.0f, | 685 /* force */ 21.0f, |
| 686 /* tilt_x */ 45.0f, | 686 /* tilt_x */ 45.0f, |
| 687 /* tilt_y */ -45.0f); | 687 /* tilt_y */ -45.0f, |
| 688 /* tangential_pressure */ 0.7f, |
| 689 /* twist */ 196); |
| 688 | 690 |
| 689 stylus_event.set_pointer_details(pointer_details); | 691 stylus_event.set_pointer_details(pointer_details); |
| 690 EXPECT_EQ(EventPointerType::POINTER_TYPE_PEN, | 692 EXPECT_EQ(EventPointerType::POINTER_TYPE_PEN, |
| 691 stylus_event.pointer_details().pointer_type); | 693 stylus_event.pointer_details().pointer_type); |
| 692 EXPECT_EQ(21.0f, stylus_event.pointer_details().force); | 694 EXPECT_EQ(21.0f, stylus_event.pointer_details().force); |
| 693 EXPECT_EQ(45.0f, stylus_event.pointer_details().tilt_x); | 695 EXPECT_EQ(45.0f, stylus_event.pointer_details().tilt_x); |
| 694 EXPECT_EQ(-45.0f, stylus_event.pointer_details().tilt_y); | 696 EXPECT_EQ(-45.0f, stylus_event.pointer_details().tilt_y); |
| 695 EXPECT_EQ(0.0f, stylus_event.pointer_details().radius_x); | 697 EXPECT_EQ(0.0f, stylus_event.pointer_details().radius_x); |
| 696 EXPECT_EQ(0.0f, stylus_event.pointer_details().radius_y); | 698 EXPECT_EQ(0.0f, stylus_event.pointer_details().radius_y); |
| 699 EXPECT_EQ(0.7f, stylus_event.pointer_details().tangential_pressure); |
| 700 EXPECT_EQ(196, stylus_event.pointer_details().twist); |
| 697 | 701 |
| 698 ui::MouseEvent stylus_event_copy(stylus_event); | 702 ui::MouseEvent stylus_event_copy(stylus_event); |
| 699 EXPECT_EQ(stylus_event.pointer_details(), | 703 EXPECT_EQ(stylus_event.pointer_details(), |
| 700 stylus_event_copy.pointer_details()); | 704 stylus_event_copy.pointer_details()); |
| 701 } | 705 } |
| 702 | 706 |
| 703 TEST(EventTest, PointerDetailsCustomTouch) { | 707 TEST(EventTest, PointerDetailsCustomTouch) { |
| 704 ui::TouchEvent touch_event(ET_TOUCH_PRESSED, gfx::Point(0, 0), 0, | 708 ui::TouchEvent touch_event(ET_TOUCH_PRESSED, gfx::Point(0, 0), 0, |
| 705 ui::EventTimeForNow()); | 709 ui::EventTimeForNow()); |
| 706 | 710 |
| 707 EXPECT_EQ(EventPointerType::POINTER_TYPE_TOUCH, | 711 EXPECT_EQ(EventPointerType::POINTER_TYPE_TOUCH, |
| 708 touch_event.pointer_details().pointer_type); | 712 touch_event.pointer_details().pointer_type); |
| 709 EXPECT_EQ(0.0f, touch_event.pointer_details().radius_x); | 713 EXPECT_EQ(0.0f, touch_event.pointer_details().radius_x); |
| 710 EXPECT_EQ(0.0f, touch_event.pointer_details().radius_y); | 714 EXPECT_EQ(0.0f, touch_event.pointer_details().radius_y); |
| 711 EXPECT_TRUE(std::isnan(touch_event.pointer_details().force)); | 715 EXPECT_TRUE(std::isnan(touch_event.pointer_details().force)); |
| 712 EXPECT_EQ(0.0f, touch_event.pointer_details().tilt_x); | 716 EXPECT_EQ(0.0f, touch_event.pointer_details().tilt_x); |
| 713 EXPECT_EQ(0.0f, touch_event.pointer_details().tilt_y); | 717 EXPECT_EQ(0.0f, touch_event.pointer_details().tilt_y); |
| 714 | 718 |
| 715 ui::PointerDetails pointer_details(EventPointerType::POINTER_TYPE_PEN, | 719 ui::PointerDetails pointer_details(EventPointerType::POINTER_TYPE_PEN, |
| 716 /* radius_x */ 5.0f, | 720 /* radius_x */ 5.0f, |
| 717 /* radius_y */ 6.0f, | 721 /* radius_y */ 6.0f, |
| 718 /* force */ 21.0f, | 722 /* force */ 21.0f, |
| 719 /* tilt_x */ 45.0f, | 723 /* tilt_x */ 45.0f, |
| 720 /* tilt_y */ -45.0f); | 724 /* tilt_y */ -45.0f, |
| 725 /* tangential_pressure */ 0.7f, |
| 726 /* twist */ 196); |
| 721 touch_event.set_pointer_details(pointer_details); | 727 touch_event.set_pointer_details(pointer_details); |
| 722 | 728 |
| 723 EXPECT_EQ(EventPointerType::POINTER_TYPE_PEN, | 729 EXPECT_EQ(EventPointerType::POINTER_TYPE_PEN, |
| 724 touch_event.pointer_details().pointer_type); | 730 touch_event.pointer_details().pointer_type); |
| 725 EXPECT_EQ(21.0f, touch_event.pointer_details().force); | 731 EXPECT_EQ(21.0f, touch_event.pointer_details().force); |
| 726 EXPECT_EQ(45.0f, touch_event.pointer_details().tilt_x); | 732 EXPECT_EQ(45.0f, touch_event.pointer_details().tilt_x); |
| 727 EXPECT_EQ(-45.0f, touch_event.pointer_details().tilt_y); | 733 EXPECT_EQ(-45.0f, touch_event.pointer_details().tilt_y); |
| 728 EXPECT_EQ(5.0f, touch_event.pointer_details().radius_x); | 734 EXPECT_EQ(5.0f, touch_event.pointer_details().radius_x); |
| 729 EXPECT_EQ(6.0f, touch_event.pointer_details().radius_y); | 735 EXPECT_EQ(6.0f, touch_event.pointer_details().radius_y); |
| 736 EXPECT_EQ(0.7f, touch_event.pointer_details().tangential_pressure); |
| 737 EXPECT_EQ(196, touch_event.pointer_details().twist); |
| 730 | 738 |
| 731 ui::TouchEvent touch_event_copy(touch_event); | 739 ui::TouchEvent touch_event_copy(touch_event); |
| 732 EXPECT_EQ(touch_event.pointer_details(), touch_event_copy.pointer_details()); | 740 EXPECT_EQ(touch_event.pointer_details(), touch_event_copy.pointer_details()); |
| 733 } | 741 } |
| 734 | 742 |
| 735 TEST(EventTest, PointerEventCanConvertFrom) { | 743 TEST(EventTest, PointerEventCanConvertFrom) { |
| 736 const gfx::Point point; | 744 const gfx::Point point; |
| 737 const base::TimeTicks time; | 745 const base::TimeTicks time; |
| 738 | 746 |
| 739 // Common mouse events can be converted. | 747 // Common mouse events can be converted. |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1029 XButtonEvent* button_event = &(native_event.xbutton); | 1037 XButtonEvent* button_event = &(native_event.xbutton); |
| 1030 button_event->type = ButtonPress; | 1038 button_event->type = ButtonPress; |
| 1031 button_event->button = 4; // A valid wheel button number between min and max. | 1039 button_event->button = 4; // A valid wheel button number between min and max. |
| 1032 MouseWheelEvent mouse_ev(&native_event); | 1040 MouseWheelEvent mouse_ev(&native_event); |
| 1033 | 1041 |
| 1034 histogram_tester.ExpectTotalCount("Event.Latency.OS.MOUSE_WHEEL", 1); | 1042 histogram_tester.ExpectTotalCount("Event.Latency.OS.MOUSE_WHEEL", 1); |
| 1035 #endif | 1043 #endif |
| 1036 } | 1044 } |
| 1037 | 1045 |
| 1038 } // namespace ui | 1046 } // namespace ui |
| OLD | NEW |