Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(350)

Side by Side Diff: remoting/protocol/input_filter_unittest.cc

Issue 10860033: Allow input & clipboard filters to be disabled without NULLing target stub. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address review comments and fix clipboard pipeline initialization. Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « remoting/protocol/input_filter.cc ('k') | remoting/remoting.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "remoting/protocol/input_filter.h"
6
7 #include "remoting/proto/event.pb.h"
8 #include "remoting/protocol/protocol_mock_objects.h"
9 #include "testing/gmock/include/gmock/gmock.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11
12 using ::testing::_;
13
14 namespace remoting {
15 namespace protocol {
16
17 MATCHER_P2(EqualsKeyEvent, usb_keycode, pressed, "") {
18 return arg.usb_keycode() == static_cast<uint32>(usb_keycode) &&
19 arg.pressed() == pressed;
20 }
21
22 MATCHER_P2(EqualsMouseMoveEvent, x, y, "") {
23 return arg.x() == x && arg.y() == y;
24 }
25
26 static KeyEvent NewKeyEvent(uint32 usb_keycode, bool pressed) {
27 KeyEvent event;
28 event.set_usb_keycode(usb_keycode);
29 event.set_pressed(pressed);
30 return event;
31 }
32
33 static MouseEvent MouseMoveEvent(int x, int y) {
34 MouseEvent event;
35 event.set_x(x);
36 event.set_y(y);
37 return event;
38 }
39
40 static void InjectTestSequence(protocol::InputStub* input_stub) {
41 // Inject a key event.
42 input_stub->InjectKeyEvent(NewKeyEvent(0, true));
43 input_stub->InjectKeyEvent(NewKeyEvent(0, false));
44
45 // Inject mouse movemement.
46 input_stub->InjectMouseEvent(MouseMoveEvent(10, 20));
47 }
48
49 // Verify that the filter passes events on correctly to a configured stub.
50 TEST(InputFilterTest, EventsPassThroughFilter) {
51 MockInputStub input_stub;
52 InputFilter input_filter(&input_stub);
53
54 EXPECT_CALL(input_stub, InjectKeyEvent(EqualsKeyEvent(0, true)));
55 EXPECT_CALL(input_stub, InjectKeyEvent(EqualsKeyEvent(0, false)));
56 EXPECT_CALL(input_stub, InjectMouseEvent(EqualsMouseMoveEvent(10, 20)));
57
58 InjectTestSequence(&input_filter);
59 }
60
61 // Verify that the filter ignores events if disabled.
62 TEST(InputFilterTest, IgnoreEventsIfDisabled) {
63 MockInputStub input_stub;
64 InputFilter input_filter(&input_stub);
65
66 input_filter.set_enabled(false);
67
68 EXPECT_CALL(input_stub, InjectKeyEvent(_)).Times(0);
69 EXPECT_CALL(input_stub, InjectMouseEvent(_)).Times(0);
70
71 InjectTestSequence(&input_filter);
72 }
73
74 // Verify that the filter ignores events if not configured.
75 TEST(InputFilterTest, IgnoreEventsIfNotConfigured) {
76 InputFilter input_filter;
77
78 InjectTestSequence(&input_filter);
79 }
80
81 } // namespace protocol
82 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/input_filter.cc ('k') | remoting/remoting.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698