| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <string> | 6 #include <string> |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 ACTION_P2(DeliverClientMessage, client_session, message) { | 80 ACTION_P2(DeliverClientMessage, client_session, message) { |
| 81 client_session->DeliverClientMessage(message); | 81 client_session->DeliverClientMessage(message); |
| 82 } | 82 } |
| 83 | 83 |
| 84 ACTION_P2(SetCapabilities, client_session, capabilities) { | 84 ACTION_P2(SetCapabilities, client_session, capabilities) { |
| 85 protocol::Capabilities capabilities_message; | 85 protocol::Capabilities capabilities_message; |
| 86 capabilities_message.set_capabilities(capabilities); | 86 capabilities_message.set_capabilities(capabilities); |
| 87 client_session->SetCapabilities(capabilities_message); | 87 client_session->SetCapabilities(capabilities_message); |
| 88 } | 88 } |
| 89 | 89 |
| 90 MATCHER_P2(EqualsUsbEvent, usb_keycode, pressed, "") { |
| 91 return arg.usb_keycode() == (unsigned int)usb_keycode && |
| 92 arg.pressed() == pressed; |
| 93 } |
| 94 |
| 95 MATCHER_P2(EqualsMouseEvent, x, y, "") { |
| 96 return arg.x() == x && arg.y() == y; |
| 97 } |
| 98 |
| 99 MATCHER_P2(EqualsMouseButtonEvent, button, down, "") { |
| 100 return arg.button() == button && arg.button_down() == down; |
| 101 } |
| 102 |
| 90 // Matches a |protocol::Capabilities| argument against a list of capabilities | 103 // Matches a |protocol::Capabilities| argument against a list of capabilities |
| 91 // formatted as a space-separated string. | 104 // formatted as a space-separated string. |
| 92 MATCHER_P(EqCapabilities, expected_capabilities, "") { | 105 MATCHER_P(EqCapabilities, expected_capabilities, "") { |
| 93 if (!arg.has_capabilities()) | 106 if (!arg.has_capabilities()) |
| 94 return false; | 107 return false; |
| 95 | 108 |
| 96 std::vector<std::string> words_args; | 109 std::vector<std::string> words_args; |
| 97 std::vector<std::string> words_expected; | 110 std::vector<std::string> words_expected; |
| 98 Tokenize(arg.capabilities(), " ", &words_args); | 111 Tokenize(arg.capabilities(), " ", &words_args); |
| 99 Tokenize(expected_capabilities, " ", &words_expected); | 112 Tokenize(expected_capabilities, " ", &words_expected); |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 EXPECT_CALL(session_event_handler_, OnSessionClosed(_)) | 375 EXPECT_CALL(session_event_handler_, OnSessionClosed(_)) |
| 363 .InSequence(s); | 376 .InSequence(s); |
| 364 | 377 |
| 365 // This event should not get through to the clipboard stub, | 378 // This event should not get through to the clipboard stub, |
| 366 // because the client isn't authenticated yet. | 379 // because the client isn't authenticated yet. |
| 367 connection_->clipboard_stub()->InjectClipboardEvent(clipboard_event1); | 380 connection_->clipboard_stub()->InjectClipboardEvent(clipboard_event1); |
| 368 | 381 |
| 369 ConnectClientSession(); | 382 ConnectClientSession(); |
| 370 } | 383 } |
| 371 | 384 |
| 372 namespace { | |
| 373 | |
| 374 MATCHER_P2(EqualsUsbEvent, usb_keycode, pressed, "") { | |
| 375 return arg.usb_keycode() == (unsigned int)usb_keycode && | |
| 376 arg.pressed() == pressed; | |
| 377 } | |
| 378 | |
| 379 MATCHER_P2(EqualsMouseEvent, x, y, "") { | |
| 380 return arg.x() == x && arg.y() == y; | |
| 381 } | |
| 382 | |
| 383 MATCHER_P2(EqualsMouseButtonEvent, button, down, "") { | |
| 384 return arg.button() == button && arg.button_down() == down; | |
| 385 } | |
| 386 | |
| 387 } // namespace | |
| 388 | |
| 389 TEST_F(ClientSessionTest, InputStubFilter) { | 385 TEST_F(ClientSessionTest, InputStubFilter) { |
| 390 CreateClientSession(); | 386 CreateClientSession(); |
| 391 | 387 |
| 392 protocol::KeyEvent key_event1; | 388 protocol::KeyEvent key_event1; |
| 393 key_event1.set_pressed(true); | 389 key_event1.set_pressed(true); |
| 394 key_event1.set_usb_keycode(1); | 390 key_event1.set_usb_keycode(1); |
| 395 | 391 |
| 396 protocol::KeyEvent key_event2_down; | 392 protocol::KeyEvent key_event2_down; |
| 397 key_event2_down.set_pressed(true); | 393 key_event2_down.set_pressed(true); |
| 398 key_event2_down.set_usb_keycode(2); | 394 key_event2_down.set_usb_keycode(2); |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 800 | 796 |
| 801 DisconnectClientSession(); | 797 DisconnectClientSession(); |
| 802 StopClientSession(); | 798 StopClientSession(); |
| 803 | 799 |
| 804 // ext1 was instantiated and wrapped the video capturer. | 800 // ext1 was instantiated and wrapped the video capturer. |
| 805 EXPECT_TRUE(extension.was_instantiated()); | 801 EXPECT_TRUE(extension.was_instantiated()); |
| 806 EXPECT_TRUE(extension.has_wrapped_video_capturer()); | 802 EXPECT_TRUE(extension.has_wrapped_video_capturer()); |
| 807 } | 803 } |
| 808 | 804 |
| 809 } // namespace remoting | 805 } // namespace remoting |
| OLD | NEW |