| Index: remoting/host/remote_input_filter_unittest.cc
|
| diff --git a/remoting/host/remote_input_filter_unittest.cc b/remoting/host/remote_input_filter_unittest.cc
|
| index 5e8576eb62200dd9fa229e24edca139387ac8c09..0a38bd408b7602dd82cccf31ac990ec1bc788cb2 100644
|
| --- a/remoting/host/remote_input_filter_unittest.cc
|
| +++ b/remoting/host/remote_input_filter_unittest.cc
|
| @@ -7,6 +7,7 @@
|
| #include "remoting/proto/event.pb.h"
|
| #include "remoting/protocol/input_event_tracker.h"
|
| #include "remoting/protocol/protocol_mock_objects.h"
|
| +#include "remoting/protocol/test_event_matchers.h"
|
| #include "testing/gmock/include/gmock/gmock.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
|
|
| @@ -16,16 +17,13 @@ using ::testing::InSequence;
|
|
|
| namespace remoting {
|
|
|
| -using protocol::MockInputStub;
|
| using protocol::InputEventTracker;
|
| +using protocol::MockInputStub;
|
| +using protocol::test::EqualsKeyEvent;
|
| +using protocol::test::EqualsTouchEventTypeAndId;
|
|
|
| namespace {
|
|
|
| -MATCHER_P2(EqualsUsbEvent, usb_keycode, pressed, "") {
|
| - return arg.usb_keycode() == (unsigned int)usb_keycode &&
|
| - arg.pressed() == pressed;
|
| -}
|
| -
|
| static protocol::MouseEvent MouseMoveEvent(int x, int y) {
|
| protocol::MouseEvent event;
|
| event.set_x(x);
|
| @@ -40,17 +38,6 @@ static protocol::KeyEvent UsbKeyEvent(int usb_keycode, bool pressed) {
|
| return event;
|
| }
|
|
|
| -MATCHER_P2(EqualsTouchEvent, type, id, "") {
|
| - if (arg.event_type() != type)
|
| - return false;
|
| -
|
| - // Expect only one touch point.
|
| - if (arg.touch_points().size() != 1)
|
| - return false;
|
| -
|
| - return arg.touch_points(0).id() == id;
|
| -}
|
| -
|
| protocol::TouchEvent TouchStartEvent(uint32_t id) {
|
| protocol::TouchEvent event;
|
| event.set_event_type(protocol::TouchEvent::TOUCH_POINT_START);
|
| @@ -66,7 +53,7 @@ protocol::TouchEvent TouchStartEvent(uint32_t id) {
|
| return event;
|
| }
|
|
|
| -}
|
| +} // namespace
|
|
|
| // Verify that events get through if there is no local activity.
|
| TEST(RemoteInputFilterTest, NoLocalActivity) {
|
| @@ -74,8 +61,7 @@ TEST(RemoteInputFilterTest, NoLocalActivity) {
|
| InputEventTracker input_tracker(&mock_stub);
|
| RemoteInputFilter input_filter(&input_tracker);
|
|
|
| - EXPECT_CALL(mock_stub, InjectMouseEvent(_))
|
| - .Times(10);
|
| + EXPECT_CALL(mock_stub, InjectMouseEvent(_)).Times(10);
|
|
|
| for (int i = 0; i < 10; ++i)
|
| input_filter.InjectMouseEvent(MouseMoveEvent(0, 0));
|
| @@ -87,8 +73,7 @@ TEST(RemoteInputFilterTest, MismatchedLocalActivity) {
|
| InputEventTracker input_tracker(&mock_stub);
|
| RemoteInputFilter input_filter(&input_tracker);
|
|
|
| - EXPECT_CALL(mock_stub, InjectMouseEvent(_))
|
| - .Times(5);
|
| + EXPECT_CALL(mock_stub, InjectMouseEvent(_)).Times(5);
|
|
|
| for (int i = 0; i < 10; ++i) {
|
| input_filter.InjectMouseEvent(MouseMoveEvent(0, 0));
|
| @@ -103,8 +88,7 @@ TEST(RemoteInputFilterTest, LocalEchoesOfRemoteActivity) {
|
| InputEventTracker input_tracker(&mock_stub);
|
| RemoteInputFilter input_filter(&input_tracker);
|
|
|
| - EXPECT_CALL(mock_stub, InjectMouseEvent(_))
|
| - .Times(10);
|
| + EXPECT_CALL(mock_stub, InjectMouseEvent(_)).Times(10);
|
|
|
| for (int i = 0; i < 10; ++i) {
|
| input_filter.InjectMouseEvent(MouseMoveEvent(0, 0));
|
| @@ -118,8 +102,7 @@ TEST(RemoteInputFilterTest, LocalEchosAndLocalActivity) {
|
| InputEventTracker input_tracker(&mock_stub);
|
| RemoteInputFilter input_filter(&input_tracker);
|
|
|
| - EXPECT_CALL(mock_stub, InjectMouseEvent(_))
|
| - .Times(5);
|
| + EXPECT_CALL(mock_stub, InjectMouseEvent(_)).Times(5);
|
|
|
| for (int i = 0; i < 10; ++i) {
|
| input_filter.InjectMouseEvent(MouseMoveEvent(0, 0));
|
| @@ -136,19 +119,18 @@ TEST(RemoteInputFilterTest, LocalActivityReleasesAll) {
|
| InputEventTracker input_tracker(&mock_stub);
|
| RemoteInputFilter input_filter(&input_tracker);
|
|
|
| - EXPECT_CALL(mock_stub, InjectMouseEvent(_))
|
| - .Times(5);
|
| + EXPECT_CALL(mock_stub, InjectMouseEvent(_)).Times(5);
|
|
|
| // Use release of a key as a proxy for InputEventTracker::ReleaseAll()
|
| // having been called, rather than mocking it.
|
| - EXPECT_CALL(mock_stub, InjectKeyEvent(EqualsUsbEvent(0, true)));
|
| - EXPECT_CALL(mock_stub, InjectKeyEvent(EqualsUsbEvent(0, false)));
|
| + EXPECT_CALL(mock_stub, InjectKeyEvent(EqualsKeyEvent(0, true)));
|
| + EXPECT_CALL(mock_stub, InjectKeyEvent(EqualsKeyEvent(0, false)));
|
| input_filter.InjectKeyEvent(UsbKeyEvent(0, true));
|
|
|
| // Touch points that are down should be canceled.
|
| - EXPECT_CALL(mock_stub, InjectTouchEvent(EqualsTouchEvent(
|
| + EXPECT_CALL(mock_stub, InjectTouchEvent(EqualsTouchEventTypeAndId(
|
| protocol::TouchEvent::TOUCH_POINT_START, 0u)));
|
| - EXPECT_CALL(mock_stub, InjectTouchEvent(EqualsTouchEvent(
|
| + EXPECT_CALL(mock_stub, InjectTouchEvent(EqualsTouchEventTypeAndId(
|
| protocol::TouchEvent::TOUCH_POINT_CANCEL, 0u)));
|
| input_filter.InjectTouchEvent(TouchStartEvent(0u));
|
|
|
|
|