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

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 non-monotonic timestamps 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);
sadrul 2014/06/02 13:31:23 Did you mean to return from here?
tdresser 2014/06/02 14:00:38 Thanks for catching that. Done.
247 }
248
249 // No timestamp was specified. Use |ui::EventTimeForNow()|.
250 std::vector<Valuator> valuators_with_time = valuators;
251 valuators_with_time.push_back(
252 Valuator(DeviceDataManager::DT_TOUCH_RAW_TIMESTAMP,
253 (ui::EventTimeForNow()).InMicroseconds()));
254 SetUpValuators(valuators_with_time);
242 } 255 }
243 256
244 void ScopedXI2Event::SetUpValuators(const std::vector<Valuator>& valuators) { 257 void ScopedXI2Event::SetUpValuators(const std::vector<Valuator>& valuators) {
245 CHECK(event_.get()); 258 CHECK(event_.get());
246 CHECK_EQ(GenericEvent, event_->type); 259 CHECK_EQ(GenericEvent, event_->type);
247 XIDeviceEvent* xiev = static_cast<XIDeviceEvent*>(event_->xcookie.data); 260 XIDeviceEvent* xiev = static_cast<XIDeviceEvent*>(event_->xcookie.data);
248 InitValuatorsForXIDeviceEvent(xiev); 261 InitValuatorsForXIDeviceEvent(xiev);
249 ui::DeviceDataManager* manager = ui::DeviceDataManager::GetInstance(); 262 ui::DeviceDataManager* manager = ui::DeviceDataManager::GetInstance();
250 for (size_t i = 0; i < valuators.size(); ++i) { 263 for (size_t i = 0; i < valuators.size(); ++i) {
251 manager->SetValuatorDataForTest(xiev, valuators[i].data_type, 264 manager->SetValuatorDataForTest(xiev, valuators[i].data_type,
(...skipping 10 matching lines...) Expand all
262 manager->SetDeviceListForTest(std::vector<unsigned int>(), device_list); 275 manager->SetDeviceListForTest(std::vector<unsigned int>(), device_list);
263 } 276 }
264 277
265 void SetUpTouchDevicesForTest(const std::vector<unsigned int>& devices) { 278 void SetUpTouchDevicesForTest(const std::vector<unsigned int>& devices) {
266 TouchFactory::GetInstance()->SetTouchDeviceForTest(devices); 279 TouchFactory::GetInstance()->SetTouchDeviceForTest(devices);
267 ui::DeviceDataManager* manager = ui::DeviceDataManager::GetInstance(); 280 ui::DeviceDataManager* manager = ui::DeviceDataManager::GetInstance();
268 manager->SetDeviceListForTest(devices, std::vector<unsigned int>()); 281 manager->SetDeviceListForTest(devices, std::vector<unsigned int>());
269 } 282 }
270 283
271 } // namespace ui 284 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698