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..3065173d8f0fa4df397284292b9325c3720ab3e9 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" |
@@ -9,6 +10,7 @@ |
namespace remoting { |
+using protocol::MockClipboardStub; |
Sergey Ulanov
2012/03/14 20:27:07
Same here. There is only one place where this is n
simonmorris
2012/03/14 21:20:21
Done.
|
using protocol::MockConnectionToClient; |
using protocol::MockConnectionToClientEventHandler; |
using protocol::MockHostStub; |
@@ -40,7 +42,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 +56,7 @@ class ClientSessionTest : public testing::Test { |
SkISize default_screen_size_; |
MessageLoop message_loop_; |
std::string client_jid_; |
+ MockClipboardStub clipboard_stub_; |
MockHostStub host_stub_; |
MockInputStub input_stub_; |
MockCapturer capturer_; |
@@ -61,6 +64,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; |
} |