Index: remoting/host/desktop_process_unittest.cc |
diff --git a/remoting/host/desktop_process_unittest.cc b/remoting/host/desktop_process_unittest.cc |
index f9a8f13eb71efeee825cbbf4ab18bfc700298168..721206a1f3656eaa5886831b74c21e6b0ab25be7 100644 |
--- a/remoting/host/desktop_process_unittest.cc |
+++ b/remoting/host/desktop_process_unittest.cc |
@@ -15,11 +15,14 @@ |
#include "ipc/ipc_channel_proxy.h" |
#include "ipc/ipc_listener.h" |
#include "ipc/ipc_message.h" |
+#include "media/video/capture/screen/screen_capturer_fake.h" |
#include "remoting/base/auto_thread.h" |
#include "remoting/base/auto_thread_task_runner.h" |
#include "remoting/host/chromoting_messages.h" |
#include "remoting/host/desktop_process.h" |
#include "remoting/host/host_exit_codes.h" |
+#include "remoting/host/host_mock_objects.h" |
+#include "remoting/protocol/protocol_mock_objects.h" |
#include "testing/gmock_mutant.h" |
#include "testing/gmock/include/gmock/gmock.h" |
#include "testing/gtest/include/gtest/gtest.h" |
@@ -27,6 +30,7 @@ |
using testing::_; |
using testing::AnyNumber; |
using testing::InSequence; |
+using testing::Return; |
namespace remoting { |
@@ -98,6 +102,18 @@ class DesktopProcessTest : public testing::Test { |
void ConnectNetworkChannel(IPC::PlatformFileForTransit desktop_process); |
void OnDesktopAttached(IPC::PlatformFileForTransit desktop_process); |
+ // Creates a DesktopEnvironment with a fake media::ScreenCapturer, to mock |
+ // DesktopEnvironmentFactory::Create(). |
+ DesktopEnvironment* CreateDesktopEnvironment(); |
+ |
+ // Creates a dummy EventExecutor, to mock |
+ // DesktopEnvironment::CreateEventExecutor(). |
+ EventExecutor* CreateEventExecutor(); |
+ |
+ // Creates a fake media::ScreenCapturer, to mock |
+ // DesktopEnvironment::CreateVideoCapturer(). |
+ media::ScreenCapturer* CreateVideoCapturer(); |
+ |
// Disconnects the daemon-to-desktop channel causing the desktop process to |
// exit. |
void DisconnectChannels(); |
@@ -169,6 +185,32 @@ void DesktopProcessTest::OnDesktopAttached( |
#endif // defined(OS_POSIX) |
} |
+DesktopEnvironment* DesktopProcessTest::CreateDesktopEnvironment() { |
+ MockDesktopEnvironment* desktop_environment = new MockDesktopEnvironment(); |
+ EXPECT_CALL(*desktop_environment, CreateAudioCapturerPtr(_)) |
+ .Times(0); |
+ EXPECT_CALL(*desktop_environment, CreateEventExecutorPtr(_, _)) |
+ .Times(AnyNumber()) |
+ .WillRepeatedly( |
+ InvokeWithoutArgs(this, &DesktopProcessTest::CreateEventExecutor)); |
+ EXPECT_CALL(*desktop_environment, CreateVideoCapturerPtr(_, _)) |
+ .Times(AnyNumber()) |
+ .WillRepeatedly( |
+ InvokeWithoutArgs(this, &DesktopProcessTest::CreateVideoCapturer)); |
Wez
2013/02/01 01:02:11
This will end up adding expectations after the tes
alexeypa (please no reviews)
2013/02/01 17:28:43
We use this pattern (create a new object and set a
Wez
2013/02/01 17:30:24
Yes, I think that the newly-created-object aspect
|
+ |
Wez
2013/02/01 01:02:11
nit: Don't really need a blank line here.
alexeypa (please no reviews)
2013/02/01 17:28:43
Done.
|
+ return desktop_environment; |
+} |
+ |
+EventExecutor* DesktopProcessTest::CreateEventExecutor() { |
+ MockEventExecutor* event_executor = new MockEventExecutor(); |
+ EXPECT_CALL(*event_executor, StartPtr(_)); |
+ return event_executor; |
+} |
+ |
+media::ScreenCapturer* DesktopProcessTest::CreateVideoCapturer() { |
+ return new media::ScreenCapturerFake(); |
+} |
+ |
void DesktopProcessTest::DisconnectChannels() { |
daemon_channel_.reset(); |
network_channel_.reset(); |
@@ -194,8 +236,19 @@ void DesktopProcessTest::RunDesktopProcess() { |
&daemon_listener_, |
io_task_runner_)); |
+ scoped_ptr<MockDesktopEnvironmentFactory> desktop_environment_factory( |
+ new MockDesktopEnvironmentFactory()); |
+ EXPECT_CALL(*desktop_environment_factory, CreatePtr()) |
+ .Times(AnyNumber()) |
+ .WillRepeatedly(Invoke(this, |
+ &DesktopProcessTest::CreateDesktopEnvironment)); |
+ EXPECT_CALL(*desktop_environment_factory, SupportsAudioCapture()) |
+ .Times(AnyNumber()) |
+ .WillRepeatedly(Return(false)); |
+ |
DesktopProcess desktop_process(ui_task_runner, channel_name); |
- EXPECT_TRUE(desktop_process.Start()); |
+ EXPECT_TRUE(desktop_process.Start( |
+ desktop_environment_factory.PassAs<DesktopEnvironmentFactory>())); |
ui_task_runner = NULL; |
run_loop.Run(); |