OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "remoting/protocol/input_filter.h" | 5 #include "remoting/protocol/input_filter.h" |
6 | 6 |
7 #include "remoting/proto/event.pb.h" | 7 #include "remoting/proto/event.pb.h" |
8 #include "remoting/protocol/protocol_mock_objects.h" | 8 #include "remoting/protocol/protocol_mock_objects.h" |
| 9 #include "remoting/protocol/test_event_matchers.h" |
9 #include "testing/gmock/include/gmock/gmock.h" | 10 #include "testing/gmock/include/gmock/gmock.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
11 | 12 |
12 using ::testing::_; | 13 using ::testing::_; |
13 | 14 |
14 namespace remoting { | 15 namespace remoting { |
15 namespace protocol { | 16 namespace protocol { |
16 | 17 |
17 MATCHER_P2(EqualsKeyEvent, usb_keycode, pressed, "") { | 18 using test::EqualsKeyEvent; |
18 return arg.usb_keycode() == static_cast<uint32>(usb_keycode) && | 19 using test::EqualsMouseMoveEvent; |
19 arg.pressed() == pressed; | 20 using test::EqualsTextEvent; |
20 } | |
21 | |
22 MATCHER_P(EqualsTextEvent, text, "") { | |
23 return arg.text() == text; | |
24 } | |
25 | |
26 MATCHER_P2(EqualsMouseMoveEvent, x, y, "") { | |
27 return arg.x() == x && arg.y() == y; | |
28 } | |
29 | 21 |
30 static KeyEvent NewKeyEvent(uint32 usb_keycode, bool pressed) { | 22 static KeyEvent NewKeyEvent(uint32 usb_keycode, bool pressed) { |
31 KeyEvent event; | 23 KeyEvent event; |
32 event.set_usb_keycode(usb_keycode); | 24 event.set_usb_keycode(usb_keycode); |
33 event.set_pressed(pressed); | 25 event.set_pressed(pressed); |
34 return event; | 26 return event; |
35 } | 27 } |
36 | 28 |
37 static TextEvent NewTextEvent(const std::string& text) { | 29 static TextEvent NewTextEvent(const std::string& text) { |
38 TextEvent event; | 30 TextEvent event; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 InjectTestSequence(&input_filter); | 73 InjectTestSequence(&input_filter); |
82 } | 74 } |
83 | 75 |
84 // Verify that the filter ignores events if not configured. | 76 // Verify that the filter ignores events if not configured. |
85 TEST(InputFilterTest, IgnoreEventsIfNotConfigured) { | 77 TEST(InputFilterTest, IgnoreEventsIfNotConfigured) { |
86 InputFilter input_filter; | 78 InputFilter input_filter; |
87 | 79 |
88 InjectTestSequence(&input_filter); | 80 InjectTestSequence(&input_filter); |
89 } | 81 } |
90 | 82 |
91 } // namespace protocol | 83 } // namespace protocol |
92 } // namespace remoting | 84 } // namespace remoting |
OLD | NEW |