1 // Copyright (c) 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 #include "base/memory/scoped_ptr.h"
6 #include "ui/events/event_constants.h"
7 #include "ui/events/events_export.h"
8 #include "ui/events/keycodes/keyboard_codes.h"
9 #include "ui/events/x/device_data_manager.h"
10 #include "ui/gfx/point.h"
11 #include "ui/gfx/x/x11_types.h"
13 typedef union _XEvent XEvent
;
18 Valuator(DeviceDataManager::DataType type
, double v
)
19 : data_type(type
), value(v
) {}
21 DeviceDataManager::DataType data_type
;
25 class EVENTS_EXPORT ScopedXI2Event
{
27 explicit ScopedXI2Event(XEvent
* event
);
30 operator XEvent
*() { return event_
.get(); }
33 scoped_ptr
<XEvent
> event_
;
35 DISALLOW_COPY_AND_ASSIGN(ScopedXI2Event
);
38 // Initializes a XEvent that holds XKeyEvent for testing. Note that ui::EF_
39 // flags should be passed as |flags|, not the native ones in <X11/X.h>.
40 EVENTS_EXPORT
void InitXKeyEventForTesting(EventType type
,
41 KeyboardCode key_code
,
45 // Initializes a XEvent that holds XButtonEvent for testing. Note that ui::EF_
46 // flags should be passed as |flags|, not the native ones in <X11/X.h>.
47 EVENTS_EXPORT
void InitXButtonEventForTesting(EventType type
,
51 // Initializes an XEvent for an Aura MouseWheelEvent. The underlying native
52 // event is an XButtonEvent.
53 EVENTS_EXPORT
void InitXMouseWheelEventForTesting(int wheel_delta
,
57 // Creates a native scroll event, based on a XInput2Event. The caller is
58 // responsible for the ownership of the returned XEvent. Consider wrapping
59 // the XEvent in a ScopedXI2Event, as XEvent is purely a struct and simply
60 // deleting it will result in dangling pointers.
61 EVENTS_EXPORT XEvent
* CreateScrollEventForTest(
69 // Initializes a test touchpad device for scroll events.
70 EVENTS_EXPORT
void SetUpScrollDeviceForTest(unsigned int deviceid
);
72 #if defined(USE_XI2_MT)
74 EVENTS_EXPORT XEvent
* CreateTouchEventForTest(
78 const gfx::Point
& location
,
79 const std::vector
<Valuator
>& valuators
);
81 EVENTS_EXPORT
void SetupTouchDevicesForTest(
82 const std::vector
<unsigned int>& devices
);