This source file includes following definitions.
- MATCHER_P2
- MakeClipboardEvent
- TEST
- TEST
- TEST
#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;
}
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"));
}
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"));
}
TEST(ClipboardFilterTest, IgnoreEventsIfNotConfigured) {
ClipboardFilter clipboard_filter;
clipboard_filter.InjectClipboardEvent(MakeClipboardEvent("text","foo"));
}
}
}