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