Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / ui / events / test / events_test_utils_x11.h
blobdd8c504fb9d55a8396f23f728a3ff43e76e15450
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/event_constants.h"
10 #include "ui/events/keycodes/keyboard_codes.h"
11 #include "ui/events/x/device_data_manager_x11.h"
12 #include "ui/gfx/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);
45 void InitGenericKeyEvent(int deviceid,
46 EventType type,
47 KeyboardCode key_code,
48 int flags);
50 void InitGenericButtonEvent(int deviceid,
51 EventType type,
52 const gfx::Point& location,
53 int flags);
55 void InitGenericMouseWheelEvent(int deviceid,
56 int wheel_delta,
57 int flags);
59 void InitScrollEvent(int deviceid,
60 int x_offset,
61 int y_offset,
62 int x_offset_ordinal,
63 int y_offset_ordinal,
64 int finger_count);
66 void InitFlingScrollEvent(int deviceid,
67 int x_velocity,
68 int y_velocity,
69 int x_velocity_ordinal,
70 int y_velocity_ordinal,
71 bool is_cancel);
73 void InitTouchEvent(int deviceid,
74 int evtype,
75 int tracking_id,
76 const gfx::Point& location,
77 const std::vector<Valuator>& valuators);
79 private:
80 void Cleanup();
82 void SetUpValuators(const std::vector<Valuator>& valuators);
84 scoped_ptr<XEvent, XEventDeleter> event_;
86 DISALLOW_COPY_AND_ASSIGN(ScopedXI2Event);
89 // Initializes a test touchpad device for scroll events.
90 void SetUpTouchPadForTest(unsigned int deviceid);
92 // Initializes a list of touchscreen devices for touch events.
93 void SetUpTouchDevicesForTest(const std::vector<unsigned int>& devices);
95 } // namespace ui
97 #endif // UI_EVENTS_TEST_EVENTS_TEST_UTILS_X11_H_