Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(149)

Side by Side Diff: ui/events/ozone/evdev/touch_event_converter_evdev_unittest.cc

Issue 2507503002: Use touch events to report stylus events (Closed)
Patch Set: I should pay attention... Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/events/ozone/evdev/touch_event_converter_evdev.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/ozone/evdev/touch_event_converter_evdev.h" 5 #include "ui/events/ozone/evdev/touch_event_converter_evdev.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <linux/input.h> 8 #include <linux/input.h>
9 #include <stddef.h> 9 #include <stddef.h>
10 #include <unistd.h> 10 #include <unistd.h>
(...skipping 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after
1014 {{0, 0}, EV_ABS, ABS_X, 9173}, 1014 {{0, 0}, EV_ABS, ABS_X, 9173},
1015 {{0, 0}, EV_ABS, ABS_Y, 3906}, 1015 {{0, 0}, EV_ABS, ABS_Y, 3906},
1016 {{0, 0}, EV_ABS, ABS_PRESSURE, 0}, 1016 {{0, 0}, EV_ABS, ABS_PRESSURE, 0},
1017 {{0, 0}, EV_SYN, SYN_REPORT, 0}, 1017 {{0, 0}, EV_SYN, SYN_REPORT, 0},
1018 {{0, 0}, EV_KEY, BTN_TOOL_PEN, 0}, 1018 {{0, 0}, EV_KEY, BTN_TOOL_PEN, 0},
1019 {{0, 0}, EV_SYN, SYN_REPORT, 0}, 1019 {{0, 0}, EV_SYN, SYN_REPORT, 0},
1020 }; 1020 };
1021 1021
1022 dev->ConfigureReadMock(mock_kernel_queue, arraysize(mock_kernel_queue), 0); 1022 dev->ConfigureReadMock(mock_kernel_queue, arraysize(mock_kernel_queue), 0);
1023 dev->ReadNow(); 1023 dev->ReadNow();
1024 EXPECT_EQ(5u, size()); 1024 EXPECT_EQ(2u, size());
1025 1025
1026 ui::MouseMoveEventParams move_event = dispatched_mouse_move_event(0); 1026 auto down_event = dispatched_touch_event(0);
1027 EXPECT_EQ(9170, move_event.location.x()); 1027 EXPECT_EQ(ET_TOUCH_PRESSED, down_event.type);
1028 EXPECT_EQ(3658, move_event.location.y()); 1028 EXPECT_EQ(9170, down_event.location.x());
1029 EXPECT_EQ(3658, down_event.location.y());
1029 EXPECT_EQ(EventPointerType::POINTER_TYPE_PEN, 1030 EXPECT_EQ(EventPointerType::POINTER_TYPE_PEN,
1030 move_event.pointer_details.pointer_type); 1031 down_event.pointer_details.pointer_type);
1032 EXPECT_EQ(60.f / 1024, down_event.pointer_details.force);
1031 1033
1032 ui::MouseButtonEventParams button_event = dispatched_mouse_button_event(1); 1034 auto up_event = dispatched_touch_event(1);
1033 EXPECT_EQ(9170, button_event.location.x()); 1035 EXPECT_EQ(ET_TOUCH_RELEASED, up_event.type);
1034 EXPECT_EQ(3658, button_event.location.y()); 1036 EXPECT_EQ(9173, up_event.location.x());
1037 EXPECT_EQ(3906, up_event.location.y());
1035 EXPECT_EQ(EventPointerType::POINTER_TYPE_PEN, 1038 EXPECT_EQ(EventPointerType::POINTER_TYPE_PEN,
1036 button_event.pointer_details.pointer_type); 1039 up_event.pointer_details.pointer_type);
1037 EXPECT_EQ(60.f / 1024, button_event.pointer_details.force); 1040 EXPECT_EQ(0.f, up_event.pointer_details.force);
1038 EXPECT_EQ(button_event.button, static_cast<unsigned int>(BTN_LEFT));
1039 EXPECT_EQ(button_event.down, true);
1040
1041 move_event = dispatched_mouse_move_event(2);
1042 EXPECT_EQ(9170, move_event.location.x());
1043 EXPECT_EQ(3658, move_event.location.y());
1044 EXPECT_EQ(EventPointerType::POINTER_TYPE_PEN,
1045 move_event.pointer_details.pointer_type);
1046 EXPECT_EQ(60.f / 1024, move_event.pointer_details.force);
1047
1048 button_event = dispatched_mouse_button_event(3);
1049 EXPECT_EQ(9173, button_event.location.x());
1050 EXPECT_EQ(3906, button_event.location.y());
1051 EXPECT_EQ(EventPointerType::POINTER_TYPE_PEN,
1052 button_event.pointer_details.pointer_type);
1053 EXPECT_EQ(button_event.button, static_cast<unsigned int>(BTN_LEFT));
1054 EXPECT_EQ(button_event.down, false);
1055
1056 move_event = dispatched_mouse_move_event(4);
1057 EXPECT_EQ(9173, move_event.location.x());
1058 EXPECT_EQ(3906, move_event.location.y());
1059 EXPECT_EQ(EventPointerType::POINTER_TYPE_PEN,
1060 move_event.pointer_details.pointer_type);
1061 } 1041 }
1062 1042
1063 TEST_F(TouchEventConverterEvdevTest, ActiveStylusMotion) { 1043 TEST_F(TouchEventConverterEvdevTest, ActiveStylusMotion) {
1064 ui::MockTouchEventConverterEvdev* dev = device(); 1044 ui::MockTouchEventConverterEvdev* dev = device();
1065 EventDeviceInfo devinfo; 1045 EventDeviceInfo devinfo;
1066 EXPECT_TRUE(CapabilitiesToDeviceInfo(kWilsonBeachActiveStylus, &devinfo)); 1046 EXPECT_TRUE(CapabilitiesToDeviceInfo(kWilsonBeachActiveStylus, &devinfo));
1067 dev->Initialize(devinfo); 1047 dev->Initialize(devinfo);
1068 1048
1069 struct input_event mock_kernel_queue[]{ 1049 struct input_event mock_kernel_queue[]{
1070 {{0, 0}, EV_KEY, BTN_TOOL_PEN, 1}, 1050 {{0, 0}, EV_KEY, BTN_TOOL_PEN, 1},
(...skipping 13 matching lines...) Expand all
1084 {{0, 0}, EV_SYN, SYN_REPORT, 0}, 1064 {{0, 0}, EV_SYN, SYN_REPORT, 0},
1085 {{0, 0}, EV_KEY, BTN_TOUCH, 0}, 1065 {{0, 0}, EV_KEY, BTN_TOUCH, 0},
1086 {{0, 0}, EV_ABS, ABS_PRESSURE, 0}, 1066 {{0, 0}, EV_ABS, ABS_PRESSURE, 0},
1087 {{0, 0}, EV_SYN, SYN_REPORT, 0}, 1067 {{0, 0}, EV_SYN, SYN_REPORT, 0},
1088 {{0, 0}, EV_KEY, BTN_TOOL_PEN, 0}, 1068 {{0, 0}, EV_KEY, BTN_TOOL_PEN, 0},
1089 {{0, 0}, EV_SYN, SYN_REPORT, 0}, 1069 {{0, 0}, EV_SYN, SYN_REPORT, 0},
1090 }; 1070 };
1091 1071
1092 dev->ConfigureReadMock(mock_kernel_queue, arraysize(mock_kernel_queue), 0); 1072 dev->ConfigureReadMock(mock_kernel_queue, arraysize(mock_kernel_queue), 0);
1093 dev->ReadNow(); 1073 dev->ReadNow();
1094 EXPECT_EQ(7u, size()); 1074 EXPECT_EQ(4u, size());
1095 1075
1096 ui::MouseMoveEventParams event = dispatched_mouse_move_event(0); 1076 ui::TouchEventParams event = dispatched_touch_event(0);
1097 EXPECT_EQ(8921, event.location.x()); 1077 EXPECT_EQ(ET_TOUCH_PRESSED, event.type);
1098 EXPECT_EQ(1072, event.location.y());
1099 EXPECT_EQ(EventPointerType::POINTER_TYPE_PEN,
1100 event.pointer_details.pointer_type);
1101 EXPECT_EQ(0.f / 1024, event.pointer_details.force);
1102
1103 ui::MouseButtonEventParams button_event = dispatched_mouse_button_event(1);
1104 EXPECT_EQ(8921, button_event.location.x());
1105 EXPECT_EQ(1072, button_event.location.y());
1106 EXPECT_EQ(EventPointerType::POINTER_TYPE_PEN,
1107 button_event.pointer_details.pointer_type);
1108 EXPECT_EQ(35.f / 1024, button_event.pointer_details.force);
1109 EXPECT_EQ(button_event.button, static_cast<unsigned int>(BTN_LEFT));
1110 EXPECT_EQ(button_event.down, true);
1111
1112 event = dispatched_mouse_move_event(2);
1113 EXPECT_EQ(8921, event.location.x()); 1078 EXPECT_EQ(8921, event.location.x());
1114 EXPECT_EQ(1072, event.location.y()); 1079 EXPECT_EQ(1072, event.location.y());
1115 EXPECT_EQ(EventPointerType::POINTER_TYPE_PEN, 1080 EXPECT_EQ(EventPointerType::POINTER_TYPE_PEN,
1116 event.pointer_details.pointer_type); 1081 event.pointer_details.pointer_type);
1117 EXPECT_EQ(35.f / 1024, event.pointer_details.force); 1082 EXPECT_EQ(35.f / 1024, event.pointer_details.force);
1118 1083
1119 event = dispatched_mouse_move_event(3); 1084 event = dispatched_touch_event(1);
1085 EXPECT_EQ(ET_TOUCH_MOVED, event.type);
1120 EXPECT_EQ(8934, event.location.x()); 1086 EXPECT_EQ(8934, event.location.x());
1121 EXPECT_EQ(981, event.location.y()); 1087 EXPECT_EQ(981, event.location.y());
1122 EXPECT_EQ(EventPointerType::POINTER_TYPE_PEN, 1088 EXPECT_EQ(EventPointerType::POINTER_TYPE_PEN,
1123 event.pointer_details.pointer_type); 1089 event.pointer_details.pointer_type);
1124 EXPECT_EQ(184.f / 1024, event.pointer_details.force); 1090 EXPECT_EQ(184.f / 1024, event.pointer_details.force);
1125 1091
1126 event = dispatched_mouse_move_event(4); 1092 event = dispatched_touch_event(2);
1093 EXPECT_EQ(ET_TOUCH_MOVED, event.type);
1127 EXPECT_EQ(8930, event.location.x()); 1094 EXPECT_EQ(8930, event.location.x());
1128 EXPECT_EQ(980, event.location.y()); 1095 EXPECT_EQ(980, event.location.y());
1129 EXPECT_EQ(EventPointerType::POINTER_TYPE_PEN, 1096 EXPECT_EQ(EventPointerType::POINTER_TYPE_PEN,
1130 event.pointer_details.pointer_type); 1097 event.pointer_details.pointer_type);
1131 EXPECT_EQ(348.f / 1024, event.pointer_details.force); 1098 EXPECT_EQ(348.f / 1024, event.pointer_details.force);
1132 1099
1133 button_event = dispatched_mouse_button_event(5); 1100 event = dispatched_touch_event(3);
1134 EXPECT_EQ(8930, button_event.location.x()); 1101 EXPECT_EQ(ET_TOUCH_RELEASED, event.type);
1135 EXPECT_EQ(980, button_event.location.y());
1136 EXPECT_EQ(EventPointerType::POINTER_TYPE_PEN,
1137 button_event.pointer_details.pointer_type);
1138 EXPECT_EQ(button_event.button, static_cast<unsigned int>(BTN_LEFT));
1139 EXPECT_EQ(button_event.down, false);
1140
1141 event = dispatched_mouse_move_event(6);
1142 EXPECT_EQ(8930, event.location.x()); 1102 EXPECT_EQ(8930, event.location.x());
1143 EXPECT_EQ(980, event.location.y()); 1103 EXPECT_EQ(980, event.location.y());
1144 EXPECT_EQ(EventPointerType::POINTER_TYPE_PEN, 1104 EXPECT_EQ(EventPointerType::POINTER_TYPE_PEN,
1145 event.pointer_details.pointer_type); 1105 event.pointer_details.pointer_type);
1146 EXPECT_EQ(0.f / 1024, event.pointer_details.force); 1106 EXPECT_EQ(0.f / 1024, event.pointer_details.force);
1147 } 1107 }
1148 1108
1149 } // namespace ui 1109 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/ozone/evdev/touch_event_converter_evdev.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698