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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/protocol/clipboard_filter.cc ('k') | remoting/protocol/input_filter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/protocol/clipboard_filter_unittest.cc
diff --git a/remoting/protocol/clipboard_filter_unittest.cc b/remoting/protocol/clipboard_filter_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..d0cff8894db02cbe15ac236436661aed84f64fb4
--- /dev/null
+++ b/remoting/protocol/clipboard_filter_unittest.cc
@@ -0,0 +1,60 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "remoting/protocol/clipboard_filter.h"
+
+#include "remoting/proto/event.pb.h"
+#include "remoting/protocol/protocol_mock_objects.h"
+#include "testing/gmock/include/gmock/gmock.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+using ::testing::_;
+
+namespace remoting {
+namespace protocol {
+
+MATCHER_P2(EqualsClipboardEvent, mime_type, data, "") {
+ return arg.mime_type() == mime_type && arg.data() == data;
+}
+
+static ClipboardEvent MakeClipboardEvent(const std::string& mime_type,
+ const std::string& data) {
+ ClipboardEvent event;
+ event.set_mime_type(mime_type);
+ event.set_data(data);
+ return event;
+}
+
+// Verify that the filter passes events on correctly to a configured stub.
+TEST(ClipboardFilterTest, EventsPassThroughFilter) {
+ MockClipboardStub clipboard_stub;
+ ClipboardFilter clipboard_filter(&clipboard_stub);
+
+ EXPECT_CALL(clipboard_stub,
+ InjectClipboardEvent(EqualsClipboardEvent("text", "foo")));
+
+ clipboard_filter.InjectClipboardEvent(MakeClipboardEvent("text","foo"));
+}
+
+// Verify that the filter ignores events if disabled.
+TEST(ClipboardFilterTest, IgnoreEventsIfDisabled) {
+ MockClipboardStub clipboard_stub;
+ ClipboardFilter clipboard_filter(&clipboard_stub);
+
+ clipboard_filter.set_enabled(false);
+
+ EXPECT_CALL(clipboard_stub, InjectClipboardEvent(_)).Times(0);
+
+ clipboard_filter.InjectClipboardEvent(MakeClipboardEvent("text","foo"));
+}
+
+// Verify that the filter ignores events if not configured.
+TEST(ClipboardFilterTest, IgnoreEventsIfNotConfigured) {
+ ClipboardFilter clipboard_filter;
+
+ clipboard_filter.InjectClipboardEvent(MakeClipboardEvent("text","foo"));
+}
+
+} // namespace protocol
+} // namespace remoting
« 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