| Index: remoting/host/ipc_desktop_environment_unittest.cc
|
| diff --git a/remoting/host/ipc_desktop_environment_unittest.cc b/remoting/host/ipc_desktop_environment_unittest.cc
|
| index d31d3d46acd51160f2aae5e3b6084cd03b66e202..edd70bd8c06205e95f4d278d574b9191abdad759 100644
|
| --- a/remoting/host/ipc_desktop_environment_unittest.cc
|
| +++ b/remoting/host/ipc_desktop_environment_unittest.cc
|
| @@ -169,6 +169,8 @@ class IpcDesktopEnvironmentTest : public testing::Test {
|
| // received.
|
| void OnDesktopAttached(IPC::PlatformFileForTransit desktop_pipe);
|
|
|
| + void RunMainLoopUntilDone();
|
| +
|
| // The main message loop.
|
| base::MessageLoopForUI message_loop_;
|
|
|
| @@ -438,6 +440,12 @@ void IpcDesktopEnvironmentTest::OnDesktopAttached(
|
| terminal_id_, process_handle, desktop_pipe);
|
| }
|
|
|
| +void IpcDesktopEnvironmentTest::RunMainLoopUntilDone() {
|
| + task_runner_ = nullptr;
|
| + io_task_runner_ = nullptr;
|
| + main_run_loop_.Run();
|
| +}
|
| +
|
| // Runs until the desktop is attached and exits immediately after that.
|
| TEST_F(IpcDesktopEnvironmentTest, Basic) {
|
| scoped_ptr<protocol::MockClipboardStub> clipboard_stub(
|
| @@ -454,9 +462,56 @@ TEST_F(IpcDesktopEnvironmentTest, Basic) {
|
| // Stop the test.
|
| DeleteDesktopEnvironment();
|
|
|
| - task_runner_ = nullptr;
|
| - io_task_runner_ = nullptr;
|
| - main_run_loop_.Run();
|
| + RunMainLoopUntilDone();
|
| +}
|
| +
|
| +// Check Capabilities.
|
| +TEST_F(IpcDesktopEnvironmentTest, CapabilitiesNoTouch) {
|
| + scoped_ptr<protocol::MockClipboardStub> clipboard_stub(
|
| + new protocol::MockClipboardStub());
|
| + EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_))
|
| + .Times(0);
|
| +
|
| + EXPECT_EQ("rateLimitResizeRequests", desktop_environment_->GetCapabilities());
|
| +
|
| + // Start the input injector and screen capturer.
|
| + input_injector_->Start(clipboard_stub.Pass());
|
| +
|
| + // Run the message loop until the desktop is attached.
|
| + setup_run_loop_->Run();
|
| +
|
| + // Stop the test.
|
| + DeleteDesktopEnvironment();
|
| +
|
| + RunMainLoopUntilDone();
|
| +}
|
| +
|
| +// Check touchEvents capability is set when the desktop environment can
|
| +// inject touch events.
|
| +TEST_F(IpcDesktopEnvironmentTest, TouchEventsCapabilities) {
|
| + // Create an environment with multi touch enabled.
|
| + desktop_environment_factory_->set_supports_touch_events(true);
|
| + desktop_environment_ = desktop_environment_factory_->Create(
|
| + client_session_control_factory_.GetWeakPtr());
|
| +
|
| + scoped_ptr<protocol::MockClipboardStub> clipboard_stub(
|
| + new protocol::MockClipboardStub());
|
| + EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_))
|
| + .Times(0);
|
| +
|
| + EXPECT_EQ("rateLimitResizeRequests touchEvents",
|
| + desktop_environment_->GetCapabilities());
|
| +
|
| + // Start the input injector and screen capturer.
|
| + input_injector_->Start(clipboard_stub.Pass());
|
| +
|
| + // Run the message loop until the desktop is attached.
|
| + setup_run_loop_->Run();
|
| +
|
| + // Stop the test.
|
| + DeleteDesktopEnvironment();
|
| +
|
| + RunMainLoopUntilDone();
|
| }
|
|
|
| // Tests that the video capturer receives a frame over IPC.
|
| @@ -483,9 +538,7 @@ TEST_F(IpcDesktopEnvironmentTest, CaptureFrame) {
|
| // Capture a single frame.
|
| video_capturer_->Capture(webrtc::DesktopRegion());
|
|
|
| - task_runner_ = nullptr;
|
| - io_task_runner_ = nullptr;
|
| - main_run_loop_.Run();
|
| + RunMainLoopUntilDone();
|
| }
|
|
|
| // Tests that attaching to a new desktop works.
|
| @@ -511,9 +564,7 @@ TEST_F(IpcDesktopEnvironmentTest, Reattach) {
|
| // Stop the test.
|
| DeleteDesktopEnvironment();
|
|
|
| - task_runner_ = nullptr;
|
| - io_task_runner_ = nullptr;
|
| - main_run_loop_.Run();
|
| + RunMainLoopUntilDone();
|
| }
|
|
|
| // Tests injection of clipboard events.
|
| @@ -547,9 +598,7 @@ TEST_F(IpcDesktopEnvironmentTest, InjectClipboardEvent) {
|
| event.set_data("a");
|
| input_injector_->InjectClipboardEvent(event);
|
|
|
| - task_runner_ = nullptr;
|
| - io_task_runner_ = nullptr;
|
| - main_run_loop_.Run();
|
| + RunMainLoopUntilDone();
|
| }
|
|
|
| // Tests injection of key events.
|
| @@ -578,9 +627,7 @@ TEST_F(IpcDesktopEnvironmentTest, InjectKeyEvent) {
|
| event.set_pressed(true);
|
| input_injector_->InjectKeyEvent(event);
|
|
|
| - task_runner_ = nullptr;
|
| - io_task_runner_ = nullptr;
|
| - main_run_loop_.Run();
|
| + RunMainLoopUntilDone();
|
| }
|
|
|
| // Tests injection of text events.
|
| @@ -608,9 +655,7 @@ TEST_F(IpcDesktopEnvironmentTest, InjectTextEvent) {
|
| event.set_text("hello");
|
| input_injector_->InjectTextEvent(event);
|
|
|
| - task_runner_ = nullptr;
|
| - io_task_runner_ = nullptr;
|
| - main_run_loop_.Run();
|
| + RunMainLoopUntilDone();
|
| }
|
|
|
| // Tests injection of mouse events.
|
| @@ -639,9 +684,7 @@ TEST_F(IpcDesktopEnvironmentTest, InjectMouseEvent) {
|
| event.set_y(0);
|
| input_injector_->InjectMouseEvent(event);
|
|
|
| - task_runner_ = nullptr;
|
| - io_task_runner_ = nullptr;
|
| - main_run_loop_.Run();
|
| + RunMainLoopUntilDone();
|
| }
|
|
|
| // Tests injection of touch events.
|
| @@ -685,9 +728,7 @@ TEST_F(IpcDesktopEnvironmentTest, InjectTouchEvent) {
|
| // Send the touch event.
|
| input_injector_->InjectTouchEvent(event);
|
|
|
| - task_runner_ = nullptr;
|
| - io_task_runner_ = nullptr;
|
| - main_run_loop_.Run();
|
| + RunMainLoopUntilDone();
|
| }
|
|
|
| // Tests that setting the desktop resolution works.
|
| @@ -714,9 +755,7 @@ TEST_F(IpcDesktopEnvironmentTest, SetScreenResolution) {
|
| webrtc::DesktopSize(100, 100),
|
| webrtc::DesktopVector(96, 96)));
|
|
|
| - task_runner_ = nullptr;
|
| - io_task_runner_ = nullptr;
|
| - main_run_loop_.Run();
|
| + RunMainLoopUntilDone();
|
| }
|
|
|
| } // namespace remoting
|
|
|