| Index: remoting/host/client_session_unittest.cc
|
| diff --git a/remoting/host/client_session_unittest.cc b/remoting/host/client_session_unittest.cc
|
| index 0f8b61edc629fabe0de91c566a121ef6b3b66183..6b54b4962026519eb77582f421e0349121463aee 100644
|
| --- a/remoting/host/client_session_unittest.cc
|
| +++ b/remoting/host/client_session_unittest.cc
|
| @@ -2,6 +2,7 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| +#include "remoting/base/constants.h"
|
| #include "remoting/host/client_session.h"
|
| #include "remoting/host/host_mock_objects.h"
|
| #include "remoting/protocol/protocol_mock_objects.h"
|
| @@ -40,7 +41,7 @@ class ClientSessionTest : public testing::Test {
|
| client_session_.reset(new ClientSession(
|
| &session_event_handler_,
|
| new protocol::ConnectionToClient(session),
|
| - &input_stub_, &capturer_));
|
| + &clipboard_stub_, &input_stub_, &capturer_));
|
| }
|
|
|
| virtual void TearDown() OVERRIDE {
|
| @@ -54,6 +55,7 @@ class ClientSessionTest : public testing::Test {
|
| SkISize default_screen_size_;
|
| MessageLoop message_loop_;
|
| std::string client_jid_;
|
| + protocol::MockClipboardStub clipboard_stub_;
|
| MockHostStub host_stub_;
|
| MockInputStub input_stub_;
|
| MockCapturer capturer_;
|
| @@ -61,6 +63,41 @@ class ClientSessionTest : public testing::Test {
|
| scoped_ptr<ClientSession> client_session_;
|
| };
|
|
|
| +MATCHER_P2(EqualsClipboardEvent, m, d, "") {
|
| + return (strcmp(arg.mime_type().c_str(), m) == 0 &&
|
| + memcmp(arg.data().data(), d, arg.data().size()) == 0);
|
| +}
|
| +
|
| +TEST_F(ClientSessionTest, ClipboardStubFilter) {
|
| + protocol::ClipboardEvent clipboard_event1;
|
| + clipboard_event1.set_mime_type(kMimeTypeText);
|
| + clipboard_event1.set_data("a");
|
| +
|
| + protocol::ClipboardEvent clipboard_event2;
|
| + clipboard_event2.set_mime_type(kMimeTypeText);
|
| + clipboard_event2.set_data("b");
|
| +
|
| + protocol::ClipboardEvent clipboard_event3;
|
| + clipboard_event3.set_mime_type(kMimeTypeText);
|
| + clipboard_event3.set_data("c");
|
| +
|
| + InSequence s;
|
| + EXPECT_CALL(session_event_handler_, OnSessionAuthenticated(_));
|
| + EXPECT_CALL(clipboard_stub_, InjectClipboardEvent(EqualsClipboardEvent(
|
| + kMimeTypeText, "b")));
|
| +
|
| + // This event should not get through to the clipboard stub,
|
| + // because the client isn't authenticated yet.
|
| + client_session_->InjectClipboardEvent(clipboard_event1);
|
| + client_session_->OnConnectionOpened(client_session_->connection());
|
| + // This event should get through to the clipboard stub.
|
| + client_session_->InjectClipboardEvent(clipboard_event2);
|
| + client_session_->Disconnect();
|
| + // This event should not get through to the clipboard stub,
|
| + // because the client has disconnected.
|
| + client_session_->InjectClipboardEvent(clipboard_event3);
|
| +}
|
| +
|
| MATCHER_P2(EqualsKeyEvent, keycode, pressed, "") {
|
| return arg.keycode() == keycode && arg.pressed() == pressed;
|
| }
|
|
|