OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/test/events_test_utils_x11.h" | 5 #include "ui/events/test/events_test_utils_x11.h" |
6 | 6 |
7 #include <X11/extensions/XI2.h> | 7 #include <X11/extensions/XI2.h> |
8 #include <X11/keysym.h> | 8 #include <X11/keysym.h> |
9 #include <X11/X.h> | 9 #include <X11/X.h> |
10 #include <X11/Xlib.h> | 10 #include <X11/Xlib.h> |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 return Button1; | 78 return Button1; |
79 if (flags & ui::EF_MIDDLE_MOUSE_BUTTON) | 79 if (flags & ui::EF_MIDDLE_MOUSE_BUTTON) |
80 return Button2; | 80 return Button2; |
81 if (flags & ui::EF_RIGHT_MOUSE_BUTTON) | 81 if (flags & ui::EF_RIGHT_MOUSE_BUTTON) |
82 return Button3; | 82 return Button3; |
83 | 83 |
84 return 0; | 84 return 0; |
85 } | 85 } |
86 | 86 |
87 void InitValuatorsForXIDeviceEvent(XIDeviceEvent* xiev) { | 87 void InitValuatorsForXIDeviceEvent(XIDeviceEvent* xiev) { |
88 int valuator_count = ui::DeviceDataManager::DT_LAST_ENTRY; | 88 int valuator_count = ui::DeviceDataManagerX11::DT_LAST_ENTRY; |
89 xiev->valuators.mask_len = (valuator_count / 8) + 1; | 89 xiev->valuators.mask_len = (valuator_count / 8) + 1; |
90 xiev->valuators.mask = new unsigned char[xiev->valuators.mask_len]; | 90 xiev->valuators.mask = new unsigned char[xiev->valuators.mask_len]; |
91 memset(xiev->valuators.mask, 0, xiev->valuators.mask_len); | 91 memset(xiev->valuators.mask, 0, xiev->valuators.mask_len); |
92 xiev->valuators.values = new double[valuator_count]; | 92 xiev->valuators.values = new double[valuator_count]; |
93 } | 93 } |
94 | 94 |
95 XEvent* CreateXInput2Event(int deviceid, | 95 XEvent* CreateXInput2Event(int deviceid, |
96 int evtype, | 96 int evtype, |
97 int tracking_id, | 97 int tracking_id, |
98 const gfx::Point& location) { | 98 const gfx::Point& location) { |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 | 191 |
192 void ScopedXI2Event::InitScrollEvent(int deviceid, | 192 void ScopedXI2Event::InitScrollEvent(int deviceid, |
193 int x_offset, | 193 int x_offset, |
194 int y_offset, | 194 int y_offset, |
195 int x_offset_ordinal, | 195 int x_offset_ordinal, |
196 int y_offset_ordinal, | 196 int y_offset_ordinal, |
197 int finger_count) { | 197 int finger_count) { |
198 event_.reset(CreateXInput2Event(deviceid, XI_Motion, 0, gfx::Point())); | 198 event_.reset(CreateXInput2Event(deviceid, XI_Motion, 0, gfx::Point())); |
199 | 199 |
200 Valuator valuators[] = { | 200 Valuator valuators[] = { |
201 Valuator(DeviceDataManager::DT_CMT_SCROLL_X, x_offset), | 201 Valuator(DeviceDataManagerX11::DT_CMT_SCROLL_X, x_offset), |
202 Valuator(DeviceDataManager::DT_CMT_SCROLL_Y, y_offset), | 202 Valuator(DeviceDataManagerX11::DT_CMT_SCROLL_Y, y_offset), |
203 Valuator(DeviceDataManager::DT_CMT_ORDINAL_X, x_offset_ordinal), | 203 Valuator(DeviceDataManagerX11::DT_CMT_ORDINAL_X, x_offset_ordinal), |
204 Valuator(DeviceDataManager::DT_CMT_ORDINAL_Y, y_offset_ordinal), | 204 Valuator(DeviceDataManagerX11::DT_CMT_ORDINAL_Y, y_offset_ordinal), |
205 Valuator(DeviceDataManager::DT_CMT_FINGER_COUNT, finger_count) | 205 Valuator(DeviceDataManagerX11::DT_CMT_FINGER_COUNT, finger_count) |
206 }; | 206 }; |
207 SetUpValuators( | 207 SetUpValuators( |
208 std::vector<Valuator>(valuators, valuators + arraysize(valuators))); | 208 std::vector<Valuator>(valuators, valuators + arraysize(valuators))); |
209 } | 209 } |
210 | 210 |
211 void ScopedXI2Event::InitFlingScrollEvent(int deviceid, | 211 void ScopedXI2Event::InitFlingScrollEvent(int deviceid, |
212 int x_velocity, | 212 int x_velocity, |
213 int y_velocity, | 213 int y_velocity, |
214 int x_velocity_ordinal, | 214 int x_velocity_ordinal, |
215 int y_velocity_ordinal, | 215 int y_velocity_ordinal, |
216 bool is_cancel) { | 216 bool is_cancel) { |
217 event_.reset(CreateXInput2Event(deviceid, XI_Motion, deviceid, gfx::Point())); | 217 event_.reset(CreateXInput2Event(deviceid, XI_Motion, deviceid, gfx::Point())); |
218 | 218 |
219 Valuator valuators[] = { | 219 Valuator valuators[] = { |
220 Valuator(DeviceDataManager::DT_CMT_FLING_STATE, is_cancel ? 1 : 0), | 220 Valuator(DeviceDataManagerX11::DT_CMT_FLING_STATE, is_cancel ? 1 : 0), |
221 Valuator(DeviceDataManager::DT_CMT_FLING_Y, y_velocity), | 221 Valuator(DeviceDataManagerX11::DT_CMT_FLING_Y, y_velocity), |
222 Valuator(DeviceDataManager::DT_CMT_ORDINAL_Y, y_velocity_ordinal), | 222 Valuator(DeviceDataManagerX11::DT_CMT_ORDINAL_Y, y_velocity_ordinal), |
223 Valuator(DeviceDataManager::DT_CMT_FLING_X, x_velocity), | 223 Valuator(DeviceDataManagerX11::DT_CMT_FLING_X, x_velocity), |
224 Valuator(DeviceDataManager::DT_CMT_ORDINAL_X, x_velocity_ordinal) | 224 Valuator(DeviceDataManagerX11::DT_CMT_ORDINAL_X, x_velocity_ordinal) |
225 }; | 225 }; |
226 | 226 |
227 SetUpValuators( | 227 SetUpValuators( |
228 std::vector<Valuator>(valuators, valuators + arraysize(valuators))); | 228 std::vector<Valuator>(valuators, valuators + arraysize(valuators))); |
229 } | 229 } |
230 | 230 |
231 void ScopedXI2Event::InitTouchEvent(int deviceid, | 231 void ScopedXI2Event::InitTouchEvent(int deviceid, |
232 int evtype, | 232 int evtype, |
233 int tracking_id, | 233 int tracking_id, |
234 const gfx::Point& location, | 234 const gfx::Point& location, |
235 const std::vector<Valuator>& valuators) { | 235 const std::vector<Valuator>& valuators) { |
236 event_.reset(CreateXInput2Event(deviceid, evtype, tracking_id, location)); | 236 event_.reset(CreateXInput2Event(deviceid, evtype, tracking_id, location)); |
237 SetUpValuators(valuators); | 237 SetUpValuators(valuators); |
238 } | 238 } |
239 | 239 |
240 void ScopedXI2Event::SetUpValuators(const std::vector<Valuator>& valuators) { | 240 void ScopedXI2Event::SetUpValuators(const std::vector<Valuator>& valuators) { |
241 CHECK(event_.get()); | 241 CHECK(event_.get()); |
242 CHECK_EQ(GenericEvent, event_->type); | 242 CHECK_EQ(GenericEvent, event_->type); |
243 XIDeviceEvent* xiev = static_cast<XIDeviceEvent*>(event_->xcookie.data); | 243 XIDeviceEvent* xiev = static_cast<XIDeviceEvent*>(event_->xcookie.data); |
244 InitValuatorsForXIDeviceEvent(xiev); | 244 InitValuatorsForXIDeviceEvent(xiev); |
245 ui::DeviceDataManager* manager = ui::DeviceDataManager::GetInstance(); | 245 ui::DeviceDataManagerX11* manager = ui::DeviceDataManagerX11::GetInstance(); |
246 for (size_t i = 0; i < valuators.size(); ++i) { | 246 for (size_t i = 0; i < valuators.size(); ++i) { |
247 manager->SetValuatorDataForTest(xiev, valuators[i].data_type, | 247 manager->SetValuatorDataForTest(xiev, valuators[i].data_type, |
248 valuators[i].value); | 248 valuators[i].value); |
249 } | 249 } |
250 } | 250 } |
251 | 251 |
252 void SetUpTouchPadForTest(unsigned int deviceid) { | 252 void SetUpTouchPadForTest(unsigned int deviceid) { |
253 std::vector<unsigned int> device_list; | 253 std::vector<unsigned int> device_list; |
254 device_list.push_back(deviceid); | 254 device_list.push_back(deviceid); |
255 | 255 |
256 TouchFactory::GetInstance()->SetPointerDeviceForTest(device_list); | 256 TouchFactory::GetInstance()->SetPointerDeviceForTest(device_list); |
257 ui::DeviceDataManager* manager = ui::DeviceDataManager::GetInstance(); | 257 ui::DeviceDataManagerX11* manager = ui::DeviceDataManagerX11::GetInstance(); |
258 manager->SetDeviceListForTest(std::vector<unsigned int>(), device_list); | 258 manager->SetDeviceListForTest(std::vector<unsigned int>(), device_list); |
259 } | 259 } |
260 | 260 |
261 void SetUpTouchDevicesForTest(const std::vector<unsigned int>& devices) { | 261 void SetUpTouchDevicesForTest(const std::vector<unsigned int>& devices) { |
262 TouchFactory::GetInstance()->SetTouchDeviceForTest(devices); | 262 TouchFactory::GetInstance()->SetTouchDeviceForTest(devices); |
263 ui::DeviceDataManager* manager = ui::DeviceDataManager::GetInstance(); | 263 ui::DeviceDataManagerX11* manager = ui::DeviceDataManagerX11::GetInstance(); |
264 manager->SetDeviceListForTest(devices, std::vector<unsigned int>()); | 264 manager->SetDeviceListForTest(devices, std::vector<unsigned int>()); |
265 } | 265 } |
266 | 266 |
267 } // namespace ui | 267 } // namespace ui |
OLD | NEW |