Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(100)

Side by Side Diff: content/browser/renderer_host/media/video_capture_host_unittest.cc

Issue 8400060: Switch content tests to use BrowserThreadImpl directly. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to lkgr Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_impl.h"
15 #include "content/browser/mock_resource_context.h" 16 #include "content/browser/mock_resource_context.h"
16 #include "content/browser/renderer_host/media/media_stream_manager.h" 17 #include "content/browser/renderer_host/media/media_stream_manager.h"
17 #include "content/browser/renderer_host/media/video_capture_host.h" 18 #include "content/browser/renderer_host/media/video_capture_host.h"
18 #include "content/browser/renderer_host/media/video_capture_manager.h" 19 #include "content/browser/renderer_host/media/video_capture_manager.h"
19 #include "content/browser/resource_context.h" 20 #include "content/browser/resource_context.h"
20 #include "content/common/media/video_capture_messages.h" 21 #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;
32 using ::testing::Mock; 32 using ::testing::Mock;
33 using ::testing::Return; 33 using ::testing::Return;
34 34
35 using content::BrowserThreadImpl;
36
35 // Id used to identify the capture session between renderer and 37 // Id used to identify the capture session between renderer and
36 // video_capture_host. 38 // video_capture_host.
37 static const int kDeviceId = 1; 39 static const int kDeviceId = 1;
38 // Id of a video capture device 40 // Id of a video capture device
39 static const media::VideoCaptureSessionId kTestFakeDeviceId = 41 static const media::VideoCaptureSessionId kTestFakeDeviceId =
40 media_stream::VideoCaptureManager::kStartOpenSessionId; 42 media_stream::VideoCaptureManager::kStartOpenSessionId;
41 43
42 // Define to enable test where video is dumped to file. 44 // Define to enable test where video is dumped to file.
43 // #define DUMP_VIDEO 45 // #define DUMP_VIDEO
44 46
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 class VideoCaptureHostTest : public testing::Test { 190 class VideoCaptureHostTest : public testing::Test {
189 public: 191 public:
190 VideoCaptureHostTest() {} 192 VideoCaptureHostTest() {}
191 193
192 protected: 194 protected:
193 virtual void SetUp() { 195 virtual void SetUp() {
194 // Create a message loop so VideoCaptureHostTest can use it. 196 // Create a message loop so VideoCaptureHostTest can use it.
195 message_loop_.reset(new MessageLoop(MessageLoop::TYPE_IO)); 197 message_loop_.reset(new MessageLoop(MessageLoop::TYPE_IO));
196 198
197 // ResourceContext must be created on the UI thread. 199 // ResourceContext must be created on the UI thread.
198 ui_thread_.reset(new content::TestBrowserThread(BrowserThread::UI, 200 ui_thread_.reset(new BrowserThreadImpl(BrowserThread::UI,
199 message_loop_.get())); 201 message_loop_.get()));
200 202
201 // MediaStreamManager must be created on the IO thread. 203 // MediaStreamManager must be created on the IO thread.
202 io_thread_.reset(new content::TestBrowserThread(BrowserThread::IO, 204 io_thread_.reset(new BrowserThreadImpl(BrowserThread::IO,
203 message_loop_.get())); 205 message_loop_.get()));
204 206
205 // Create a MediaStreamManager instance and hand over pointer to 207 // Create a MediaStreamManager instance and hand over pointer to
206 // ResourceContext. 208 // ResourceContext.
207 media_stream_manager_.reset(new media_stream::MediaStreamManager()); 209 media_stream_manager_.reset(new media_stream::MediaStreamManager());
208 210
209 #ifndef TEST_REAL_CAPTURE_DEVICE 211 #ifndef TEST_REAL_CAPTURE_DEVICE
210 media_stream_manager_->UseFakeDevice(); 212 media_stream_manager_->UseFakeDevice();
211 #endif 213 #endif
212 214
213 content::MockResourceContext::GetInstance()->set_media_stream_manager( 215 content::MockResourceContext::GetInstance()->set_media_stream_manager(
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 .Times(1); 357 .Times(1);
356 VideoCaptureControllerID id(kDeviceId); 358 VideoCaptureControllerID id(kDeviceId);
357 host_->OnError(id); 359 host_->OnError(id);
358 SyncWithVideoCaptureManagerThread(); 360 SyncWithVideoCaptureManagerThread();
359 } 361 }
360 362
361 scoped_refptr<MockVideoCaptureHost> host_; 363 scoped_refptr<MockVideoCaptureHost> host_;
362 364
363 private: 365 private:
364 scoped_ptr<MessageLoop> message_loop_; 366 scoped_ptr<MessageLoop> message_loop_;
365 scoped_ptr<content::TestBrowserThread> ui_thread_; 367 scoped_ptr<BrowserThreadImpl> ui_thread_;
366 scoped_ptr<content::TestBrowserThread> io_thread_; 368 scoped_ptr<BrowserThreadImpl> io_thread_;
367 scoped_ptr<media_stream::MediaStreamManager> media_stream_manager_; 369 scoped_ptr<media_stream::MediaStreamManager> media_stream_manager_;
368 370
369 DISALLOW_COPY_AND_ASSIGN(VideoCaptureHostTest); 371 DISALLOW_COPY_AND_ASSIGN(VideoCaptureHostTest);
370 }; 372 };
371 373
372 TEST_F(VideoCaptureHostTest, StartCapture) { 374 TEST_F(VideoCaptureHostTest, StartCapture) {
373 StartCapture(); 375 StartCapture();
374 } 376 }
375 377
376 TEST_F(VideoCaptureHostTest, StartCapturePlayStop) { 378 TEST_F(VideoCaptureHostTest, StartCapturePlayStop) {
(...skipping 21 matching lines...) Expand all
398 } 400 }
399 401
400 #ifdef DUMP_VIDEO 402 #ifdef DUMP_VIDEO
401 TEST_F(VideoCaptureHostTest, CaptureAndDumpVideoVga) { 403 TEST_F(VideoCaptureHostTest, CaptureAndDumpVideoVga) {
402 CaptureAndDumpVideo(640, 480, 30); 404 CaptureAndDumpVideo(640, 480, 30);
403 } 405 }
404 TEST_F(VideoCaptureHostTest, CaptureAndDump720P) { 406 TEST_F(VideoCaptureHostTest, CaptureAndDump720P) {
405 CaptureAndDumpVideo(1280, 720, 30); 407 CaptureAndDumpVideo(1280, 720, 30);
406 } 408 }
407 #endif 409 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698