Commit c21dfe90 authored by spang's avatar spang Committed by Commit bot

ozone: evdev: Move EventModifiersEvdev usage to EventFactoryEvdev

This is part of a series moving IO on evdev devices to a fast thread,
since UI thread is too slow for the cursor.

EventModifiersEvdev is a UI thread object, so move all remaining
ui::Event construction outside of the device-specific objects. Devices
no longer get a EventModifiersEvdev* since they will execute on a
different thread.

This completes the series moving ui::Event construction out of device
objects and into EventFactoryEvdev.

BUG=449710
TEST=boot link_freon & click mouse

Review URL: https://codereview.chromium.org/867803004

Cr-Commit-Position: refs/heads/master@{#313464}
parent e6117333
...@@ -27,7 +27,6 @@ EventConverterEvdevImpl::EventConverterEvdevImpl( ...@@ -27,7 +27,6 @@ EventConverterEvdevImpl::EventConverterEvdevImpl(
int id, int id,
InputDeviceType type, InputDeviceType type,
const EventDeviceInfo& devinfo, const EventDeviceInfo& devinfo,
EventModifiersEvdev* modifiers,
CursorDelegateEvdev* cursor, CursorDelegateEvdev* cursor,
const KeyEventDispatchCallback& key_callback, const KeyEventDispatchCallback& key_callback,
const MouseMoveEventDispatchCallback& mouse_move_callback, const MouseMoveEventDispatchCallback& mouse_move_callback,
...@@ -38,7 +37,6 @@ EventConverterEvdevImpl::EventConverterEvdevImpl( ...@@ -38,7 +37,6 @@ EventConverterEvdevImpl::EventConverterEvdevImpl(
x_offset_(0), x_offset_(0),
y_offset_(0), y_offset_(0),
cursor_(cursor), cursor_(cursor),
modifiers_(modifiers),
key_callback_(key_callback), key_callback_(key_callback),
mouse_move_callback_(mouse_move_callback), mouse_move_callback_(mouse_move_callback),
mouse_button_callback_(mouse_button_callback) { mouse_button_callback_(mouse_button_callback) {
......
...@@ -32,7 +32,6 @@ class EVENTS_OZONE_EVDEV_EXPORT EventConverterEvdevImpl ...@@ -32,7 +32,6 @@ class EVENTS_OZONE_EVDEV_EXPORT EventConverterEvdevImpl
int id, int id,
InputDeviceType type, InputDeviceType type,
const EventDeviceInfo& info, const EventDeviceInfo& info,
EventModifiersEvdev* modifiers,
CursorDelegateEvdev* cursor, CursorDelegateEvdev* cursor,
const KeyEventDispatchCallback& key_callback, const KeyEventDispatchCallback& key_callback,
const MouseMoveEventDispatchCallback& mouse_move_callback, const MouseMoveEventDispatchCallback& mouse_move_callback,
...@@ -79,9 +78,6 @@ class EVENTS_OZONE_EVDEV_EXPORT EventConverterEvdevImpl ...@@ -79,9 +78,6 @@ class EVENTS_OZONE_EVDEV_EXPORT EventConverterEvdevImpl
// Shared cursor state. // Shared cursor state.
CursorDelegateEvdev* cursor_; CursorDelegateEvdev* cursor_;
// Modifier key state (shift, ctrl, etc).
EventModifiersEvdev* modifiers_;
// Callbacks for dispatching events. // Callbacks for dispatching events.
KeyEventDispatchCallback key_callback_; KeyEventDispatchCallback key_callback_;
MouseMoveEventDispatchCallback mouse_move_callback_; MouseMoveEventDispatchCallback mouse_move_callback_;
......
...@@ -26,7 +26,6 @@ class MockEventConverterEvdevImpl : public EventConverterEvdevImpl { ...@@ -26,7 +26,6 @@ class MockEventConverterEvdevImpl : public EventConverterEvdevImpl {
public: public:
MockEventConverterEvdevImpl( MockEventConverterEvdevImpl(
int fd, int fd,
EventModifiersEvdev* modifiers,
CursorDelegateEvdev* cursor, CursorDelegateEvdev* cursor,
const KeyEventDispatchCallback& key_callback, const KeyEventDispatchCallback& key_callback,
const MouseMoveEventDispatchCallback& mouse_move_callback, const MouseMoveEventDispatchCallback& mouse_move_callback,
...@@ -36,7 +35,6 @@ class MockEventConverterEvdevImpl : public EventConverterEvdevImpl { ...@@ -36,7 +35,6 @@ class MockEventConverterEvdevImpl : public EventConverterEvdevImpl {
1, 1,
INPUT_DEVICE_UNKNOWN, INPUT_DEVICE_UNKNOWN,
EventDeviceInfo(), EventDeviceInfo(),
modifiers,
cursor, cursor,
key_callback, key_callback,
mouse_move_callback, mouse_move_callback,
...@@ -133,7 +131,7 @@ class EventConverterEvdevImplTest : public testing::Test { ...@@ -133,7 +131,7 @@ class EventConverterEvdevImplTest : public testing::Test {
base::Unretained(this)))); base::Unretained(this))));
device_.reset(new ui::MockEventConverterEvdevImpl( device_.reset(new ui::MockEventConverterEvdevImpl(
events_in_, event_factory_->modifiers(), cursor_.get(), events_in_, cursor_.get(),
base::Bind(&ui::EventFactoryEvdev::PostKeyEvent, base::Bind(&ui::EventFactoryEvdev::PostKeyEvent,
base::Unretained(event_factory_.get())), base::Unretained(event_factory_.get())),
base::Bind(&ui::EventFactoryEvdev::PostMouseMoveEvent, base::Bind(&ui::EventFactoryEvdev::PostMouseMoveEvent,
......
...@@ -44,6 +44,39 @@ MouseButtonEventParams::MouseButtonEventParams( ...@@ -44,6 +44,39 @@ MouseButtonEventParams::MouseButtonEventParams(
MouseButtonEventParams::~MouseButtonEventParams() { MouseButtonEventParams::~MouseButtonEventParams() {
} }
MouseWheelEventParams::MouseWheelEventParams(int device_id,
const gfx::PointF& location,
const gfx::Vector2d& delta)
: device_id(device_id), location(location), delta(delta) {
}
MouseWheelEventParams::MouseWheelEventParams(
const MouseWheelEventParams& other) = default;
MouseWheelEventParams::~MouseWheelEventParams() {
}
ScrollEventParams::ScrollEventParams(int device_id,
EventType type,
const gfx::PointF location,
const gfx::Vector2dF delta,
const gfx::Vector2dF ordinal_delta,
int finger_count,
const base::TimeDelta timestamp)
: device_id(device_id),
type(type),
location(location),
delta(delta),
ordinal_delta(ordinal_delta),
finger_count(finger_count),
timestamp(timestamp) {
}
ScrollEventParams::ScrollEventParams(const ScrollEventParams& other) = default;
ScrollEventParams::~ScrollEventParams() {
}
TouchEventParams::TouchEventParams(int device_id, TouchEventParams::TouchEventParams(int device_id,
int touch_id, int touch_id,
EventType type, EventType type,
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "ui/events/event_constants.h" #include "ui/events/event_constants.h"
#include "ui/events/ozone/evdev/events_ozone_evdev_export.h" #include "ui/events/ozone/evdev/events_ozone_evdev_export.h"
#include "ui/gfx/geometry/point_f.h" #include "ui/gfx/geometry/point_f.h"
#include "ui/gfx/geometry/vector2d.h"
#include "ui/gfx/geometry/vector2d_f.h" #include "ui/gfx/geometry/vector2d_f.h"
namespace base { namespace base {
...@@ -18,6 +19,7 @@ class TimeDelta; ...@@ -18,6 +19,7 @@ class TimeDelta;
namespace gfx { namespace gfx {
class PointF; class PointF;
class Vector2d;
class Vector2dF; class Vector2dF;
} }
...@@ -71,6 +73,44 @@ struct EVENTS_OZONE_EVDEV_EXPORT MouseButtonEventParams { ...@@ -71,6 +73,44 @@ struct EVENTS_OZONE_EVDEV_EXPORT MouseButtonEventParams {
typedef base::Callback<void(const MouseButtonEventParams& params)> typedef base::Callback<void(const MouseButtonEventParams& params)>
MouseButtonEventDispatchCallback; MouseButtonEventDispatchCallback;
struct EVENTS_OZONE_EVDEV_EXPORT MouseWheelEventParams {
MouseWheelEventParams(int device_id,
const gfx::PointF& location,
const gfx::Vector2d& delta);
MouseWheelEventParams(const MouseWheelEventParams& other);
~MouseWheelEventParams();
int device_id;
gfx::PointF location;
gfx::Vector2d delta;
};
typedef base::Callback<void(const MouseWheelEventParams& params)>
MouseWheelEventDispatchCallback;
struct EVENTS_OZONE_EVDEV_EXPORT ScrollEventParams {
ScrollEventParams(int device_id,
EventType type,
const gfx::PointF location,
const gfx::Vector2dF delta,
const gfx::Vector2dF ordinal_delta,
int finger_count,
const base::TimeDelta timestamp);
ScrollEventParams(const ScrollEventParams& other);
~ScrollEventParams();
int device_id;
EventType type;
const gfx::PointF location;
const gfx::Vector2dF delta;
const gfx::Vector2dF ordinal_delta;
int finger_count;
const base::TimeDelta timestamp;
};
typedef base::Callback<void(const ScrollEventParams& params)>
ScrollEventDispatchCallback;
struct EVENTS_OZONE_EVDEV_EXPORT TouchEventParams { struct EVENTS_OZONE_EVDEV_EXPORT TouchEventParams {
TouchEventParams(int device_id, TouchEventParams(int device_id,
int touch_id, int touch_id,
......
...@@ -50,14 +50,14 @@ struct OpenInputDeviceParams { ...@@ -50,14 +50,14 @@ struct OpenInputDeviceParams {
base::FilePath path; base::FilePath path;
// Callback for dispatching events. Call on UI thread only. // Callback for dispatching events. Call on UI thread only.
EventDispatchCallback dispatch_callback;
KeyEventDispatchCallback key_callback; KeyEventDispatchCallback key_callback;
MouseMoveEventDispatchCallback mouse_move_callback; MouseMoveEventDispatchCallback mouse_move_callback;
MouseButtonEventDispatchCallback mouse_button_callback; MouseButtonEventDispatchCallback mouse_button_callback;
MouseWheelEventDispatchCallback mouse_wheel_callback;
ScrollEventDispatchCallback scroll_callback;
TouchEventDispatchCallback touch_callback; TouchEventDispatchCallback touch_callback;
// State shared between devices. Must not be dereferenced on worker thread. // State shared between devices. Must not be dereferenced on worker thread.
EventModifiersEvdev* modifiers;
CursorDelegateEvdev* cursor; CursorDelegateEvdev* cursor;
#if defined(USE_EVDEV_GESTURES) #if defined(USE_EVDEV_GESTURES)
GesturePropertyProvider* gesture_property_provider; GesturePropertyProvider* gesture_property_provider;
...@@ -87,10 +87,10 @@ scoped_ptr<EventConverterEvdev> CreateConverter( ...@@ -87,10 +87,10 @@ scoped_ptr<EventConverterEvdev> CreateConverter(
if (UseGesturesLibraryForDevice(devinfo)) { if (UseGesturesLibraryForDevice(devinfo)) {
scoped_ptr<GestureInterpreterLibevdevCros> gesture_interp = scoped_ptr<GestureInterpreterLibevdevCros> gesture_interp =
make_scoped_ptr(new GestureInterpreterLibevdevCros( make_scoped_ptr(new GestureInterpreterLibevdevCros(
params.id, params.modifiers, params.cursor, params.id, params.cursor, params.gesture_property_provider,
params.gesture_property_provider, params.key_callback, params.key_callback, params.mouse_move_callback,
params.mouse_move_callback, params.mouse_button_callback, params.mouse_button_callback, params.mouse_wheel_callback,
params.dispatch_callback)); params.scroll_callback));
return make_scoped_ptr(new EventReaderLibevdevCros( return make_scoped_ptr(new EventReaderLibevdevCros(
fd, params.path, params.id, type, devinfo, gesture_interp.Pass())); fd, params.path, params.id, type, devinfo, gesture_interp.Pass()));
} }
...@@ -107,13 +107,13 @@ scoped_ptr<EventConverterEvdev> CreateConverter( ...@@ -107,13 +107,13 @@ scoped_ptr<EventConverterEvdev> CreateConverter(
// Graphics tablet // Graphics tablet
if (devinfo.HasAbsXY()) if (devinfo.HasAbsXY())
return make_scoped_ptr<EventConverterEvdev>(new TabletEventConverterEvdev( return make_scoped_ptr<EventConverterEvdev>(new TabletEventConverterEvdev(
fd, params.path, params.id, type, params.modifiers, params.cursor, fd, params.path, params.id, type, params.cursor, devinfo,
devinfo, params.dispatch_callback)); params.mouse_move_callback, params.mouse_button_callback));
// Everything else: use EventConverterEvdevImpl. // Everything else: use EventConverterEvdevImpl.
return make_scoped_ptr<EventConverterEvdevImpl>(new EventConverterEvdevImpl( return make_scoped_ptr<EventConverterEvdevImpl>(new EventConverterEvdevImpl(
fd, params.path, params.id, type, devinfo, params.modifiers, fd, params.path, params.id, type, devinfo, params.cursor,
params.cursor, params.key_callback, params.mouse_move_callback, params.key_callback, params.mouse_move_callback,
params.mouse_button_callback)); params.mouse_button_callback));
} }
...@@ -248,6 +248,24 @@ void EventFactoryEvdev::PostMouseButtonEvent( ...@@ -248,6 +248,24 @@ void EventFactoryEvdev::PostMouseButtonEvent(
PostUiEvent(event.Pass()); PostUiEvent(event.Pass());
} }
void EventFactoryEvdev::PostMouseWheelEvent(
const MouseWheelEventParams& params) {
scoped_ptr<MouseWheelEvent> event(new MouseWheelEvent(
params.delta, params.location, params.location,
modifiers_.GetModifierFlags(), 0 /* changed_button_flags */));
event->set_source_device_id(params.device_id);
PostUiEvent(event.Pass());
}
void EventFactoryEvdev::PostScrollEvent(const ScrollEventParams& params) {
scoped_ptr<ScrollEvent> event(new ScrollEvent(
params.type, params.location, params.timestamp,
modifiers_.GetModifierFlags(), params.delta.x(), params.delta.y(),
params.ordinal_delta.x(), params.ordinal_delta.y(), params.finger_count));
event->set_source_device_id(params.device_id);
PostUiEvent(event.Pass());
}
void EventFactoryEvdev::PostTouchEvent(const TouchEventParams& params) { void EventFactoryEvdev::PostTouchEvent(const TouchEventParams& params) {
float x = params.location.x(); float x = params.location.x();
float y = params.location.y(); float y = params.location.y();
...@@ -313,8 +331,6 @@ void EventFactoryEvdev::OnDeviceEvent(const DeviceEvent& event) { ...@@ -313,8 +331,6 @@ void EventFactoryEvdev::OnDeviceEvent(const DeviceEvent& event) {
scoped_ptr<OpenInputDeviceParams> params(new OpenInputDeviceParams); scoped_ptr<OpenInputDeviceParams> params(new OpenInputDeviceParams);
params->id = NextDeviceId(); params->id = NextDeviceId();
params->path = event.path(); params->path = event.path();
params->dispatch_callback = dispatch_callback_;
params->modifiers = &modifiers_;
params->cursor = cursor_; params->cursor = cursor_;
params->key_callback = base::Bind(&EventFactoryEvdev::PostKeyEvent, params->key_callback = base::Bind(&EventFactoryEvdev::PostKeyEvent,
weak_ptr_factory_.GetWeakPtr()); weak_ptr_factory_.GetWeakPtr());
...@@ -324,6 +340,11 @@ void EventFactoryEvdev::OnDeviceEvent(const DeviceEvent& event) { ...@@ -324,6 +340,11 @@ void EventFactoryEvdev::OnDeviceEvent(const DeviceEvent& event) {
params->mouse_button_callback = params->mouse_button_callback =
base::Bind(&EventFactoryEvdev::PostMouseButtonEvent, base::Bind(&EventFactoryEvdev::PostMouseButtonEvent,
weak_ptr_factory_.GetWeakPtr()); weak_ptr_factory_.GetWeakPtr());
params->mouse_wheel_callback =
base::Bind(&EventFactoryEvdev::PostMouseWheelEvent,
weak_ptr_factory_.GetWeakPtr());
params->scroll_callback = base::Bind(&EventFactoryEvdev::PostScrollEvent,
weak_ptr_factory_.GetWeakPtr());
params->touch_callback = base::Bind(&EventFactoryEvdev::PostTouchEvent, params->touch_callback = base::Bind(&EventFactoryEvdev::PostTouchEvent,
weak_ptr_factory_.GetWeakPtr()); weak_ptr_factory_.GetWeakPtr());
......
...@@ -78,13 +78,12 @@ class EVENTS_OZONE_EVDEV_EXPORT EventFactoryEvdev : public DeviceEventObserver, ...@@ -78,13 +78,12 @@ class EVENTS_OZONE_EVDEV_EXPORT EventFactoryEvdev : public DeviceEventObserver,
InputController* input_controller() { return &input_controller_; } InputController* input_controller() { return &input_controller_; }
// Transitional accessors for testing.
EventModifiersEvdev* modifiers() { return &modifiers_; }
// Post events to UI. // Post events to UI.
void PostKeyEvent(const KeyEventParams& params); void PostKeyEvent(const KeyEventParams& params);
void PostMouseMoveEvent(const MouseMoveEventParams& params); void PostMouseMoveEvent(const MouseMoveEventParams& params);
void PostMouseButtonEvent(const MouseButtonEventParams& params); void PostMouseButtonEvent(const MouseButtonEventParams& params);
void PostMouseWheelEvent(const MouseWheelEventParams& parms);
void PostScrollEvent(const ScrollEventParams& params);
void PostTouchEvent(const TouchEventParams& params); void PostTouchEvent(const TouchEventParams& params);
protected: protected:
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
#include "ui/events/ozone/evdev/cursor_delegate_evdev.h" #include "ui/events/ozone/evdev/cursor_delegate_evdev.h"
#include "ui/events/ozone/evdev/event_device_info.h" #include "ui/events/ozone/evdev/event_device_info.h"
#include "ui/events/ozone/evdev/event_device_util.h" #include "ui/events/ozone/evdev/event_device_util.h"
#include "ui/events/ozone/evdev/event_modifiers_evdev.h"
#include "ui/events/ozone/evdev/keyboard_util_evdev.h" #include "ui/events/ozone/evdev/keyboard_util_evdev.h"
#include "ui/events/ozone/evdev/libgestures_glue/gesture_property_provider.h" #include "ui/events/ozone/evdev/libgestures_glue/gesture_property_provider.h"
#include "ui/events/ozone/evdev/libgestures_glue/gesture_timer_provider.h" #include "ui/events/ozone/evdev/libgestures_glue/gesture_timer_provider.h"
...@@ -88,22 +87,22 @@ const int kGestureSwipeFingerCount = 3; ...@@ -88,22 +87,22 @@ const int kGestureSwipeFingerCount = 3;
GestureInterpreterLibevdevCros::GestureInterpreterLibevdevCros( GestureInterpreterLibevdevCros::GestureInterpreterLibevdevCros(
int id, int id,
EventModifiersEvdev* modifiers,
CursorDelegateEvdev* cursor, CursorDelegateEvdev* cursor,
GesturePropertyProvider* property_provider, GesturePropertyProvider* property_provider,
const KeyEventDispatchCallback& key_callback, const KeyEventDispatchCallback& key_callback,
const MouseMoveEventDispatchCallback& mouse_move_callback, const MouseMoveEventDispatchCallback& mouse_move_callback,
const MouseButtonEventDispatchCallback& mouse_button_callback, const MouseButtonEventDispatchCallback& mouse_button_callback,
const EventDispatchCallback& callback) const MouseWheelEventDispatchCallback& mouse_wheel_callback,
const ScrollEventDispatchCallback& scroll_callback)
: id_(id), : id_(id),
is_mouse_(false), is_mouse_(false),
modifiers_(modifiers),
cursor_(cursor), cursor_(cursor),
property_provider_(property_provider), property_provider_(property_provider),
key_callback_(key_callback), key_callback_(key_callback),
mouse_move_callback_(mouse_move_callback), mouse_move_callback_(mouse_move_callback),
mouse_button_callback_(mouse_button_callback), mouse_button_callback_(mouse_button_callback),
dispatch_callback_(callback), mouse_wheel_callback_(mouse_wheel_callback),
scroll_callback_(scroll_callback),
interpreter_(NULL), interpreter_(NULL),
evdev_(NULL), evdev_(NULL),
device_properties_(new GestureDeviceProperties) { device_properties_(new GestureDeviceProperties) {
...@@ -294,23 +293,14 @@ void GestureInterpreterLibevdevCros::OnGestureScroll( ...@@ -294,23 +293,14 @@ void GestureInterpreterLibevdevCros::OnGestureScroll(
// TODO(spang): Use scroll->start_time // TODO(spang): Use scroll->start_time
if (is_mouse_) { if (is_mouse_) {
Dispatch(make_scoped_ptr(new MouseWheelEvent( mouse_wheel_callback_.Run(MouseWheelEventParams(
gfx::Vector2d(scroll->dx, scroll->dy), id_, cursor_->GetLocation(), gfx::Vector2d(scroll->dx, scroll->dy)));
cursor_->GetLocation(),
cursor_->GetLocation(),
modifiers_->GetModifierFlags(),
0)));
} else { } else {
Dispatch(make_scoped_ptr(new ScrollEvent( scroll_callback_.Run(ScrollEventParams(
ET_SCROLL, id_, ET_SCROLL, cursor_->GetLocation(),
cursor_->GetLocation(), gfx::Vector2dF(scroll->dx, scroll->dy),
StimeToTimedelta(gesture->end_time), gfx::Vector2dF(scroll->ordinal_dx, scroll->ordinal_dy),
modifiers_->GetModifierFlags(), kGestureScrollFingerCount, StimeToTimedelta(gesture->end_time)));
scroll->dx,
scroll->dy,
scroll->ordinal_dx,
scroll->ordinal_dy,
kGestureScrollFingerCount)));
} }
} }
...@@ -362,15 +352,10 @@ void GestureInterpreterLibevdevCros::OnGestureFling(const Gesture* gesture, ...@@ -362,15 +352,10 @@ void GestureInterpreterLibevdevCros::OnGestureFling(const Gesture* gesture,
: ET_SCROLL_FLING_CANCEL); : ET_SCROLL_FLING_CANCEL);
// Fling is like 2-finger scrolling but with velocity instead of displacement. // Fling is like 2-finger scrolling but with velocity instead of displacement.
Dispatch(make_scoped_ptr(new ScrollEvent(type, scroll_callback_.Run(ScrollEventParams(
cursor_->GetLocation(), id_, type, cursor_->GetLocation(), gfx::Vector2dF(fling->vx, fling->vy),
StimeToTimedelta(gesture->end_time), gfx::Vector2dF(fling->ordinal_vx, fling->ordinal_vy),
modifiers_->GetModifierFlags(), kGestureScrollFingerCount, StimeToTimedelta(gesture->end_time)));
fling->vx,
fling->vy,
fling->ordinal_vx,
fling->ordinal_vy,
kGestureScrollFingerCount)));
} }
void GestureInterpreterLibevdevCros::OnGestureSwipe(const Gesture* gesture, void GestureInterpreterLibevdevCros::OnGestureSwipe(const Gesture* gesture,
...@@ -385,15 +370,11 @@ void GestureInterpreterLibevdevCros::OnGestureSwipe(const Gesture* gesture, ...@@ -385,15 +370,11 @@ void GestureInterpreterLibevdevCros::OnGestureSwipe(const Gesture* gesture,
return; // No cursor! return; // No cursor!
// Swipe is 3-finger scrolling. // Swipe is 3-finger scrolling.
Dispatch(make_scoped_ptr(new ScrollEvent(ET_SCROLL, scroll_callback_.Run(ScrollEventParams(
cursor_->GetLocation(), id_, ET_SCROLL, cursor_->GetLocation(),
StimeToTimedelta(gesture->end_time), gfx::Vector2dF(swipe->dx, swipe->dy),
modifiers_->GetModifierFlags(), gfx::Vector2dF(swipe->ordinal_dx, swipe->ordinal_dy),
swipe->dx, kGestureSwipeFingerCount, StimeToTimedelta(gesture->end_time)));
swipe->dy,
swipe->ordinal_dx,
swipe->ordinal_dy,
kGestureSwipeFingerCount)));
} }
void GestureInterpreterLibevdevCros::OnGestureSwipeLift( void GestureInterpreterLibevdevCros::OnGestureSwipeLift(
...@@ -407,15 +388,10 @@ void GestureInterpreterLibevdevCros::OnGestureSwipeLift( ...@@ -407,15 +388,10 @@ void GestureInterpreterLibevdevCros::OnGestureSwipeLift(
// Turn a swipe lift into a fling start. // Turn a swipe lift into a fling start.
// TODO(spang): Figure out why and put it in this comment. // TODO(spang): Figure out why and put it in this comment.
Dispatch(make_scoped_ptr(new ScrollEvent(ET_SCROLL_FLING_START, scroll_callback_.Run(ScrollEventParams(
cursor_->GetLocation(), id_, ET_SCROLL_FLING_START, cursor_->GetLocation(),
StimeToTimedelta(gesture->end_time), gfx::Vector2dF() /* delta */, gfx::Vector2dF() /* ordinal_delta */,
modifiers_->GetModifierFlags(), kGestureScrollFingerCount, StimeToTimedelta(gesture->end_time)));
/* x_offset */ 0,
/* y_offset */ 0,
/* x_offset_ordinal */ 0,
/* y_offset_ordinal */ 0,
kGestureScrollFingerCount)));
} }
void GestureInterpreterLibevdevCros::OnGesturePinch(const Gesture* gesture, void GestureInterpreterLibevdevCros::OnGesturePinch(const Gesture* gesture,
...@@ -439,10 +415,6 @@ void GestureInterpreterLibevdevCros::OnGestureMetrics( ...@@ -439,10 +415,6 @@ void GestureInterpreterLibevdevCros::OnGestureMetrics(
NOTIMPLEMENTED(); NOTIMPLEMENTED();
} }
void GestureInterpreterLibevdevCros::Dispatch(scoped_ptr<Event> event) {
dispatch_callback_.Run(event.Pass());
}
void GestureInterpreterLibevdevCros::DispatchMouseButton(unsigned int button, void GestureInterpreterLibevdevCros::DispatchMouseButton(unsigned int button,
bool down) { bool down) {
bool allow_remap = is_mouse_; bool allow_remap = is_mouse_;
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
namespace ui { namespace ui {
class EventDeviceInfo; class EventDeviceInfo;
class EventModifiersEvdev;
class CursorDelegateEvdev; class CursorDelegateEvdev;
struct GestureDeviceProperties; struct GestureDeviceProperties;
class GesturePropertyProvider; class GesturePropertyProvider;
...@@ -42,13 +41,13 @@ class EVENTS_OZONE_EVDEV_EXPORT GestureInterpreterLibevdevCros ...@@ -42,13 +41,13 @@ class EVENTS_OZONE_EVDEV_EXPORT GestureInterpreterLibevdevCros
public: public:
GestureInterpreterLibevdevCros( GestureInterpreterLibevdevCros(
int id, int id,
EventModifiersEvdev* modifiers,
CursorDelegateEvdev* cursor, CursorDelegateEvdev* cursor,
GesturePropertyProvider* property_provider, GesturePropertyProvider* property_provider,
const KeyEventDispatchCallback& key_callback, const KeyEventDispatchCallback& key_callback,
const MouseMoveEventDispatchCallback& mouse_move_callback, const MouseMoveEventDispatchCallback& mouse_move_callback,
const MouseButtonEventDispatchCallback& mouse_button_callback, const MouseButtonEventDispatchCallback& mouse_button_callback,
const EventDispatchCallback& callback); const MouseWheelEventDispatchCallback& mouse_wheel_callback,
const ScrollEventDispatchCallback& scroll_callback);
~GestureInterpreterLibevdevCros() override; ~GestureInterpreterLibevdevCros() override;
// Overriden from ui::EventReaderLibevdevCros::Delegate // Overriden from ui::EventReaderLibevdevCros::Delegate
...@@ -81,7 +80,6 @@ class EVENTS_OZONE_EVDEV_EXPORT GestureInterpreterLibevdevCros ...@@ -81,7 +80,6 @@ class EVENTS_OZONE_EVDEV_EXPORT GestureInterpreterLibevdevCros
void OnGesturePinch(const Gesture* gesture, const GesturePinch* pinch); void OnGesturePinch(const Gesture* gesture, const GesturePinch* pinch);
void OnGestureMetrics(const Gesture* gesture, const GestureMetrics* metrics); void OnGestureMetrics(const Gesture* gesture, const GestureMetrics* metrics);
void Dispatch(scoped_ptr<Event> event);
void DispatchMouseButton(unsigned int modifier, bool down); void DispatchMouseButton(unsigned int modifier, bool down);
void DispatchChangedKeys(Evdev* evdev, const timeval& time); void DispatchChangedKeys(Evdev* evdev, const timeval& time);
...@@ -96,9 +94,6 @@ class EVENTS_OZONE_EVDEV_EXPORT GestureInterpreterLibevdevCros ...@@ -96,9 +94,6 @@ class EVENTS_OZONE_EVDEV_EXPORT GestureInterpreterLibevdevCros
// should be processed. // should be processed.
scoped_ptr<std::set<int>> allowed_keys_; scoped_ptr<std::set<int>> allowed_keys_;
// Shared modifier state.
EventModifiersEvdev* modifiers_;
// Shared cursor state. // Shared cursor state.
CursorDelegateEvdev* cursor_; CursorDelegateEvdev* cursor_;
...@@ -109,7 +104,8 @@ class EVENTS_OZONE_EVDEV_EXPORT GestureInterpreterLibevdevCros ...@@ -109,7 +104,8 @@ class EVENTS_OZONE_EVDEV_EXPORT GestureInterpreterLibevdevCros
KeyEventDispatchCallback key_callback_; KeyEventDispatchCallback key_callback_;
MouseMoveEventDispatchCallback mouse_move_callback_; MouseMoveEventDispatchCallback mouse_move_callback_;
MouseButtonEventDispatchCallback mouse_button_callback_; MouseButtonEventDispatchCallback mouse_button_callback_;
EventDispatchCallback dispatch_callback_; MouseWheelEventDispatchCallback mouse_wheel_callback_;
ScrollEventDispatchCallback scroll_callback_;
// Gestures interpretation state. // Gestures interpretation state.
gestures::GestureInterpreter* interpreter_; gestures::GestureInterpreter* interpreter_;
......
...@@ -17,14 +17,14 @@ TabletEventConverterEvdev::TabletEventConverterEvdev( ...@@ -17,14 +17,14 @@ TabletEventConverterEvdev::TabletEventConverterEvdev(
base::FilePath path, base::FilePath path,
int id, int id,
InputDeviceType type, InputDeviceType type,
EventModifiersEvdev* modifiers,
CursorDelegateEvdev* cursor, CursorDelegateEvdev* cursor,
const EventDeviceInfo& info, const EventDeviceInfo& info,
const EventDispatchCallback& callback) const MouseMoveEventDispatchCallback& mouse_move_callback,
const MouseButtonEventDispatchCallback& mouse_button_callback)
: EventConverterEvdev(fd, path, id, type), : EventConverterEvdev(fd, path, id, type),
cursor_(cursor), cursor_(cursor),
modifiers_(modifiers), mouse_move_callback_(mouse_move_callback),
callback_(callback), mouse_button_callback_(mouse_button_callback),
stylus_(0), stylus_(0),
abs_value_dirty_(false) { abs_value_dirty_(false) {
x_abs_min_ = info.GetAbsMinimum(ABS_X); x_abs_min_ = info.GetAbsMinimum(ABS_X);
...@@ -127,14 +127,14 @@ void TabletEventConverterEvdev::DispatchMouseButton(const input_event& input) { ...@@ -127,14 +127,14 @@ void TabletEventConverterEvdev::DispatchMouseButton(const input_event& input) {
if (!cursor_) if (!cursor_)
return; return;
unsigned int modifier; unsigned int button;
// These are the same as X11 behaviour // These are the same as X11 behaviour
if (input.code == BTN_TOUCH) if (input.code == BTN_TOUCH)
modifier = EVDEV_MODIFIER_LEFT_MOUSE_BUTTON; button = BTN_LEFT;
else if (input.code == BTN_STYLUS2) else if (input.code == BTN_STYLUS2)
modifier = EVDEV_MODIFIER_RIGHT_MOUSE_BUTTON; button = BTN_RIGHT;
else if (input.code == BTN_STYLUS) else if (input.code == BTN_STYLUS)
modifier = EVDEV_MODIFIER_MIDDLE_MOUSE_BUTTON; button = BTN_MIDDLE;
else else
return; return;
...@@ -143,12 +143,10 @@ void TabletEventConverterEvdev::DispatchMouseButton(const input_event& input) { ...@@ -143,12 +143,10 @@ void TabletEventConverterEvdev::DispatchMouseButton(const input_event& input) {
abs_value_dirty_ = false; abs_value_dirty_ = false;
} }
int flag = modifiers_->GetEventFlagFromModifier(modifier); bool down = input.value;
modifiers_->UpdateModifier(modifier, input.value);
callback_.Run(make_scoped_ptr( mouse_button_callback_.Run(MouseButtonEventParams(
new MouseEvent(input.value ? ET_MOUSE_PRESSED : ET_MOUSE_RELEASED, id_, cursor_->GetLocation(), button, down, false /* allow_remap */));
cursor_->GetLocation(), cursor_->GetLocation(),
modifiers_->GetModifierFlags() | flag, flag)));
} }
void TabletEventConverterEvdev::FlushEvents() { void TabletEventConverterEvdev::FlushEvents() {
...@@ -166,10 +164,7 @@ void TabletEventConverterEvdev::FlushEvents() { ...@@ -166,10 +164,7 @@ void TabletEventConverterEvdev::FlushEvents() {
UpdateCursor(); UpdateCursor();
callback_.Run(make_scoped_ptr( mouse_move_callback_.Run(MouseMoveEventParams(id_, cursor_->GetLocation()));
new MouseEvent(ui::ET_MOUSE_MOVED, cursor_->GetLocation(),
cursor_->GetLocation(), modifiers_->GetModifierFlags(),
/* changed_button_flags */ 0)));
abs_value_dirty_ = false; abs_value_dirty_ = false;
} }
......
...@@ -21,14 +21,15 @@ namespace ui { ...@@ -21,14 +21,15 @@ namespace ui {
class EVENTS_OZONE_EVDEV_EXPORT TabletEventConverterEvdev class EVENTS_OZONE_EVDEV_EXPORT TabletEventConverterEvdev
: public EventConverterEvdev { : public EventConverterEvdev {
public: public:
TabletEventConverterEvdev(int fd, TabletEventConverterEvdev(
int fd,
base::FilePath path, base::FilePath path,
int id, int id,
InputDeviceType type, InputDeviceType type,
EventModifiersEvdev* modifiers,
CursorDelegateEvdev* cursor, CursorDelegateEvdev* cursor,
const EventDeviceInfo& info, const EventDeviceInfo& info,
const EventDispatchCallback& callback); const MouseMoveEventDispatchCallback& mouse_move_callback,
const MouseButtonEventDispatchCallback& mouse_button_callback);
~TabletEventConverterEvdev() override; ~TabletEventConverterEvdev() override;
// EventConverterEvdev: // EventConverterEvdev:
...@@ -53,11 +54,9 @@ class EVENTS_OZONE_EVDEV_EXPORT TabletEventConverterEvdev ...@@ -53,11 +54,9 @@ class EVENTS_OZONE_EVDEV_EXPORT TabletEventConverterEvdev
// Shared cursor state. // Shared cursor state.
CursorDelegateEvdev* cursor_; CursorDelegateEvdev* cursor_;
// Modifier key state (shift, ctrl, etc). // Callbacks for dispatching events.
EventModifiersEvdev* modifiers_; MouseMoveEventDispatchCallback mouse_move_callback_;
MouseButtonEventDispatchCallback mouse_button_callback_;
// Callback for dispatching events.
EventDispatchCallback callback_;
int y_abs_location_; int y_abs_location_;
int x_abs_location_; int x_abs_location_;
......
...@@ -17,7 +17,10 @@ ...@@ -17,7 +17,10 @@
#include "base/time/time.h" #include "base/time/time.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "ui/events/event.h" #include "ui/events/event.h"
#include "ui/events/ozone/device/device_manager.h"
#include "ui/events/ozone/evdev/event_factory_evdev.h"
#include "ui/events/ozone/evdev/tablet_event_converter_evdev.h" #include "ui/events/ozone/evdev/tablet_event_converter_evdev.h"
#include "ui/events/ozone/layout/keyboard_layout_engine_manager.h"
#include "ui/events/platform/platform_event_dispatcher.h" #include "ui/events/platform/platform_event_dispatcher.h"
#include "ui/events/platform/platform_event_source.h" #include "ui/events/platform/platform_event_source.h"
...@@ -38,34 +41,24 @@ namespace ui { ...@@ -38,34 +41,24 @@ namespace ui {
class MockTabletEventConverterEvdev : public TabletEventConverterEvdev { class MockTabletEventConverterEvdev : public TabletEventConverterEvdev {
public: public:
MockTabletEventConverterEvdev(int fd, MockTabletEventConverterEvdev(
int fd,
base::FilePath path, base::FilePath path,
EventModifiersEvdev* modifiers, CursorDelegateEvdev* cursor,
CursorDelegateEvdev* cursor); const MouseMoveEventDispatchCallback& mouse_move_callback,
const MouseButtonEventDispatchCallback& mouse_button_callback);
~MockTabletEventConverterEvdev() override {}; ~MockTabletEventConverterEvdev() override {};
void ConfigureReadMock(struct input_event* queue, void ConfigureReadMock(struct input_event* queue,
long read_this_many, long read_this_many,
long queue_index); long queue_index);
unsigned size() { return dispatched_events_.size(); }
MouseEvent* event(unsigned index) {
DCHECK_GT(dispatched_events_.size(), index);
Event* ev = dispatched_events_[index];
DCHECK(ev->IsMouseEvent());
return static_cast<MouseEvent*>(ev);
}
// Actually dispatch the event reader code. // Actually dispatch the event reader code.
void ReadNow() { void ReadNow() {
OnFileCanReadWithoutBlocking(read_pipe_); OnFileCanReadWithoutBlocking(read_pipe_);
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
} }
void DispatchCallback(scoped_ptr<Event> event) {
dispatched_events_.push_back(event.release());
}
private: private:
int read_pipe_; int read_pipe_;
int write_pipe_; int write_pipe_;
...@@ -104,18 +97,17 @@ class MockTabletCursorEvdev : public CursorDelegateEvdev { ...@@ -104,18 +97,17 @@ class MockTabletCursorEvdev : public CursorDelegateEvdev {
MockTabletEventConverterEvdev::MockTabletEventConverterEvdev( MockTabletEventConverterEvdev::MockTabletEventConverterEvdev(
int fd, int fd,
base::FilePath path, base::FilePath path,
EventModifiersEvdev* modifiers, CursorDelegateEvdev* cursor,
CursorDelegateEvdev* cursor) const MouseMoveEventDispatchCallback& mouse_move_callback,
: TabletEventConverterEvdev( const MouseButtonEventDispatchCallback& mouse_button_callback)
fd, : TabletEventConverterEvdev(fd,
path, path,
1, 1,
INPUT_DEVICE_UNKNOWN, INPUT_DEVICE_UNKNOWN,
modifiers,
cursor, cursor,
EventDeviceInfo(), EventDeviceInfo(),
base::Bind(&MockTabletEventConverterEvdev::DispatchCallback, mouse_move_callback,
base::Unretained(this))) { mouse_button_callback) {
// Real values taken from Wacom Intuos 4 // Real values taken from Wacom Intuos 4
x_abs_min_ = 0; x_abs_min_ = 0;
x_abs_range_ = 65024; x_abs_range_ = 65024;
...@@ -145,6 +137,35 @@ void MockTabletEventConverterEvdev::ConfigureReadMock(struct input_event* queue, ...@@ -145,6 +137,35 @@ void MockTabletEventConverterEvdev::ConfigureReadMock(struct input_event* queue,
<< "write() failed, errno: " << errno; << "write() failed, errno: " << errno;
} }
class MockDeviceManager : public ui::DeviceManager {
public:
MockDeviceManager() {}
~MockDeviceManager() override {}
// DeviceManager:
void ScanDevices(DeviceEventObserver* observer) override {}
void AddObserver(DeviceEventObserver* observer) override {}
void RemoveObserver(DeviceEventObserver* observer) override {}
};
class TestEventFactoryEvdev : public EventFactoryEvdev {
public:
TestEventFactoryEvdev(CursorDelegateEvdev* cursor,
DeviceManager* device_manager,
KeyboardLayoutEngine* keyboard_layout_engine,
const EventDispatchCallback& callback)
: EventFactoryEvdev(cursor, device_manager, keyboard_layout_engine),
callback_(callback) {}
~TestEventFactoryEvdev() override {}
private:
void PostUiEvent(scoped_ptr<Event> event) override {
callback_.Run(event.Pass());
}
EventDispatchCallback callback_;
};
} // namespace ui } // namespace ui
// Test fixture. // Test fixture.
...@@ -162,26 +183,47 @@ class TabletEventConverterEvdevTest : public testing::Test { ...@@ -162,26 +183,47 @@ class TabletEventConverterEvdevTest : public testing::Test {
events_out_ = evdev_io[1]; events_out_ = evdev_io[1];
cursor_.reset(new ui::MockTabletCursorEvdev()); cursor_.reset(new ui::MockTabletCursorEvdev());
modifiers_.reset(new ui::EventModifiersEvdev()); device_manager_.reset(new ui::MockDeviceManager);
event_factory_.reset(new ui::TestEventFactoryEvdev(
cursor_.get(), device_manager_.get(),
ui::KeyboardLayoutEngineManager::GetKeyboardLayoutEngine(),
base::Bind(&TabletEventConverterEvdevTest::DispatchEventForTest,
base::Unretained(this))));
device_.reset(new ui::MockTabletEventConverterEvdev( device_.reset(new ui::MockTabletEventConverterEvdev(
events_in_, base::FilePath(kTestDevicePath), modifiers_.get(), events_in_, base::FilePath(kTestDevicePath), cursor_.get(),
cursor_.get())); base::Bind(&ui::EventFactoryEvdev::PostMouseMoveEvent,
base::Unretained(event_factory_.get())),
base::Bind(&ui::EventFactoryEvdev::PostMouseButtonEvent,
base::Unretained(event_factory_.get()))));
} }
void TearDown() override { void TearDown() override {
modifiers_.reset();
cursor_.reset(); cursor_.reset();
device_.reset(); device_.reset();
} }
ui::MockTabletEventConverterEvdev* device() { return device_.get(); } ui::MockTabletEventConverterEvdev* device() { return device_.get(); }
ui::CursorDelegateEvdev* cursor() { return cursor_.get(); } ui::CursorDelegateEvdev* cursor() { return cursor_.get(); }
ui::EventModifiersEvdev* modifiers() { return modifiers_.get(); }
unsigned size() { return dispatched_events_.size(); }
ui::MouseEvent* dispatched_event(unsigned index) {
DCHECK_GT(dispatched_events_.size(), index);
ui::Event* ev = dispatched_events_[index];
DCHECK(ev->IsMouseEvent());
return static_cast<ui::MouseEvent*>(ev);
}
void DispatchEventForTest(scoped_ptr<ui::Event> event) {
dispatched_events_.push_back(event.release());
}
private: private:
scoped_ptr<ui::MockTabletEventConverterEvdev> device_;
scoped_ptr<ui::MockTabletCursorEvdev> cursor_; scoped_ptr<ui::MockTabletCursorEvdev> cursor_;
scoped_ptr<ui::EventModifiersEvdev> modifiers_; scoped_ptr<ui::DeviceManager> device_manager_;
scoped_ptr<ui::EventFactoryEvdev> event_factory_;
scoped_ptr<ui::MockTabletEventConverterEvdev> device_;
ScopedVector<ui::Event> dispatched_events_;
int events_out_; int events_out_;
int events_in_; int events_in_;
...@@ -214,9 +256,9 @@ TEST_F(TabletEventConverterEvdevTest, MoveTopLeft) { ...@@ -214,9 +256,9 @@ TEST_F(TabletEventConverterEvdevTest, MoveTopLeft) {
}; };
dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue)); dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue));
EXPECT_EQ(1u, dev->size()); EXPECT_EQ(1u, size());
ui::MouseEvent* event = dev->event(0); ui::MouseEvent* event = dispatched_event(0);
EXPECT_EQ(ui::ET_MOUSE_MOVED, event->type()); EXPECT_EQ(ui::ET_MOUSE_MOVED, event->type());
EXPECT_LT(cursor()->GetLocation().x(), EPSILON); EXPECT_LT(cursor()->GetLocation().x(), EPSILON);
...@@ -247,9 +289,9 @@ TEST_F(TabletEventConverterEvdevTest, MoveTopRight) { ...@@ -247,9 +289,9 @@ TEST_F(TabletEventConverterEvdevTest, MoveTopRight) {
}; };
dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue)); dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue));
EXPECT_EQ(1u, dev->size()); EXPECT_EQ(1u, size());
ui::MouseEvent* event = dev->event(0); ui::MouseEvent* event = dispatched_event(0);
EXPECT_EQ(ui::ET_MOUSE_MOVED, event->type()); EXPECT_EQ(ui::ET_MOUSE_MOVED, event->type());
EXPECT_GT(cursor()->GetLocation().x(), EXPECT_GT(cursor()->GetLocation().x(),
...@@ -280,9 +322,9 @@ TEST_F(TabletEventConverterEvdevTest, MoveBottomLeft) { ...@@ -280,9 +322,9 @@ TEST_F(TabletEventConverterEvdevTest, MoveBottomLeft) {
}; };
dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue)); dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue));
EXPECT_EQ(1u, dev->size()); EXPECT_EQ(1u, size());
ui::MouseEvent* event = dev->event(0); ui::MouseEvent* event = dispatched_event(0);
EXPECT_EQ(ui::ET_MOUSE_MOVED, event->type()); EXPECT_EQ(ui::ET_MOUSE_MOVED, event->type());
EXPECT_LT(cursor()->GetLocation().x(), EPSILON); EXPECT_LT(cursor()->GetLocation().x(), EPSILON);
...@@ -315,9 +357,9 @@ TEST_F(TabletEventConverterEvdevTest, MoveBottomRight) { ...@@ -315,9 +357,9 @@ TEST_F(TabletEventConverterEvdevTest, MoveBottomRight) {
}; };
dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue)); dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue));
EXPECT_EQ(1u, dev->size()); EXPECT_EQ(1u, size());
ui::MouseEvent* event = dev->event(0); ui::MouseEvent* event = dispatched_event(0);
EXPECT_EQ(ui::ET_MOUSE_MOVED, event->type()); EXPECT_EQ(ui::ET_MOUSE_MOVED, event->type());
EXPECT_GT(cursor()->GetLocation().x(), EXPECT_GT(cursor()->GetLocation().x(),
...@@ -365,14 +407,14 @@ TEST_F(TabletEventConverterEvdevTest, Tap) { ...@@ -365,14 +407,14 @@ TEST_F(TabletEventConverterEvdevTest, Tap) {
}; };
dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue)); dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue));
EXPECT_EQ(3u, dev->size()); EXPECT_EQ(3u, size());
ui::MouseEvent* event = dev->event(0); ui::MouseEvent* event = dispatched_event(0);
EXPECT_EQ(ui::ET_MOUSE_MOVED, event->type()); EXPECT_EQ(ui::ET_MOUSE_MOVED, event->type());
event = dev->event(1); event = dispatched_event(1);
EXPECT_EQ(ui::ET_MOUSE_PRESSED, event->type()); EXPECT_EQ(ui::ET_MOUSE_PRESSED, event->type());
EXPECT_EQ(true, event->IsLeftMouseButton()); EXPECT_EQ(true, event->IsLeftMouseButton());
event = dev->event(2); event = dispatched_event(2);
EXPECT_EQ(ui::ET_MOUSE_RELEASED, event->type()); EXPECT_EQ(ui::ET_MOUSE_RELEASED, event->type());
EXPECT_EQ(true, event->IsLeftMouseButton()); EXPECT_EQ(true, event->IsLeftMouseButton());
} }
...@@ -412,14 +454,14 @@ TEST_F(TabletEventConverterEvdevTest, StylusButtonPress) { ...@@ -412,14 +454,14 @@ TEST_F(TabletEventConverterEvdevTest, StylusButtonPress) {
}; };
dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue)); dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue));
EXPECT_EQ(3u, dev->size()); EXPECT_EQ(3u, size());
ui::MouseEvent* event = dev->event(0); ui::MouseEvent* event = dispatched_event(0);
EXPECT_EQ(ui::ET_MOUSE_MOVED, event->type()); EXPECT_EQ(ui::ET_MOUSE_MOVED, event->type());
event = dev->event(1); event = dispatched_event(1);
EXPECT_EQ(ui::ET_MOUSE_PRESSED, event->type()); EXPECT_EQ(ui::ET_MOUSE_PRESSED, event->type());
EXPECT_EQ(true, event->IsRightMouseButton()); EXPECT_EQ(true, event->IsRightMouseButton());
event = dev->event(2); event = dispatched_event(2);
EXPECT_EQ(ui::ET_MOUSE_RELEASED, event->type()); EXPECT_EQ(ui::ET_MOUSE_RELEASED, event->type());
EXPECT_EQ(true, event->IsRightMouseButton()); EXPECT_EQ(true, event->IsRightMouseButton());
} }
...@@ -435,5 +477,5 @@ TEST_F(TabletEventConverterEvdevTest, CheckStylusFiltering) { ...@@ -435,5 +477,5 @@ TEST_F(TabletEventConverterEvdevTest, CheckStylusFiltering) {
}; };
dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue)); dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue));
EXPECT_EQ(0u, dev->size()); EXPECT_EQ(0u, size());
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment