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 "remoting/host/desktop_process.h" | 5 #include "remoting/host/desktop_process.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 virtual void TearDown() OVERRIDE; | 101 virtual void TearDown() OVERRIDE; |
102 | 102 |
103 // MockDaemonListener mocks | 103 // MockDaemonListener mocks |
104 void ConnectNetworkChannel(IPC::PlatformFileForTransit desktop_process); | 104 void ConnectNetworkChannel(IPC::PlatformFileForTransit desktop_process); |
105 void OnDesktopAttached(IPC::PlatformFileForTransit desktop_process); | 105 void OnDesktopAttached(IPC::PlatformFileForTransit desktop_process); |
106 | 106 |
107 // Creates a DesktopEnvironment with a fake media::ScreenCapturer, to mock | 107 // Creates a DesktopEnvironment with a fake media::ScreenCapturer, to mock |
108 // DesktopEnvironmentFactory::Create(). | 108 // DesktopEnvironmentFactory::Create(). |
109 DesktopEnvironment* CreateDesktopEnvironment(); | 109 DesktopEnvironment* CreateDesktopEnvironment(); |
110 | 110 |
111 // Creates a dummy EventExecutor, to mock | 111 // Creates a dummy InputInjector, to mock |
112 // DesktopEnvironment::CreateEventExecutor(). | 112 // DesktopEnvironment::CreateInputInjector(). |
113 EventExecutor* CreateEventExecutor(); | 113 InputInjector* CreateInputInjector(); |
114 | 114 |
115 // Creates a dummy SessionController, to mock | 115 // Creates a dummy SessionController, to mock |
116 // DesktopEnvironment::CreateSessionController(). | 116 // DesktopEnvironment::CreateSessionController(). |
117 SessionController* CreateSessionController(); | 117 SessionController* CreateSessionController(); |
118 | 118 |
119 // Creates a fake media::ScreenCapturer, to mock | 119 // Creates a fake media::ScreenCapturer, to mock |
120 // DesktopEnvironment::CreateVideoCapturer(). | 120 // DesktopEnvironment::CreateVideoCapturer(). |
121 media::ScreenCapturer* CreateVideoCapturer(); | 121 media::ScreenCapturer* CreateVideoCapturer(); |
122 | 122 |
123 // Disconnects the daemon-to-desktop channel causing the desktop process to | 123 // Disconnects the daemon-to-desktop channel causing the desktop process to |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 DCHECK(desktop_process.auto_close); | 194 DCHECK(desktop_process.auto_close); |
195 | 195 |
196 base::ClosePlatformFile(desktop_process.fd); | 196 base::ClosePlatformFile(desktop_process.fd); |
197 #endif // defined(OS_POSIX) | 197 #endif // defined(OS_POSIX) |
198 } | 198 } |
199 | 199 |
200 DesktopEnvironment* DesktopProcessTest::CreateDesktopEnvironment() { | 200 DesktopEnvironment* DesktopProcessTest::CreateDesktopEnvironment() { |
201 MockDesktopEnvironment* desktop_environment = new MockDesktopEnvironment(); | 201 MockDesktopEnvironment* desktop_environment = new MockDesktopEnvironment(); |
202 EXPECT_CALL(*desktop_environment, CreateAudioCapturerPtr(_)) | 202 EXPECT_CALL(*desktop_environment, CreateAudioCapturerPtr(_)) |
203 .Times(0); | 203 .Times(0); |
204 EXPECT_CALL(*desktop_environment, CreateEventExecutorPtr(_, _)) | 204 EXPECT_CALL(*desktop_environment, CreateInputInjectorPtr(_, _)) |
205 .Times(AnyNumber()) | 205 .Times(AnyNumber()) |
206 .WillRepeatedly( | 206 .WillRepeatedly( |
207 InvokeWithoutArgs(this, &DesktopProcessTest::CreateEventExecutor)); | 207 InvokeWithoutArgs(this, &DesktopProcessTest::CreateInputInjector)); |
208 EXPECT_CALL(*desktop_environment, CreateSessionControllerPtr()) | 208 EXPECT_CALL(*desktop_environment, CreateSessionControllerPtr()) |
209 .Times(AnyNumber()) | 209 .Times(AnyNumber()) |
210 .WillRepeatedly( | 210 .WillRepeatedly( |
211 InvokeWithoutArgs(this, | 211 InvokeWithoutArgs(this, |
212 &DesktopProcessTest::CreateSessionController)); | 212 &DesktopProcessTest::CreateSessionController)); |
213 EXPECT_CALL(*desktop_environment, CreateVideoCapturerPtr(_, _)) | 213 EXPECT_CALL(*desktop_environment, CreateVideoCapturerPtr(_, _)) |
214 .Times(AnyNumber()) | 214 .Times(AnyNumber()) |
215 .WillRepeatedly( | 215 .WillRepeatedly( |
216 InvokeWithoutArgs(this, &DesktopProcessTest::CreateVideoCapturer)); | 216 InvokeWithoutArgs(this, &DesktopProcessTest::CreateVideoCapturer)); |
217 | 217 |
218 // Notify the test that the desktop environment has been created. | 218 // Notify the test that the desktop environment has been created. |
219 network_listener_.OnDesktopEnvironmentCreated(); | 219 network_listener_.OnDesktopEnvironmentCreated(); |
220 return desktop_environment; | 220 return desktop_environment; |
221 } | 221 } |
222 | 222 |
223 EventExecutor* DesktopProcessTest::CreateEventExecutor() { | 223 InputInjector* DesktopProcessTest::CreateInputInjector() { |
224 MockEventExecutor* event_executor = new MockEventExecutor(); | 224 MockInputInjector* input_injector = new MockInputInjector(); |
225 EXPECT_CALL(*event_executor, StartPtr(_)); | 225 EXPECT_CALL(*input_injector, StartPtr(_)); |
226 return event_executor; | 226 return input_injector; |
227 } | 227 } |
228 | 228 |
229 SessionController* DesktopProcessTest::CreateSessionController() { | 229 SessionController* DesktopProcessTest::CreateSessionController() { |
230 return new MockSessionController(); | 230 return new MockSessionController(); |
231 } | 231 } |
232 | 232 |
233 media::ScreenCapturer* DesktopProcessTest::CreateVideoCapturer() { | 233 media::ScreenCapturer* DesktopProcessTest::CreateVideoCapturer() { |
234 return new media::ScreenCapturerFake(); | 234 return new media::ScreenCapturerFake(); |
235 } | 235 } |
236 | 236 |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 } | 355 } |
356 | 356 |
357 // Run the desktop process and ask it to crash. | 357 // Run the desktop process and ask it to crash. |
358 TEST_F(DesktopProcessTest, DeathTest) { | 358 TEST_F(DesktopProcessTest, DeathTest) { |
359 testing::GTEST_FLAG(death_test_style) = "threadsafe"; | 359 testing::GTEST_FLAG(death_test_style) = "threadsafe"; |
360 | 360 |
361 EXPECT_DEATH(RunDeathTest(), ""); | 361 EXPECT_DEATH(RunDeathTest(), ""); |
362 } | 362 } |
363 | 363 |
364 } // namespace remoting | 364 } // namespace remoting |
OLD | NEW |