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

Side by Side Diff: ui/events/test/events_test_utils_x11.cc

Issue 306483003: Prepare for Unified Gesture Recognizer landing in Aura (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix whitespace, disable UGR. Created 6 years, 6 months 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 | Annotate | Revision Log
OLDNEW
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>
11 11
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "ui/events/event_constants.h" 13 #include "ui/events/event_constants.h"
14 #include "ui/events/event_utils.h"
14 #include "ui/events/keycodes/keyboard_code_conversion_x.h" 15 #include "ui/events/keycodes/keyboard_code_conversion_x.h"
15 #include "ui/events/x/touch_factory_x11.h" 16 #include "ui/events/x/touch_factory_x11.h"
16 17
17 namespace { 18 namespace {
18 19
19 // Converts ui::EventType to state for X*Events. 20 // Converts ui::EventType to state for X*Events.
20 unsigned int XEventState(int flags) { 21 unsigned int XEventState(int flags) {
21 return 22 return
22 ((flags & ui::EF_SHIFT_DOWN) ? ShiftMask : 0) | 23 ((flags & ui::EF_SHIFT_DOWN) ? ShiftMask : 0) |
23 ((flags & ui::EF_CONTROL_DOWN) ? ControlMask : 0) | 24 ((flags & ui::EF_CONTROL_DOWN) ? ControlMask : 0) |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 SetUpValuators( 232 SetUpValuators(
232 std::vector<Valuator>(valuators, valuators + arraysize(valuators))); 233 std::vector<Valuator>(valuators, valuators + arraysize(valuators)));
233 } 234 }
234 235
235 void ScopedXI2Event::InitTouchEvent(int deviceid, 236 void ScopedXI2Event::InitTouchEvent(int deviceid,
236 int evtype, 237 int evtype,
237 int tracking_id, 238 int tracking_id,
238 const gfx::Point& location, 239 const gfx::Point& location,
239 const std::vector<Valuator>& valuators) { 240 const std::vector<Valuator>& valuators) {
240 event_.reset(CreateXInput2Event(deviceid, evtype, tracking_id, location)); 241 event_.reset(CreateXInput2Event(deviceid, evtype, tracking_id, location));
241 SetUpValuators(valuators); 242
243 // If a timestamp was specified, setup the event.
244 for (size_t i = 0; i < valuators.size(); ++i) {
245 if (valuators[i].data_type == DeviceDataManager::DT_TOUCH_RAW_TIMESTAMP) {
246 SetUpValuators(valuators);
247 return;
248 }
249 }
250
251 // No timestamp was specified. Use |ui::EventTimeForNow()|.
252 std::vector<Valuator> valuators_with_time = valuators;
253 valuators_with_time.push_back(
254 Valuator(DeviceDataManager::DT_TOUCH_RAW_TIMESTAMP,
255 (ui::EventTimeForNow()).InMicroseconds()));
256 SetUpValuators(valuators_with_time);
242 } 257 }
243 258
244 void ScopedXI2Event::SetUpValuators(const std::vector<Valuator>& valuators) { 259 void ScopedXI2Event::SetUpValuators(const std::vector<Valuator>& valuators) {
245 CHECK(event_.get()); 260 CHECK(event_.get());
246 CHECK_EQ(GenericEvent, event_->type); 261 CHECK_EQ(GenericEvent, event_->type);
247 XIDeviceEvent* xiev = static_cast<XIDeviceEvent*>(event_->xcookie.data); 262 XIDeviceEvent* xiev = static_cast<XIDeviceEvent*>(event_->xcookie.data);
248 InitValuatorsForXIDeviceEvent(xiev); 263 InitValuatorsForXIDeviceEvent(xiev);
249 ui::DeviceDataManager* manager = ui::DeviceDataManager::GetInstance(); 264 ui::DeviceDataManager* manager = ui::DeviceDataManager::GetInstance();
250 for (size_t i = 0; i < valuators.size(); ++i) { 265 for (size_t i = 0; i < valuators.size(); ++i) {
251 manager->SetValuatorDataForTest(xiev, valuators[i].data_type, 266 manager->SetValuatorDataForTest(xiev, valuators[i].data_type,
(...skipping 10 matching lines...) Expand all
262 manager->SetDeviceListForTest(std::vector<unsigned int>(), device_list); 277 manager->SetDeviceListForTest(std::vector<unsigned int>(), device_list);
263 } 278 }
264 279
265 void SetUpTouchDevicesForTest(const std::vector<unsigned int>& devices) { 280 void SetUpTouchDevicesForTest(const std::vector<unsigned int>& devices) {
266 TouchFactory::GetInstance()->SetTouchDeviceForTest(devices); 281 TouchFactory::GetInstance()->SetTouchDeviceForTest(devices);
267 ui::DeviceDataManager* manager = ui::DeviceDataManager::GetInstance(); 282 ui::DeviceDataManager* manager = ui::DeviceDataManager::GetInstance();
268 manager->SetDeviceListForTest(devices, std::vector<unsigned int>()); 283 manager->SetDeviceListForTest(devices, std::vector<unsigned int>());
269 } 284 }
270 285
271 } // namespace ui 286 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/gestures/gesture_recognizer_impl.cc ('k') | ui/views/widget/native_widget_aura_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698