Automated Commit: Committing new LKGM version 6610.0.0 for chromeos.
[chromium-blink-merge.git] / remoting / protocol / clipboard_filter_unittest.cc
blobd0cff8894db02cbe15ac236436661aed84f64fb4
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 "testing/gmock/include/gmock/gmock.h"
10 #include "testing/gtest/include/gtest/gtest.h"
12 using ::testing::_;
14 namespace remoting {
15 namespace protocol {
17 MATCHER_P2(EqualsClipboardEvent, mime_type, data, "") {
18 return arg.mime_type() == mime_type && arg.data() == data;
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;
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);
34 EXPECT_CALL(clipboard_stub,
35 InjectClipboardEvent(EqualsClipboardEvent("text", "foo")));
37 clipboard_filter.InjectClipboardEvent(MakeClipboardEvent("text","foo"));
40 // Verify that the filter ignores events if disabled.
41 TEST(ClipboardFilterTest, IgnoreEventsIfDisabled) {
42 MockClipboardStub clipboard_stub;
43 ClipboardFilter clipboard_filter(&clipboard_stub);
45 clipboard_filter.set_enabled(false);
47 EXPECT_CALL(clipboard_stub, InjectClipboardEvent(_)).Times(0);
49 clipboard_filter.InjectClipboardEvent(MakeClipboardEvent("text","foo"));
52 // Verify that the filter ignores events if not configured.
53 TEST(ClipboardFilterTest, IgnoreEventsIfNotConfigured) {
54 ClipboardFilter clipboard_filter;
56 clipboard_filter.InjectClipboardEvent(MakeClipboardEvent("text","foo"));
59 } // namespace protocol
60 } // namespace remoting