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 #ifndef UI_EVENTS_TEST_EVENTS_TEST_UTILS_X11_H_ | 5 #ifndef UI_EVENTS_TEST_EVENTS_TEST_UTILS_X11_H_ |
6 #define UI_EVENTS_TEST_EVENTS_TEST_UTILS_X11_H_ | 6 #define UI_EVENTS_TEST_EVENTS_TEST_UTILS_X11_H_ |
7 | 7 |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "ui/events/event_constants.h" | 9 #include "ui/events/event_constants.h" |
10 #include "ui/events/keycodes/keyboard_codes.h" | 10 #include "ui/events/keycodes/keyboard_codes.h" |
11 #include "ui/events/x/device_data_manager.h" | 11 #include "ui/events/x/device_data_manager.h" |
12 #include "ui/gfx/point.h" | 12 #include "ui/gfx/point.h" |
13 #include "ui/gfx/x/x11_types.h" | 13 #include "ui/gfx/x/x11_types.h" |
14 | 14 |
15 typedef union _XEvent XEvent; | 15 typedef union _XEvent XEvent; |
16 | 16 |
17 namespace ui { | 17 namespace ui { |
18 | 18 |
19 struct Valuator { | 19 struct Valuator { |
20 Valuator(DeviceDataManager::DataType type, double v) | 20 Valuator(DeviceDataManager::DataType type, double v) |
21 : data_type(type), value(v) {} | 21 : data_type(type), value(v) {} |
22 | 22 |
23 DeviceDataManager::DataType data_type; | 23 DeviceDataManager::DataType data_type; |
24 double value; | 24 double value; |
25 }; | 25 }; |
26 | 26 |
27 struct XEventDeleter { | |
28 void operator()(XEvent* event); | |
29 }; | |
30 | |
31 class ScopedXI2Event { | 27 class ScopedXI2Event { |
32 public: | 28 public: |
33 ScopedXI2Event(); | 29 ScopedXI2Event(); |
34 ~ScopedXI2Event(); | 30 ~ScopedXI2Event(); |
35 | 31 |
36 operator XEvent*() { return event_.get(); } | 32 operator XEvent*() { return event_.get(); } |
37 | 33 |
38 // Initializes a XEvent with for the appropriate type with the specified data. | 34 // Initializes a XEvent with for the appropriate type with the specified data. |
39 // Note that ui::EF_ flags should be passed as |flags|, not the native ones in | 35 // Note that ui::EF_ flags should be passed as |flags|, not the native ones in |
40 // <X11/X.h>. | 36 // <X11/X.h>. |
(...skipping 29 matching lines...) Expand all Loading... |
70 int evtype, | 66 int evtype, |
71 int tracking_id, | 67 int tracking_id, |
72 const gfx::Point& location, | 68 const gfx::Point& location, |
73 const std::vector<Valuator>& valuators); | 69 const std::vector<Valuator>& valuators); |
74 | 70 |
75 private: | 71 private: |
76 void Cleanup(); | 72 void Cleanup(); |
77 | 73 |
78 void SetUpValuators(const std::vector<Valuator>& valuators); | 74 void SetUpValuators(const std::vector<Valuator>& valuators); |
79 | 75 |
80 scoped_ptr<XEvent, XEventDeleter> event_; | 76 scoped_ptr<XEvent> event_; |
81 | 77 |
82 DISALLOW_COPY_AND_ASSIGN(ScopedXI2Event); | 78 DISALLOW_COPY_AND_ASSIGN(ScopedXI2Event); |
83 }; | 79 }; |
84 | 80 |
85 // Initializes a test touchpad device for scroll events. | 81 // Initializes a test touchpad device for scroll events. |
86 void SetUpScrollDeviceForTest(unsigned int deviceid); | 82 void SetUpScrollDeviceForTest(unsigned int deviceid); |
87 | 83 |
88 // Initializes a list of touchscreen devices for touch events. | 84 // Initializes a list of touchscreen devices for touch events. |
89 void SetUpTouchDevicesForTest(const std::vector<unsigned int>& devices); | 85 void SetUpTouchDevicesForTest(const std::vector<unsigned int>& devices); |
90 | 86 |
91 } // namespace ui | 87 } // namespace ui |
92 | 88 |
93 #endif // UI_EVENTS_TEST_EVENTS_TEST_UTILS_X11_H_ | 89 #endif // UI_EVENTS_TEST_EVENTS_TEST_UTILS_X11_H_ |
OLD | NEW |