Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(334)

Side by Side Diff: remoting/host/client_session_unittest.cc

Issue 9646013: Add the plumbing that will carry a clipboard item from a chromoting client to a host. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move clipboard events to the control channel. Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "remoting/base/constants.h"
5 #include "remoting/host/client_session.h" 6 #include "remoting/host/client_session.h"
6 #include "remoting/host/host_mock_objects.h" 7 #include "remoting/host/host_mock_objects.h"
7 #include "remoting/protocol/protocol_mock_objects.h" 8 #include "remoting/protocol/protocol_mock_objects.h"
8 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
9 10
10 namespace remoting { 11 namespace remoting {
11 12
13 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.
12 using protocol::MockConnectionToClient; 14 using protocol::MockConnectionToClient;
13 using protocol::MockConnectionToClientEventHandler; 15 using protocol::MockConnectionToClientEventHandler;
14 using protocol::MockHostStub; 16 using protocol::MockHostStub;
15 using protocol::MockInputStub; 17 using protocol::MockInputStub;
16 using protocol::MockSession; 18 using protocol::MockSession;
17 19
18 using testing::_; 20 using testing::_;
19 using testing::DeleteArg; 21 using testing::DeleteArg;
20 using testing::InSequence; 22 using testing::InSequence;
21 using testing::Return; 23 using testing::Return;
(...skipping 11 matching lines...) Expand all
33 EXPECT_CALL(capturer_, size_most_recent()) 35 EXPECT_CALL(capturer_, size_most_recent())
34 .WillRepeatedly(ReturnRef(default_screen_size_)); 36 .WillRepeatedly(ReturnRef(default_screen_size_));
35 37
36 protocol::MockSession* session = new MockSession(); 38 protocol::MockSession* session = new MockSession();
37 EXPECT_CALL(*session, jid()).WillRepeatedly(ReturnRef(client_jid_)); 39 EXPECT_CALL(*session, jid()).WillRepeatedly(ReturnRef(client_jid_));
38 EXPECT_CALL(*session, SetStateChangeCallback(_)); 40 EXPECT_CALL(*session, SetStateChangeCallback(_));
39 41
40 client_session_.reset(new ClientSession( 42 client_session_.reset(new ClientSession(
41 &session_event_handler_, 43 &session_event_handler_,
42 new protocol::ConnectionToClient(session), 44 new protocol::ConnectionToClient(session),
43 &input_stub_, &capturer_)); 45 &clipboard_stub_, &input_stub_, &capturer_));
44 } 46 }
45 47
46 virtual void TearDown() OVERRIDE { 48 virtual void TearDown() OVERRIDE {
47 client_session_.reset(); 49 client_session_.reset();
48 // Run message loop before destroying because protocol::Session is 50 // Run message loop before destroying because protocol::Session is
49 // destroyed asynchronously. 51 // destroyed asynchronously.
50 message_loop_.RunAllPending(); 52 message_loop_.RunAllPending();
51 } 53 }
52 54
53 protected: 55 protected:
54 SkISize default_screen_size_; 56 SkISize default_screen_size_;
55 MessageLoop message_loop_; 57 MessageLoop message_loop_;
56 std::string client_jid_; 58 std::string client_jid_;
59 MockClipboardStub clipboard_stub_;
57 MockHostStub host_stub_; 60 MockHostStub host_stub_;
58 MockInputStub input_stub_; 61 MockInputStub input_stub_;
59 MockCapturer capturer_; 62 MockCapturer capturer_;
60 MockClientSessionEventHandler session_event_handler_; 63 MockClientSessionEventHandler session_event_handler_;
61 scoped_ptr<ClientSession> client_session_; 64 scoped_ptr<ClientSession> client_session_;
62 }; 65 };
63 66
67 MATCHER_P2(EqualsClipboardEvent, m, d, "") {
68 return (strcmp(arg.mime_type().c_str(), m) == 0 &&
69 memcmp(arg.data().data(), d, arg.data().size()) == 0);
70 }
71
72 TEST_F(ClientSessionTest, ClipboardStubFilter) {
73 protocol::ClipboardEvent clipboard_event1;
74 clipboard_event1.set_mime_type(kMimeTypeText);
75 clipboard_event1.set_data("a");
76
77 protocol::ClipboardEvent clipboard_event2;
78 clipboard_event2.set_mime_type(kMimeTypeText);
79 clipboard_event2.set_data("b");
80
81 protocol::ClipboardEvent clipboard_event3;
82 clipboard_event3.set_mime_type(kMimeTypeText);
83 clipboard_event3.set_data("c");
84
85 InSequence s;
86 EXPECT_CALL(session_event_handler_, OnSessionAuthenticated(_));
87 EXPECT_CALL(clipboard_stub_, InjectClipboardEvent(EqualsClipboardEvent(
88 kMimeTypeText, "b")));
89
90 // This event should not get through to the clipboard stub,
91 // because the client isn't authenticated yet.
92 client_session_->InjectClipboardEvent(clipboard_event1);
93 client_session_->OnConnectionOpened(client_session_->connection());
94 // This event should get through to the clipboard stub.
95 client_session_->InjectClipboardEvent(clipboard_event2);
96 client_session_->Disconnect();
97 // This event should not get through to the clipboard stub,
98 // because the client has disconnected.
99 client_session_->InjectClipboardEvent(clipboard_event3);
100 }
101
64 MATCHER_P2(EqualsKeyEvent, keycode, pressed, "") { 102 MATCHER_P2(EqualsKeyEvent, keycode, pressed, "") {
65 return arg.keycode() == keycode && arg.pressed() == pressed; 103 return arg.keycode() == keycode && arg.pressed() == pressed;
66 } 104 }
67 105
68 MATCHER_P2(EqualsMouseEvent, x, y, "") { 106 MATCHER_P2(EqualsMouseEvent, x, y, "") {
69 return arg.x() == x && arg.y() == y; 107 return arg.x() == x && arg.y() == y;
70 } 108 }
71 109
72 MATCHER_P(EqualsMouseUpEvent, button, "") { 110 MATCHER_P(EqualsMouseUpEvent, button, "") {
73 return arg.button() == button && !arg.button_down(); 111 return arg.button() == button && !arg.button_down();
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 event.set_x(input_x[i]); 240 event.set_x(input_x[i]);
203 event.set_y(input_y[j]); 241 event.set_y(input_y[j]);
204 EXPECT_CALL(input_stub_, InjectMouseEvent(EqualsMouseEvent( 242 EXPECT_CALL(input_stub_, InjectMouseEvent(EqualsMouseEvent(
205 expected_x[i], expected_y[j]))); 243 expected_x[i], expected_y[j])));
206 client_session_->InjectMouseEvent(event); 244 client_session_->InjectMouseEvent(event);
207 } 245 }
208 } 246 }
209 } 247 }
210 248
211 } // namespace remoting 249 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698