Index: remoting/host/chromoting_host_unittest.cc |
diff --git a/remoting/host/chromoting_host_unittest.cc b/remoting/host/chromoting_host_unittest.cc |
index 0235512fe1a30c8d783ff8cdc973d6d459c70a85..732adee0a87f4ed14d1dfdae0bc106fdf249364f 100644 |
--- a/remoting/host/chromoting_host_unittest.cc |
+++ b/remoting/host/chromoting_host_unittest.cc |
@@ -11,9 +11,7 @@ |
#include "remoting/host/audio_capturer.h" |
#include "remoting/host/chromoting_host.h" |
#include "remoting/host/chromoting_host_context.h" |
-#include "remoting/host/desktop_environment.h" |
#include "remoting/host/desktop_environment_factory.h" |
-#include "remoting/host/event_executor_fake.h" |
#include "remoting/host/host_mock_objects.h" |
#include "remoting/host/it2me_host_user_interface.h" |
#include "remoting/jingle_glue/mock_objects.h" |
@@ -118,7 +116,8 @@ class ChromotingHostTest : public testing::Test { |
base::Bind(&ChromotingHostTest::QuitMainMessageLoop, |
base::Unretained(this))); |
- desktop_environment_factory_.reset(new MockDesktopEnvironmentFactory()); |
+ desktop_environment_factory_.reset( |
+ new MockDesktopEnvironmentFactory(ui_task_runner_)); |
EXPECT_CALL(*desktop_environment_factory_, CreatePtr()) |
.Times(AnyNumber()) |
.WillRepeatedly(Invoke(this, |
@@ -131,9 +130,11 @@ class ChromotingHostTest : public testing::Test { |
desktop_environment_factory_.get(), |
scoped_ptr<protocol::SessionManager>(session_manager_), |
ui_task_runner_, // Audio |
+ ui_task_runner_, // Input |
ui_task_runner_, // Video capture |
ui_task_runner_, // Video encode |
- ui_task_runner_); // Network |
+ ui_task_runner_, // Network |
+ ui_task_runner_); // UI |
host_->AddStatusObserver(&host_status_observer_); |
disconnect_window_ = new MockDisconnectWindow(); |
@@ -237,9 +238,11 @@ class ChromotingHostTest : public testing::Test { |
scoped_refptr<ClientSession> client = new ClientSession( |
host_.get(), |
ui_task_runner_, // Audio |
+ ui_task_runner_, // Input |
ui_task_runner_, // Video capture |
ui_task_runner_, // Video encode |
ui_task_runner_, // Network |
+ ui_task_runner_, // UI |
connection.Pass(), |
desktop_environment_factory_.get(), |
base::TimeDelta()); |
@@ -280,12 +283,38 @@ class ChromotingHostTest : public testing::Test { |
host_->OnSessionRouteChange(get_client(0), channel_name, route); |
} |
+ // Creates a DesktopEnvironment with a fake VideoFrameCapturer, to mock |
+ // DesktopEnvironmentFactory::Create(). |
DesktopEnvironment* CreateDesktopEnvironment() { |
- scoped_ptr<EventExecutor> event_executor(new EventExecutorFake()); |
- scoped_ptr<VideoFrameCapturer> video_capturer(new VideoFrameCapturerFake()); |
- return new DesktopEnvironment(scoped_ptr<AudioCapturer>(NULL), |
- event_executor.Pass(), |
- video_capturer.Pass()); |
+ MockDesktopEnvironment* desktop_environment = new MockDesktopEnvironment(); |
+ EXPECT_CALL(*desktop_environment, CreateAudioCapturerPtr(_)) |
+ .Times(0); |
+ EXPECT_CALL(*desktop_environment, CreateEventExecutorPtr(_, _)) |
+ .Times(AnyNumber()) |
+ .WillRepeatedly(Invoke(this, &ChromotingHostTest::CreateEventExecutor)); |
+ EXPECT_CALL(*desktop_environment, CreateVideoCapturerPtr(_, _)) |
+ .Times(AnyNumber()) |
+ .WillRepeatedly(Invoke(this, &ChromotingHostTest::CreateVideoCapturer)); |
+ |
+ return desktop_environment; |
+ } |
+ |
+ // Creates a dummy EventExecutor, to mock |
+ // DesktopEnvironment::CreateEventExecutor(). |
+ EventExecutor* CreateEventExecutor( |
+ scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, |
+ scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { |
+ MockEventExecutor* event_executor = new MockEventExecutor(); |
+ EXPECT_CALL(*event_executor, StartPtr(_)); |
+ return event_executor; |
+ } |
+ |
+ // Creates a fake VideoFrameCapturer, to mock |
+ // DesktopEnvironment::CreateVideoCapturer(). |
+ VideoFrameCapturer* CreateVideoCapturer( |
+ scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner, |
+ scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner) { |
+ return new VideoFrameCapturerFake(); |
} |
void DisconnectAllClients() { |
@@ -336,6 +365,7 @@ class ChromotingHostTest : public testing::Test { |
it2me_host_user_interface_.reset(); |
ui_task_runner_ = NULL; |
host_ = NULL; |
+ desktop_environment_factory_.reset(); |
} |
void QuitMainMessageLoop() { |