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

Side by Side Diff: remoting/protocol/clipboard_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/clipboard_filter.cc ('k') | remoting/protocol/input_filter.h » ('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/clipboard_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(EqualsClipboardEvent, mime_type, data, "") {
18 return arg.mime_type() == mime_type && arg.data() == data;
19 }
20
21 static ClipboardEvent MakeClipboardEvent(const std::string& mime_type,
22 const std::string& data) {
23 ClipboardEvent event;
24 event.set_mime_type(mime_type);
25 event.set_data(data);
26 return event;
27 }
28
29 // Verify that the filter passes events on correctly to a configured stub.
30 TEST(ClipboardFilterTest, EventsPassThroughFilter) {
31 MockClipboardStub clipboard_stub;
32 ClipboardFilter clipboard_filter(&clipboard_stub);
33
34 EXPECT_CALL(clipboard_stub,
35 InjectClipboardEvent(EqualsClipboardEvent("text", "foo")));
36
37 clipboard_filter.InjectClipboardEvent(MakeClipboardEvent("text","foo"));
38 }
39
40 // Verify that the filter ignores events if disabled.
41 TEST(ClipboardFilterTest, IgnoreEventsIfDisabled) {
42 MockClipboardStub clipboard_stub;
43 ClipboardFilter clipboard_filter(&clipboard_stub);
44
45 clipboard_filter.set_enabled(false);
46
47 EXPECT_CALL(clipboard_stub, InjectClipboardEvent(_)).Times(0);
48
49 clipboard_filter.InjectClipboardEvent(MakeClipboardEvent("text","foo"));
50 }
51
52 // Verify that the filter ignores events if not configured.
53 TEST(ClipboardFilterTest, IgnoreEventsIfNotConfigured) {
54 ClipboardFilter clipboard_filter;
55
56 clipboard_filter.InjectClipboardEvent(MakeClipboardEvent("text","foo"));
57 }
58
59 } // namespace protocol
60 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/clipboard_filter.cc ('k') | remoting/protocol/input_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698