Update V8 to version 4.7.16.
[chromium-blink-merge.git] / ui / events / test / events_test_utils_x11.h
blobf312c832e51bee54ad09391ea8a1b2e29e706b29
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
3 // found in the LICENSE file.
5 #ifndef UI_EVENTS_TEST_EVENTS_TEST_UTILS_X11_H_
6 #define UI_EVENTS_TEST_EVENTS_TEST_UTILS_X11_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "ui/events/devices/x11/device_data_manager_x11.h"
10 #include "ui/events/event_constants.h"
11 #include "ui/events/keycodes/keyboard_codes.h"
12 #include "ui/gfx/geometry/point.h"
13 #include "ui/gfx/x/x11_types.h"
15 typedef union _XEvent XEvent;
17 namespace ui {
19 struct Valuator {
20 Valuator(DeviceDataManagerX11::DataType type, double v)
21 : data_type(type), value(v) {}
23 DeviceDataManagerX11::DataType data_type;
24 double value;
27 struct XEventDeleter {
28 void operator()(XEvent* event);
31 class ScopedXI2Event {
32 public:
33 ScopedXI2Event();
34 ~ScopedXI2Event();
36 operator XEvent*() { return event_.get(); }
38 // 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
40 // <X11/X.h>.
41 void InitKeyEvent(EventType type,
42 KeyboardCode key_code,
43 int flags);
44 void InitMotionEvent(const gfx::Point& location,
45 const gfx::Point& root_location,
46 int flags);
48 // Initializes an Xinput2 key event.
49 // |deviceid| is the master, and |sourceid| is the slave device.
50 void InitGenericKeyEvent(int deviceid,
51 int sourceid,
52 EventType type,
53 KeyboardCode key_code,
54 int flags);
56 void InitGenericButtonEvent(int deviceid,
57 EventType type,
58 const gfx::Point& location,
59 int flags);
61 void InitGenericMouseWheelEvent(int deviceid,
62 int wheel_delta,
63 int flags);
65 void InitScrollEvent(int deviceid,
66 int x_offset,
67 int y_offset,
68 int x_offset_ordinal,
69 int y_offset_ordinal,
70 int finger_count);
72 void InitFlingScrollEvent(int deviceid,
73 int x_velocity,
74 int y_velocity,
75 int x_velocity_ordinal,
76 int y_velocity_ordinal,
77 bool is_cancel);
79 void InitTouchEvent(int deviceid,
80 int evtype,
81 int tracking_id,
82 const gfx::Point& location,
83 const std::vector<Valuator>& valuators);
85 private:
86 void Cleanup();
88 void SetUpValuators(const std::vector<Valuator>& valuators);
90 scoped_ptr<XEvent, XEventDeleter> event_;
92 DISALLOW_COPY_AND_ASSIGN(ScopedXI2Event);
95 // Initializes a test touchpad device for scroll events.
96 void SetUpTouchPadForTest(int deviceid);
98 // Initializes a list of touchscreen devices for touch events.
99 void SetUpTouchDevicesForTest(const std::vector<int>& devices);
101 // Initializes a list of non-touch, non-cmt pointer devices.
102 void SetUpPointerDevicesForTest(const std::vector<int>& devices);
104 } // namespace ui
106 #endif // UI_EVENTS_TEST_EVENTS_TEST_UTILS_X11_H_