| 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 <map> | 5 #include <map> |
| 6 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 | 175 |
| 176 private: | 176 private: |
| 177 virtual ~MockVideoCaptureHost() { | 177 virtual ~MockVideoCaptureHost() { |
| 178 STLDeleteContainerPairSecondPointers(filled_dib_.begin(), | 178 STLDeleteContainerPairSecondPointers(filled_dib_.begin(), |
| 179 filled_dib_.end()); | 179 filled_dib_.end()); |
| 180 } | 180 } |
| 181 | 181 |
| 182 // This method is used to dispatch IPC messages to the renderer. We intercept | 182 // This method is used to dispatch IPC messages to the renderer. We intercept |
| 183 // these messages here and dispatch to our mock methods to verify the | 183 // these messages here and dispatch to our mock methods to verify the |
| 184 // conversation between this object and the renderer. | 184 // conversation between this object and the renderer. |
| 185 virtual bool Send(IPC::Message* message) OVERRIDE { | 185 virtual bool Send(IPC::Message* message) override { |
| 186 CHECK(message); | 186 CHECK(message); |
| 187 | 187 |
| 188 // In this method we dispatch the messages to the according handlers as if | 188 // In this method we dispatch the messages to the according handlers as if |
| 189 // we are the renderer. | 189 // we are the renderer. |
| 190 bool handled = true; | 190 bool handled = true; |
| 191 IPC_BEGIN_MESSAGE_MAP(MockVideoCaptureHost, *message) | 191 IPC_BEGIN_MESSAGE_MAP(MockVideoCaptureHost, *message) |
| 192 IPC_MESSAGE_HANDLER(VideoCaptureMsg_NewBuffer, OnNewBufferCreatedDispatch) | 192 IPC_MESSAGE_HANDLER(VideoCaptureMsg_NewBuffer, OnNewBufferCreatedDispatch) |
| 193 IPC_MESSAGE_HANDLER(VideoCaptureMsg_FreeBuffer, OnBufferFreedDispatch) | 193 IPC_MESSAGE_HANDLER(VideoCaptureMsg_FreeBuffer, OnBufferFreedDispatch) |
| 194 IPC_MESSAGE_HANDLER(VideoCaptureMsg_BufferReady, OnBufferFilledDispatch) | 194 IPC_MESSAGE_HANDLER(VideoCaptureMsg_BufferReady, OnBufferFilledDispatch) |
| 195 IPC_MESSAGE_HANDLER(VideoCaptureMsg_MailboxBufferReady, | 195 IPC_MESSAGE_HANDLER(VideoCaptureMsg_MailboxBufferReady, |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 // This is an integration test of VideoCaptureHost in conjunction with | 280 // This is an integration test of VideoCaptureHost in conjunction with |
| 281 // MediaStreamManager, VideoCaptureManager, VideoCaptureController, and | 281 // MediaStreamManager, VideoCaptureManager, VideoCaptureController, and |
| 282 // VideoCaptureDevice. | 282 // VideoCaptureDevice. |
| 283 class VideoCaptureHostTest : public testing::Test { | 283 class VideoCaptureHostTest : public testing::Test { |
| 284 public: | 284 public: |
| 285 VideoCaptureHostTest() | 285 VideoCaptureHostTest() |
| 286 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), | 286 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), |
| 287 message_loop_(base::MessageLoopProxy::current()), | 287 message_loop_(base::MessageLoopProxy::current()), |
| 288 opened_session_id_(kInvalidMediaCaptureSessionId) {} | 288 opened_session_id_(kInvalidMediaCaptureSessionId) {} |
| 289 | 289 |
| 290 virtual void SetUp() OVERRIDE { | 290 virtual void SetUp() override { |
| 291 SetBrowserClientForTesting(&browser_client_); | 291 SetBrowserClientForTesting(&browser_client_); |
| 292 | 292 |
| 293 #if defined(OS_CHROMEOS) | 293 #if defined(OS_CHROMEOS) |
| 294 chromeos::CrasAudioHandler::InitializeForTesting(); | 294 chromeos::CrasAudioHandler::InitializeForTesting(); |
| 295 #endif | 295 #endif |
| 296 | 296 |
| 297 // Create our own MediaStreamManager. | 297 // Create our own MediaStreamManager. |
| 298 audio_manager_.reset(media::AudioManager::CreateForTesting()); | 298 audio_manager_.reset(media::AudioManager::CreateForTesting()); |
| 299 #ifndef TEST_REAL_CAPTURE_DEVICE | 299 #ifndef TEST_REAL_CAPTURE_DEVICE |
| 300 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 300 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 301 switches::kUseFakeDeviceForMediaStream); | 301 switches::kUseFakeDeviceForMediaStream); |
| 302 #endif | 302 #endif |
| 303 media_stream_manager_.reset(new MediaStreamManager(audio_manager_.get())); | 303 media_stream_manager_.reset(new MediaStreamManager(audio_manager_.get())); |
| 304 media_stream_manager_->UseFakeUI(scoped_ptr<FakeMediaStreamUIProxy>()); | 304 media_stream_manager_->UseFakeUI(scoped_ptr<FakeMediaStreamUIProxy>()); |
| 305 | 305 |
| 306 // Create a Host and connect it to a simulated IPC channel. | 306 // Create a Host and connect it to a simulated IPC channel. |
| 307 host_ = new MockVideoCaptureHost(media_stream_manager_.get()); | 307 host_ = new MockVideoCaptureHost(media_stream_manager_.get()); |
| 308 host_->OnChannelConnected(base::GetCurrentProcId()); | 308 host_->OnChannelConnected(base::GetCurrentProcId()); |
| 309 | 309 |
| 310 OpenSession(); | 310 OpenSession(); |
| 311 } | 311 } |
| 312 | 312 |
| 313 virtual void TearDown() OVERRIDE { | 313 virtual void TearDown() override { |
| 314 // Verifies and removes the expectations on host_ and | 314 // Verifies and removes the expectations on host_ and |
| 315 // returns true iff successful. | 315 // returns true iff successful. |
| 316 Mock::VerifyAndClearExpectations(host_.get()); | 316 Mock::VerifyAndClearExpectations(host_.get()); |
| 317 EXPECT_EQ(0u, host_->entries_.size()); | 317 EXPECT_EQ(0u, host_->entries_.size()); |
| 318 | 318 |
| 319 CloseSession(); | 319 CloseSession(); |
| 320 | 320 |
| 321 // Simulate closing the IPC sender. | 321 // Simulate closing the IPC sender. |
| 322 host_->OnChannelClosing(); | 322 host_->OnChannelClosing(); |
| 323 | 323 |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 #ifdef DUMP_VIDEO | 550 #ifdef DUMP_VIDEO |
| 551 TEST_F(VideoCaptureHostTest, CaptureAndDumpVideoVga) { | 551 TEST_F(VideoCaptureHostTest, CaptureAndDumpVideoVga) { |
| 552 CaptureAndDumpVideo(640, 480, 30); | 552 CaptureAndDumpVideo(640, 480, 30); |
| 553 } | 553 } |
| 554 TEST_F(VideoCaptureHostTest, CaptureAndDump720P) { | 554 TEST_F(VideoCaptureHostTest, CaptureAndDump720P) { |
| 555 CaptureAndDumpVideo(1280, 720, 30); | 555 CaptureAndDumpVideo(1280, 720, 30); |
| 556 } | 556 } |
| 557 #endif | 557 #endif |
| 558 | 558 |
| 559 } // namespace content | 559 } // namespace content |
| OLD | NEW |