| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/message_loop_proxy.h" | 8 #include "base/message_loop_proxy.h" |
| 9 #include "media/video/capture/screen/screen_capturer_fake.h" |
| 9 #include "remoting/base/auto_thread_task_runner.h" | 10 #include "remoting/base/auto_thread_task_runner.h" |
| 10 #include "remoting/capturer/video_frame_capturer_fake.h" | |
| 11 #include "remoting/host/audio_capturer.h" | 11 #include "remoting/host/audio_capturer.h" |
| 12 #include "remoting/host/chromoting_host.h" | 12 #include "remoting/host/chromoting_host.h" |
| 13 #include "remoting/host/chromoting_host_context.h" | 13 #include "remoting/host/chromoting_host_context.h" |
| 14 #include "remoting/host/desktop_environment.h" | 14 #include "remoting/host/desktop_environment.h" |
| 15 #include "remoting/host/host_mock_objects.h" | 15 #include "remoting/host/host_mock_objects.h" |
| 16 #include "remoting/host/it2me_host_user_interface.h" | 16 #include "remoting/host/it2me_host_user_interface.h" |
| 17 #include "remoting/jingle_glue/mock_objects.h" | 17 #include "remoting/jingle_glue/mock_objects.h" |
| 18 #include "remoting/proto/video.pb.h" | 18 #include "remoting/proto/video.pb.h" |
| 19 #include "remoting/protocol/errors.h" | 19 #include "remoting/protocol/errors.h" |
| 20 #include "remoting/protocol/protocol_mock_objects.h" | 20 #include "remoting/protocol/protocol_mock_objects.h" |
| 21 #include "remoting/protocol/session_config.h" | 21 #include "remoting/protocol/session_config.h" |
| 22 #include "testing/gmock/include/gmock/gmock.h" |
| 22 #include "testing/gmock_mutant.h" | 23 #include "testing/gmock_mutant.h" |
| 23 #include "testing/gmock/include/gmock/gmock.h" | |
| 24 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
| 25 | 25 |
| 26 using ::remoting::protocol::MockClientStub; | 26 using ::remoting::protocol::MockClientStub; |
| 27 using ::remoting::protocol::MockConnectionToClient; | 27 using ::remoting::protocol::MockConnectionToClient; |
| 28 using ::remoting::protocol::MockConnectionToClientEventHandler; | 28 using ::remoting::protocol::MockConnectionToClientEventHandler; |
| 29 using ::remoting::protocol::MockHostStub; | 29 using ::remoting::protocol::MockHostStub; |
| 30 using ::remoting::protocol::MockSession; | 30 using ::remoting::protocol::MockSession; |
| 31 using ::remoting::protocol::MockVideoStub; | 31 using ::remoting::protocol::MockVideoStub; |
| 32 using ::remoting::protocol::SessionConfig; | 32 using ::remoting::protocol::SessionConfig; |
| 33 | 33 |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 // Make sure that the host has been properly deleted. | 278 // Make sure that the host has been properly deleted. |
| 279 DCHECK(host_.get() == NULL); | 279 DCHECK(host_.get() == NULL); |
| 280 } | 280 } |
| 281 | 281 |
| 282 // Change the session route for |client1_|. | 282 // Change the session route for |client1_|. |
| 283 void ChangeSessionRoute(const std::string& channel_name, | 283 void ChangeSessionRoute(const std::string& channel_name, |
| 284 const protocol::TransportRoute& route) { | 284 const protocol::TransportRoute& route) { |
| 285 host_->OnSessionRouteChange(get_client(0), channel_name, route); | 285 host_->OnSessionRouteChange(get_client(0), channel_name, route); |
| 286 } | 286 } |
| 287 | 287 |
| 288 // Creates a DesktopEnvironment with a fake VideoFrameCapturer, to mock | 288 // Creates a DesktopEnvironment with a fake media::ScreenCapturer, to mock |
| 289 // DesktopEnvironmentFactory::Create(). | 289 // DesktopEnvironmentFactory::Create(). |
| 290 DesktopEnvironment* CreateDesktopEnvironment() { | 290 DesktopEnvironment* CreateDesktopEnvironment() { |
| 291 MockDesktopEnvironment* desktop_environment = new MockDesktopEnvironment(); | 291 MockDesktopEnvironment* desktop_environment = new MockDesktopEnvironment(); |
| 292 EXPECT_CALL(*desktop_environment, CreateAudioCapturerPtr(_)) | 292 EXPECT_CALL(*desktop_environment, CreateAudioCapturerPtr(_)) |
| 293 .Times(0); | 293 .Times(0); |
| 294 EXPECT_CALL(*desktop_environment, CreateEventExecutorPtr(_, _)) | 294 EXPECT_CALL(*desktop_environment, CreateEventExecutorPtr(_, _)) |
| 295 .Times(AnyNumber()) | 295 .Times(AnyNumber()) |
| 296 .WillRepeatedly(Invoke(this, &ChromotingHostTest::CreateEventExecutor)); | 296 .WillRepeatedly(Invoke(this, &ChromotingHostTest::CreateEventExecutor)); |
| 297 EXPECT_CALL(*desktop_environment, CreateVideoCapturerPtr(_, _)) | 297 EXPECT_CALL(*desktop_environment, CreateVideoCapturerPtr(_, _)) |
| 298 .Times(AnyNumber()) | 298 .Times(AnyNumber()) |
| 299 .WillRepeatedly(Invoke(this, &ChromotingHostTest::CreateVideoCapturer)); | 299 .WillRepeatedly(Invoke(this, &ChromotingHostTest::CreateVideoCapturer)); |
| 300 | 300 |
| 301 return desktop_environment; | 301 return desktop_environment; |
| 302 } | 302 } |
| 303 | 303 |
| 304 // Creates a dummy EventExecutor, to mock | 304 // Creates a dummy EventExecutor, to mock |
| 305 // DesktopEnvironment::CreateEventExecutor(). | 305 // DesktopEnvironment::CreateEventExecutor(). |
| 306 EventExecutor* CreateEventExecutor( | 306 EventExecutor* CreateEventExecutor( |
| 307 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, | 307 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, |
| 308 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { | 308 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { |
| 309 MockEventExecutor* event_executor = new MockEventExecutor(); | 309 MockEventExecutor* event_executor = new MockEventExecutor(); |
| 310 EXPECT_CALL(*event_executor, StartPtr(_)); | 310 EXPECT_CALL(*event_executor, StartPtr(_)); |
| 311 return event_executor; | 311 return event_executor; |
| 312 } | 312 } |
| 313 | 313 |
| 314 // Creates a fake VideoFrameCapturer, to mock | 314 // Creates a fake media::ScreenCapturer, to mock |
| 315 // DesktopEnvironment::CreateVideoCapturer(). | 315 // DesktopEnvironment::CreateVideoCapturer(). |
| 316 VideoFrameCapturer* CreateVideoCapturer( | 316 media::ScreenCapturer* CreateVideoCapturer( |
| 317 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner, | 317 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner, |
| 318 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner) { | 318 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner) { |
| 319 return new VideoFrameCapturerFake(); | 319 return new media::ScreenCapturerFake(); |
| 320 } | 320 } |
| 321 | 321 |
| 322 void DisconnectAllClients() { | 322 void DisconnectAllClients() { |
| 323 host_->DisconnectAllClients(); | 323 host_->DisconnectAllClients(); |
| 324 } | 324 } |
| 325 | 325 |
| 326 // Helper method to disconnect client 1 from the host. | 326 // Helper method to disconnect client 1 from the host. |
| 327 void DisconnectClient1() { | 327 void DisconnectClient1() { |
| 328 NotifyClientSessionClosed(0); | 328 NotifyClientSessionClosed(0); |
| 329 } | 329 } |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 719 ExpectClientDisconnected(0, true, video_packet_sent, | 719 ExpectClientDisconnected(0, true, video_packet_sent, |
| 720 InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost)); | 720 InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost)); |
| 721 EXPECT_CALL(host_status_observer_, OnShutdown()); | 721 EXPECT_CALL(host_status_observer_, OnShutdown()); |
| 722 | 722 |
| 723 host_->Start(xmpp_login_); | 723 host_->Start(xmpp_login_); |
| 724 SimulateClientConnection(0, true, false); | 724 SimulateClientConnection(0, true, false); |
| 725 message_loop_.Run(); | 725 message_loop_.Run(); |
| 726 } | 726 } |
| 727 | 727 |
| 728 } // namespace remoting | 728 } // namespace remoting |
| OLD | NEW |