This source file includes following definitions.
- MATCHER_P2
- MakeClipboardEvent
- TEST
- TEST
- TEST
#include "remoting/protocol/clipboard_echo_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::_;
using ::testing::InSequence;
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(ClipboardEchoFilterTest, FromClientBlocksIdenticalEventToClient) {
MockClipboardStub client_stub;
MockClipboardStub host_stub;
{
InSequence s;
EXPECT_CALL(host_stub,
InjectClipboardEvent(EqualsClipboardEvent("text", "a")));
EXPECT_CALL(host_stub,
InjectClipboardEvent(EqualsClipboardEvent("text", "b")));
EXPECT_CALL(client_stub,
InjectClipboardEvent(EqualsClipboardEvent("text", "a")));
EXPECT_CALL(host_stub,
InjectClipboardEvent(EqualsClipboardEvent("image", "a")));
EXPECT_CALL(client_stub,
InjectClipboardEvent(EqualsClipboardEvent("text", "a")));
}
ClipboardEchoFilter filter;
filter.set_client_stub(&client_stub);
filter.set_host_stub(&host_stub);
filter.host_filter()->InjectClipboardEvent(
MakeClipboardEvent("text", "a"));
filter.client_filter()->InjectClipboardEvent(
MakeClipboardEvent("text", "a"));
filter.host_filter()->InjectClipboardEvent(
MakeClipboardEvent("text", "b"));
filter.client_filter()->InjectClipboardEvent(
MakeClipboardEvent("text", "a"));
filter.host_filter()->InjectClipboardEvent(
MakeClipboardEvent("image", "a"));
filter.client_filter()->InjectClipboardEvent(
MakeClipboardEvent("text", "a"));
}
TEST(ClipboardEchoFilterTest, NoHostStub) {
MockClipboardStub client_stub;
MockClipboardStub host_stub;
EXPECT_CALL(host_stub,
InjectClipboardEvent(EqualsClipboardEvent("text", "a")));
ClipboardEchoFilter filter;
ClipboardEvent event = MakeClipboardEvent("text", "a");
filter.host_filter()->InjectClipboardEvent(event);
filter.set_client_stub(&client_stub);
filter.host_filter()->InjectClipboardEvent(event);
filter.set_host_stub(&host_stub);
filter.host_filter()->InjectClipboardEvent(event);
}
TEST(ClipboardEchoFilter, NoClientStub) {
MockClipboardStub client_stub;
MockClipboardStub host_stub;
EXPECT_CALL(client_stub,
InjectClipboardEvent(EqualsClipboardEvent("text", "a")));
ClipboardEchoFilter filter;
ClipboardEvent event = MakeClipboardEvent("text", "a");
filter.client_filter()->InjectClipboardEvent(event);
filter.set_host_stub(&host_stub);
filter.client_filter()->InjectClipboardEvent(event);
filter.set_client_stub(&client_stub);
filter.client_filter()->InjectClipboardEvent(event);
}
}
}