| 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/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "testing/gmock/include/gmock/gmock.h" | 9 #include "testing/gmock/include/gmock/gmock.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 cursor_location_ = location; | 56 cursor_location_ = location; |
| 57 } | 57 } |
| 58 void MoveCursor(const gfx::Vector2dF& delta) override { | 58 void MoveCursor(const gfx::Vector2dF& delta) override { |
| 59 cursor_location_ = gfx::PointF(delta.x(), delta.y()); | 59 cursor_location_ = gfx::PointF(delta.x(), delta.y()); |
| 60 } | 60 } |
| 61 bool IsCursorVisible() override { return 1; } | 61 bool IsCursorVisible() override { return 1; } |
| 62 gfx::Rect GetCursorDisplayBounds() override { | 62 gfx::Rect GetCursorDisplayBounds() override { |
| 63 NOTIMPLEMENTED(); | 63 NOTIMPLEMENTED(); |
| 64 return gfx::Rect(); | 64 return gfx::Rect(); |
| 65 } | 65 } |
| 66 gfx::PointF location() override { return cursor_location_; } | 66 gfx::PointF GetLocation() override { return cursor_location_; } |
| 67 | 67 |
| 68 private: | 68 private: |
| 69 // The location of the mock cursor. | 69 // The location of the mock cursor. |
| 70 gfx::PointF cursor_location_; | 70 gfx::PointF cursor_location_; |
| 71 | 71 |
| 72 DISALLOW_COPY_AND_ASSIGN(MockCursorEvdev); | 72 DISALLOW_COPY_AND_ASSIGN(MockCursorEvdev); |
| 73 }; | 73 }; |
| 74 | 74 |
| 75 MATCHER_P4(MatchesMouseEvent, type, button, x, y, "") { | 75 MATCHER_P4(MatchesMouseEvent, type, button, x, y, "") { |
| 76 if (arg->type() != type) { | 76 if (arg->type() != type) { |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 | 166 |
| 167 TEST_F(InputInjectorEvdevTest, DoubleClick) { | 167 TEST_F(InputInjectorEvdevTest, DoubleClick) { |
| 168 ExpectClick(12, 13, EF_LEFT_MOUSE_BUTTON, 2); | 168 ExpectClick(12, 13, EF_LEFT_MOUSE_BUTTON, 2); |
| 169 SimulateMouseClick(12, 13, EF_LEFT_MOUSE_BUTTON, 2); | 169 SimulateMouseClick(12, 13, EF_LEFT_MOUSE_BUTTON, 2); |
| 170 run_loop_.RunUntilIdle(); | 170 run_loop_.RunUntilIdle(); |
| 171 } | 171 } |
| 172 | 172 |
| 173 TEST_F(InputInjectorEvdevTest, MouseMoved) { | 173 TEST_F(InputInjectorEvdevTest, MouseMoved) { |
| 174 injector_.MoveCursorTo(gfx::PointF(1, 1)); | 174 injector_.MoveCursorTo(gfx::PointF(1, 1)); |
| 175 run_loop_.RunUntilIdle(); | 175 run_loop_.RunUntilIdle(); |
| 176 EXPECT_EQ(cursor_.location(), gfx::PointF(1, 1)); | 176 EXPECT_EQ(cursor_.GetLocation(), gfx::PointF(1, 1)); |
| 177 } | 177 } |
| 178 | 178 |
| 179 TEST_F(InputInjectorEvdevTest, MouseDragged) { | 179 TEST_F(InputInjectorEvdevTest, MouseDragged) { |
| 180 InSequence dummy; | 180 InSequence dummy; |
| 181 EXPECT_CALL(event_observer_, | 181 EXPECT_CALL(event_observer_, |
| 182 OnMouseEvent(MatchesMouseEvent(ET_MOUSE_PRESSED, | 182 OnMouseEvent(MatchesMouseEvent(ET_MOUSE_PRESSED, |
| 183 EF_LEFT_MOUSE_BUTTON, 0, 0))); | 183 EF_LEFT_MOUSE_BUTTON, 0, 0))); |
| 184 EXPECT_CALL(event_observer_, | 184 EXPECT_CALL(event_observer_, |
| 185 OnMouseEvent(MatchesMouseEvent(ET_MOUSE_DRAGGED, | 185 OnMouseEvent(MatchesMouseEvent(ET_MOUSE_DRAGGED, |
| 186 EF_LEFT_MOUSE_BUTTON, 1, 1))); | 186 EF_LEFT_MOUSE_BUTTON, 1, 1))); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 207 MatchesMouseEvent(ET_MOUSEWHEEL, 0, 10, 20), | 207 MatchesMouseEvent(ET_MOUSEWHEEL, 0, 10, 20), |
| 208 Property(&MouseWheelEvent::x_offset, 100), | 208 Property(&MouseWheelEvent::x_offset, 100), |
| 209 Property(&MouseWheelEvent::y_offset, 0)))); | 209 Property(&MouseWheelEvent::y_offset, 0)))); |
| 210 injector_.MoveCursorTo(gfx::PointF(10, 20)); | 210 injector_.MoveCursorTo(gfx::PointF(10, 20)); |
| 211 injector_.InjectMouseWheel(0, 100); | 211 injector_.InjectMouseWheel(0, 100); |
| 212 injector_.InjectMouseWheel(100, 0); | 212 injector_.InjectMouseWheel(100, 0); |
| 213 run_loop_.RunUntilIdle(); | 213 run_loop_.RunUntilIdle(); |
| 214 } | 214 } |
| 215 | 215 |
| 216 } // namespace ui | 216 } // namespace ui |
| OLD | NEW |