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

Unified Diff: remoting/host/client_session_unittest.cc

Issue 902613004: Fix ConnectionToClient to connect stubs only after authentication. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@audio_pump
Patch Set: Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: remoting/host/client_session_unittest.cc
diff --git a/remoting/host/client_session_unittest.cc b/remoting/host/client_session_unittest.cc
index 313845498dca77791cb31a7818a693f6f3d6c7e6..fa7a3e646fedbb204af7764b35b57ae2abef4457 100644
--- a/remoting/host/client_session_unittest.cc
+++ b/remoting/host/client_session_unittest.cc
@@ -310,7 +310,15 @@ webrtc::MouseCursorMonitor* ClientSessionTest::CreateMouseCursorMonitor() {
}
void ClientSessionTest::ConnectClientSession() {
+ // Stubs should be set only after connection is authenticated.
+ EXPECT_FALSE(connection_->clipboard_stub());
+ EXPECT_FALSE(connection_->input_stub());
+
client_session_->OnConnectionAuthenticated(client_session_->connection());
+
+ EXPECT_TRUE(connection_->clipboard_stub());
+ EXPECT_TRUE(connection_->input_stub());
+
client_session_->OnConnectionChannelsConnected(client_session_->connection());
}
@@ -343,131 +351,6 @@ MATCHER_P2(EqualsClipboardEvent, m, d, "") {
memcmp(arg.data().data(), d, arg.data().size()) == 0);
}
-TEST_F(ClientSessionTest, ClipboardStubFilter) {
Wez 2015/02/07 00:40:43 We should have some disable-inputs tests - perhaps
Sergey Ulanov 2015/02/13 19:40:21 Done.
- CreateClientSession();
-
- protocol::ClipboardEvent clipboard_event1;
- clipboard_event1.set_mime_type(kMimeTypeTextUtf8);
- clipboard_event1.set_data("a");
-
- protocol::ClipboardEvent clipboard_event2;
- clipboard_event2.set_mime_type(kMimeTypeTextUtf8);
- clipboard_event2.set_data("b");
-
- protocol::ClipboardEvent clipboard_event3;
- clipboard_event3.set_mime_type(kMimeTypeTextUtf8);
- clipboard_event3.set_data("c");
-
- Expectation authenticated =
- EXPECT_CALL(session_event_handler_, OnSessionAuthenticated(_))
- .WillOnce(Return(true));
- EXPECT_CALL(*input_injector_, StartPtr(_))
- .After(authenticated);
- EXPECT_CALL(session_event_handler_, OnSessionChannelsConnected(_))
- .After(authenticated);
-
- // Wait for the first video packet to be captured to make sure that
- // the injected input will go though. Otherwise mouse events will be blocked
- // by the mouse clamping filter.
- Sequence s;
- EXPECT_CALL(video_stub_, ProcessVideoPacketPtr(_, _))
- .InSequence(s)
- .After(authenticated)
- .WillOnce(DoAll(
- // This event should get through to the clipboard stub.
- InjectClipboardEvent(connection_, clipboard_event2),
- InvokeWithoutArgs(this, &ClientSessionTest::DisconnectClientSession),
- // This event should not get through to the clipboard stub,
- // because the client has disconnected.
- InjectClipboardEvent(connection_, clipboard_event3),
- InvokeWithoutArgs(this, &ClientSessionTest::StopClientSession)));
- EXPECT_CALL(*input_injector_, InjectClipboardEvent(EqualsClipboardEvent(
- kMimeTypeTextUtf8, "b")))
- .InSequence(s);
- EXPECT_CALL(session_event_handler_, OnSessionClosed(_))
- .InSequence(s);
-
- // This event should not get through to the clipboard stub,
- // because the client isn't authenticated yet.
- connection_->clipboard_stub()->InjectClipboardEvent(clipboard_event1);
-
- ConnectClientSession();
-}
-
-TEST_F(ClientSessionTest, InputStubFilter) {
- CreateClientSession();
-
- protocol::KeyEvent key_event1;
- key_event1.set_pressed(true);
- key_event1.set_usb_keycode(1);
-
- protocol::KeyEvent key_event2_down;
- key_event2_down.set_pressed(true);
- key_event2_down.set_usb_keycode(2);
-
- protocol::KeyEvent key_event2_up;
- key_event2_up.set_pressed(false);
- key_event2_up.set_usb_keycode(2);
-
- protocol::KeyEvent key_event3;
- key_event3.set_pressed(true);
- key_event3.set_usb_keycode(3);
-
- protocol::MouseEvent mouse_event1;
- mouse_event1.set_x(100);
- mouse_event1.set_y(101);
-
- protocol::MouseEvent mouse_event2;
- mouse_event2.set_x(200);
- mouse_event2.set_y(201);
-
- protocol::MouseEvent mouse_event3;
- mouse_event3.set_x(300);
- mouse_event3.set_y(301);
-
- Expectation authenticated =
- EXPECT_CALL(session_event_handler_, OnSessionAuthenticated(_))
- .WillOnce(Return(true));
- EXPECT_CALL(*input_injector_, StartPtr(_))
- .After(authenticated);
- EXPECT_CALL(session_event_handler_, OnSessionChannelsConnected(_))
- .After(authenticated);
-
- // Wait for the first video packet to be captured to make sure that
- // the injected input will go though. Otherwise mouse events will be blocked
- // by the mouse clamping filter.
- Sequence s;
- EXPECT_CALL(video_stub_, ProcessVideoPacketPtr(_, _))
- .InSequence(s)
- .After(authenticated)
- .WillOnce(DoAll(
- // These events should get through to the input stub.
- InjectKeyEvent(connection_, key_event2_down),
- InjectKeyEvent(connection_, key_event2_up),
- InjectMouseEvent(connection_, mouse_event2),
- InvokeWithoutArgs(this, &ClientSessionTest::DisconnectClientSession),
- // These events should not get through to the input stub,
- // because the client has disconnected.
- InjectKeyEvent(connection_, key_event3),
- InjectMouseEvent(connection_, mouse_event3),
- InvokeWithoutArgs(this, &ClientSessionTest::StopClientSession)));
- EXPECT_CALL(*input_injector_, InjectKeyEvent(EqualsUsbEvent(2, true)))
- .InSequence(s);
- EXPECT_CALL(*input_injector_, InjectKeyEvent(EqualsUsbEvent(2, false)))
- .InSequence(s);
- EXPECT_CALL(*input_injector_, InjectMouseEvent(EqualsMouseEvent(200, 201)))
- .InSequence(s);
- EXPECT_CALL(session_event_handler_, OnSessionClosed(_))
- .InSequence(s);
-
- // These events should not get through to the input stub,
- // because the client isn't authenticated yet.
- connection_->input_stub()->InjectKeyEvent(key_event1);
- connection_->input_stub()->InjectMouseEvent(mouse_event1);
-
- ConnectClientSession();
-}
-
TEST_F(ClientSessionTest, LocalInputTest) {
CreateClientSession();

Powered by Google App Engine
This is Rietveld 408576698