Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / remoting / protocol / clipboard_filter_unittest.cc
blob70858d691920c1f48be73b8ec9e47890682d6739
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.
5 #include "remoting/protocol/clipboard_filter.h"
7 #include "remoting/proto/event.pb.h"
8 #include "remoting/protocol/protocol_mock_objects.h"
9 #include "remoting/protocol/test_event_matchers.h"
10 #include "testing/gmock/include/gmock/gmock.h"
11 #include "testing/gtest/include/gtest/gtest.h"
13 using ::testing::_;
15 namespace remoting {
16 namespace protocol {
18 using test::EqualsClipboardEvent;
20 static ClipboardEvent MakeClipboardEvent(const std::string& mime_type,
21 const std::string& data) {
22 ClipboardEvent event;
23 event.set_mime_type(mime_type);
24 event.set_data(data);
25 return event;
28 // Verify that the filter passes events on correctly to a configured stub.
29 TEST(ClipboardFilterTest, EventsPassThroughFilter) {
30 MockClipboardStub clipboard_stub;
31 ClipboardFilter clipboard_filter(&clipboard_stub);
33 EXPECT_CALL(clipboard_stub,
34 InjectClipboardEvent(EqualsClipboardEvent("text", "foo")));
36 clipboard_filter.InjectClipboardEvent(MakeClipboardEvent("text","foo"));
39 // Verify that the filter ignores events if disabled.
40 TEST(ClipboardFilterTest, IgnoreEventsIfDisabled) {
41 MockClipboardStub clipboard_stub;
42 ClipboardFilter clipboard_filter(&clipboard_stub);
44 clipboard_filter.set_enabled(false);
46 EXPECT_CALL(clipboard_stub, InjectClipboardEvent(_)).Times(0);
48 clipboard_filter.InjectClipboardEvent(MakeClipboardEvent("text","foo"));
51 // Verify that the filter ignores events if not configured.
52 TEST(ClipboardFilterTest, IgnoreEventsIfNotConfigured) {
53 ClipboardFilter clipboard_filter;
55 clipboard_filter.InjectClipboardEvent(MakeClipboardEvent("text","foo"));
58 } // namespace protocol
59 } // namespace remoting