| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
| 12 #include "base/process_util.h" | 12 #include "base/process_util.h" |
| 13 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
| 14 #include "base/stringprintf.h" | 14 #include "base/stringprintf.h" |
| 15 #include "content/browser/browser_thread.h" | |
| 16 #include "content/browser/mock_resource_context.h" | 15 #include "content/browser/mock_resource_context.h" |
| 17 #include "content/browser/renderer_host/media/media_stream_manager.h" | 16 #include "content/browser/renderer_host/media/media_stream_manager.h" |
| 18 #include "content/browser/renderer_host/media/video_capture_host.h" | 17 #include "content/browser/renderer_host/media/video_capture_host.h" |
| 19 #include "content/browser/renderer_host/media/video_capture_manager.h" | 18 #include "content/browser/renderer_host/media/video_capture_manager.h" |
| 20 #include "content/browser/resource_context.h" | 19 #include "content/browser/resource_context.h" |
| 21 #include "content/common/media/video_capture_messages.h" | 20 #include "content/common/media/video_capture_messages.h" |
| 21 #include "content/test/test_browser_thread.h" |
| 22 #include "media/video/capture/video_capture_types.h" | 22 #include "media/video/capture/video_capture_types.h" |
| 23 | 23 |
| 24 #include "testing/gmock/include/gmock/gmock.h" | 24 #include "testing/gmock/include/gmock/gmock.h" |
| 25 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
| 26 | 26 |
| 27 using ::testing::_; | 27 using ::testing::_; |
| 28 using ::testing::AtLeast; | 28 using ::testing::AtLeast; |
| 29 using ::testing::AnyNumber; | 29 using ::testing::AnyNumber; |
| 30 using ::testing::DoAll; | 30 using ::testing::DoAll; |
| 31 using ::testing::InSequence; | 31 using ::testing::InSequence; |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 class VideoCaptureHostTest : public testing::Test { | 188 class VideoCaptureHostTest : public testing::Test { |
| 189 public: | 189 public: |
| 190 VideoCaptureHostTest() {} | 190 VideoCaptureHostTest() {} |
| 191 | 191 |
| 192 protected: | 192 protected: |
| 193 virtual void SetUp() { | 193 virtual void SetUp() { |
| 194 // Create a message loop so VideoCaptureHostTest can use it. | 194 // Create a message loop so VideoCaptureHostTest can use it. |
| 195 message_loop_.reset(new MessageLoop(MessageLoop::TYPE_IO)); | 195 message_loop_.reset(new MessageLoop(MessageLoop::TYPE_IO)); |
| 196 | 196 |
| 197 // ResourceContext must be created on the UI thread. | 197 // ResourceContext must be created on the UI thread. |
| 198 ui_thread_.reset(new BrowserThread(BrowserThread::UI, message_loop_.get())); | 198 ui_thread_.reset(new content::TestBrowserThread(BrowserThread::UI, |
| 199 message_loop_.get())); |
| 199 | 200 |
| 200 // MediaStreamManager must be created on the IO thread. | 201 // MediaStreamManager must be created on the IO thread. |
| 201 io_thread_.reset(new BrowserThread(BrowserThread::IO, message_loop_.get())); | 202 io_thread_.reset(new content::TestBrowserThread(BrowserThread::IO, |
| 203 message_loop_.get())); |
| 202 | 204 |
| 203 // Create a MediaStreamManager instance and hand over pointer to | 205 // Create a MediaStreamManager instance and hand over pointer to |
| 204 // ResourceContext. | 206 // ResourceContext. |
| 205 media_stream_manager_.reset(new media_stream::MediaStreamManager()); | 207 media_stream_manager_.reset(new media_stream::MediaStreamManager()); |
| 206 | 208 |
| 207 #ifndef TEST_REAL_CAPTURE_DEVICE | 209 #ifndef TEST_REAL_CAPTURE_DEVICE |
| 208 media_stream_manager_->UseFakeDevice(); | 210 media_stream_manager_->UseFakeDevice(); |
| 209 #endif | 211 #endif |
| 210 | 212 |
| 211 content::MockResourceContext::GetInstance()->set_media_stream_manager( | 213 content::MockResourceContext::GetInstance()->set_media_stream_manager( |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 .Times(1); | 355 .Times(1); |
| 354 VideoCaptureControllerID id(kDeviceId); | 356 VideoCaptureControllerID id(kDeviceId); |
| 355 host_->OnError(id); | 357 host_->OnError(id); |
| 356 SyncWithVideoCaptureManagerThread(); | 358 SyncWithVideoCaptureManagerThread(); |
| 357 } | 359 } |
| 358 | 360 |
| 359 scoped_refptr<MockVideoCaptureHost> host_; | 361 scoped_refptr<MockVideoCaptureHost> host_; |
| 360 | 362 |
| 361 private: | 363 private: |
| 362 scoped_ptr<MessageLoop> message_loop_; | 364 scoped_ptr<MessageLoop> message_loop_; |
| 363 scoped_ptr<BrowserThread> ui_thread_; | 365 scoped_ptr<content::TestBrowserThread> ui_thread_; |
| 364 scoped_ptr<BrowserThread> io_thread_; | 366 scoped_ptr<content::TestBrowserThread> io_thread_; |
| 365 scoped_ptr<media_stream::MediaStreamManager> media_stream_manager_; | 367 scoped_ptr<media_stream::MediaStreamManager> media_stream_manager_; |
| 366 | 368 |
| 367 DISALLOW_COPY_AND_ASSIGN(VideoCaptureHostTest); | 369 DISALLOW_COPY_AND_ASSIGN(VideoCaptureHostTest); |
| 368 }; | 370 }; |
| 369 | 371 |
| 370 TEST_F(VideoCaptureHostTest, StartCapture) { | 372 TEST_F(VideoCaptureHostTest, StartCapture) { |
| 371 StartCapture(); | 373 StartCapture(); |
| 372 } | 374 } |
| 373 | 375 |
| 374 TEST_F(VideoCaptureHostTest, StartCapturePlayStop) { | 376 TEST_F(VideoCaptureHostTest, StartCapturePlayStop) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 396 } | 398 } |
| 397 | 399 |
| 398 #ifdef DUMP_VIDEO | 400 #ifdef DUMP_VIDEO |
| 399 TEST_F(VideoCaptureHostTest, CaptureAndDumpVideoVga) { | 401 TEST_F(VideoCaptureHostTest, CaptureAndDumpVideoVga) { |
| 400 CaptureAndDumpVideo(640, 480, 30); | 402 CaptureAndDumpVideo(640, 480, 30); |
| 401 } | 403 } |
| 402 TEST_F(VideoCaptureHostTest, CaptureAndDump720P) { | 404 TEST_F(VideoCaptureHostTest, CaptureAndDump720P) { |
| 403 CaptureAndDumpVideo(1280, 720, 30); | 405 CaptureAndDumpVideo(1280, 720, 30); |
| 404 } | 406 } |
| 405 #endif | 407 #endif |
| OLD | NEW |