| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "ui/events/ozone/evdev/input_injector_evdev.h" | 5 #include "ui/events/ozone/evdev/input_injector_evdev.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "testing/gmock/include/gmock/gmock.h" | 10 #include "testing/gmock/include/gmock/gmock.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 class EventObserver { | 25 class EventObserver { |
| 26 public: | 26 public: |
| 27 void EventDispatchCallback(Event* event) { | 27 void EventDispatchCallback(Event* event) { |
| 28 DispatchEventFromNativeUiEvent( | 28 DispatchEventFromNativeUiEvent( |
| 29 event, base::Bind(&EventObserver::OnEvent, base::Unretained(this))); | 29 event, base::Bind(&EventObserver::OnEvent, base::Unretained(this))); |
| 30 } | 30 } |
| 31 | 31 |
| 32 void OnEvent(Event* event) { | 32 void OnEvent(Event* event) { |
| 33 if (event->IsMouseEvent()) { | 33 if (event->IsMouseEvent()) { |
| 34 if (event->type() == ET_MOUSEWHEEL) { | 34 if (event->type() == ET_MOUSEWHEEL) { |
| 35 OnMouseWheelEvent(static_cast<MouseWheelEvent*>(event)); | 35 OnMouseWheelEvent(event->AsMouseWheelEvent()); |
| 36 } else { | 36 } else { |
| 37 OnMouseEvent(static_cast<MouseEvent*>(event)); | 37 OnMouseEvent(event->AsMouseEvent()); |
| 38 } | 38 } |
| 39 } | 39 } |
| 40 } | 40 } |
| 41 | 41 |
| 42 // Mock functions for intercepting mouse events. | 42 // Mock functions for intercepting mouse events. |
| 43 MOCK_METHOD1(OnMouseEvent, void(MouseEvent* event)); | 43 MOCK_METHOD1(OnMouseEvent, void(MouseEvent* event)); |
| 44 MOCK_METHOD1(OnMouseWheelEvent, void(MouseWheelEvent* event)); | 44 MOCK_METHOD1(OnMouseWheelEvent, void(MouseWheelEvent* event)); |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 class MockCursorEvdev : public CursorDelegateEvdev { | 47 class MockCursorEvdev : public CursorDelegateEvdev { |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 MatchesMouseEvent(ET_MOUSEWHEEL, 0, 10, 20), | 216 MatchesMouseEvent(ET_MOUSEWHEEL, 0, 10, 20), |
| 217 Property(&MouseWheelEvent::x_offset, 100), | 217 Property(&MouseWheelEvent::x_offset, 100), |
| 218 Property(&MouseWheelEvent::y_offset, 0)))); | 218 Property(&MouseWheelEvent::y_offset, 0)))); |
| 219 injector_.MoveCursorTo(gfx::PointF(10, 20)); | 219 injector_.MoveCursorTo(gfx::PointF(10, 20)); |
| 220 injector_.InjectMouseWheel(0, 100); | 220 injector_.InjectMouseWheel(0, 100); |
| 221 injector_.InjectMouseWheel(100, 0); | 221 injector_.InjectMouseWheel(100, 0); |
| 222 run_loop_.RunUntilIdle(); | 222 run_loop_.RunUntilIdle(); |
| 223 } | 223 } |
| 224 | 224 |
| 225 } // namespace ui | 225 } // namespace ui |
| OLD | NEW |