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

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

Issue 9805001: Move media/audio files into media namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 months 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) 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/file_util.h" 9 #include "base/file_util.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 } 65 }
66 66
67 private: 67 private:
68 file_util::ScopedFILE file_; 68 file_util::ScopedFILE file_;
69 int expected_size_; 69 int expected_size_;
70 }; 70 };
71 71
72 class MockVideoCaptureHost : public VideoCaptureHost { 72 class MockVideoCaptureHost : public VideoCaptureHost {
73 public: 73 public:
74 MockVideoCaptureHost(content::ResourceContext* resource_context, 74 MockVideoCaptureHost(content::ResourceContext* resource_context,
75 AudioManager* audio_manager) 75 media::AudioManager* audio_manager)
76 : VideoCaptureHost(resource_context, audio_manager), 76 : VideoCaptureHost(resource_context, audio_manager),
77 return_buffers_(false), 77 return_buffers_(false),
78 dump_video_(false) {} 78 dump_video_(false) {}
79 virtual ~MockVideoCaptureHost() { 79 virtual ~MockVideoCaptureHost() {
80 STLDeleteContainerPairSecondPointers(filled_dib_.begin(), 80 STLDeleteContainerPairSecondPointers(filled_dib_.begin(),
81 filled_dib_.end()); 81 filled_dib_.end());
82 } 82 }
83 83
84 // A list of mock methods. 84 // A list of mock methods.
85 MOCK_METHOD4(OnNewBufferCreated, 85 MOCK_METHOD4(OnNewBufferCreated,
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 message_loop_.reset(new MessageLoop(MessageLoop::TYPE_IO)); 198 message_loop_.reset(new MessageLoop(MessageLoop::TYPE_IO));
199 199
200 // ResourceContext must be created on the UI thread. 200 // ResourceContext must be created on the UI thread.
201 ui_thread_.reset(new BrowserThreadImpl(BrowserThread::UI, 201 ui_thread_.reset(new BrowserThreadImpl(BrowserThread::UI,
202 message_loop_.get())); 202 message_loop_.get()));
203 203
204 // MediaStreamManager must be created on the IO thread. 204 // MediaStreamManager must be created on the IO thread.
205 io_thread_.reset(new BrowserThreadImpl(BrowserThread::IO, 205 io_thread_.reset(new BrowserThreadImpl(BrowserThread::IO,
206 message_loop_.get())); 206 message_loop_.get()));
207 207
208 audio_manager_.reset(AudioManager::Create()); 208 audio_manager_.reset(media::AudioManager::Create());
209 209
210 #ifndef TEST_REAL_CAPTURE_DEVICE 210 #ifndef TEST_REAL_CAPTURE_DEVICE
211 media_stream::MediaStreamManager::GetForResourceContext( 211 media_stream::MediaStreamManager::GetForResourceContext(
212 &resource_context_, audio_manager_.get())->UseFakeDevice(); 212 &resource_context_, audio_manager_.get())->UseFakeDevice();
213 #endif 213 #endif
214 214
215 host_ = new MockVideoCaptureHost(&resource_context_, audio_manager_.get()); 215 host_ = new MockVideoCaptureHost(&resource_context_, audio_manager_.get());
216 216
217 // Simulate IPC channel connected. 217 // Simulate IPC channel connected.
218 host_->OnChannelConnected(base::GetCurrentProcId()); 218 host_->OnChannelConnected(base::GetCurrentProcId());
(...skipping 20 matching lines...) Expand all
239 } 239 }
240 240
241 // Called on the VideoCaptureManager thread. 241 // Called on the VideoCaptureManager thread.
242 static void PostQuitMessageLoop(MessageLoop* message_loop) { 242 static void PostQuitMessageLoop(MessageLoop* message_loop) {
243 message_loop->PostTask(FROM_HERE, MessageLoop::QuitClosure()); 243 message_loop->PostTask(FROM_HERE, MessageLoop::QuitClosure());
244 } 244 }
245 245
246 // Called on the main thread. 246 // Called on the main thread.
247 static void PostQuitOnVideoCaptureManagerThread( 247 static void PostQuitOnVideoCaptureManagerThread(
248 MessageLoop* message_loop, content::ResourceContext* resource_context, 248 MessageLoop* message_loop, content::ResourceContext* resource_context,
249 AudioManager* audio_manager) { 249 media:: AudioManager* audio_manager) {
250 media_stream::MediaStreamManager* manager = 250 media_stream::MediaStreamManager* manager =
251 media_stream::MediaStreamManager::GetForResourceContext( 251 media_stream::MediaStreamManager::GetForResourceContext(
252 resource_context, audio_manager); 252 resource_context, audio_manager);
253 manager->video_capture_manager()->GetMessageLoop()->PostTask( 253 manager->video_capture_manager()->GetMessageLoop()->PostTask(
254 FROM_HERE, base::Bind(&PostQuitMessageLoop, message_loop)); 254 FROM_HERE, base::Bind(&PostQuitMessageLoop, message_loop));
255 } 255 }
256 256
257 // SyncWithVideoCaptureManagerThread() waits until all pending tasks on the 257 // SyncWithVideoCaptureManagerThread() waits until all pending tasks on the
258 // video_capture_manager thread are executed while also processing pending 258 // video_capture_manager thread are executed while also processing pending
259 // task in message_loop_ on the current thread. It is used to synchronize 259 // task in message_loop_ on the current thread. It is used to synchronize
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 host_->OnError(id); 355 host_->OnError(id);
356 SyncWithVideoCaptureManagerThread(); 356 SyncWithVideoCaptureManagerThread();
357 } 357 }
358 358
359 scoped_refptr<MockVideoCaptureHost> host_; 359 scoped_refptr<MockVideoCaptureHost> host_;
360 360
361 private: 361 private:
362 scoped_ptr<MessageLoop> message_loop_; 362 scoped_ptr<MessageLoop> message_loop_;
363 scoped_ptr<BrowserThreadImpl> ui_thread_; 363 scoped_ptr<BrowserThreadImpl> ui_thread_;
364 scoped_ptr<BrowserThreadImpl> io_thread_; 364 scoped_ptr<BrowserThreadImpl> io_thread_;
365 scoped_ptr<AudioManager> audio_manager_; 365 scoped_ptr<media::AudioManager> audio_manager_;
366 content::MockResourceContext resource_context_; 366 content::MockResourceContext resource_context_;
367 367
368 DISALLOW_COPY_AND_ASSIGN(VideoCaptureHostTest); 368 DISALLOW_COPY_AND_ASSIGN(VideoCaptureHostTest);
369 }; 369 };
370 370
371 TEST_F(VideoCaptureHostTest, StartCapture) { 371 TEST_F(VideoCaptureHostTest, StartCapture) {
372 StartCapture(); 372 StartCapture();
373 } 373 }
374 374
375 TEST_F(VideoCaptureHostTest, StartCapturePlayStop) { 375 TEST_F(VideoCaptureHostTest, StartCapturePlayStop) {
(...skipping 21 matching lines...) Expand all
397 } 397 }
398 398
399 #ifdef DUMP_VIDEO 399 #ifdef DUMP_VIDEO
400 TEST_F(VideoCaptureHostTest, CaptureAndDumpVideoVga) { 400 TEST_F(VideoCaptureHostTest, CaptureAndDumpVideoVga) {
401 CaptureAndDumpVideo(640, 480, 30); 401 CaptureAndDumpVideo(640, 480, 30);
402 } 402 }
403 TEST_F(VideoCaptureHostTest, CaptureAndDump720P) { 403 TEST_F(VideoCaptureHostTest, CaptureAndDump720P) {
404 CaptureAndDumpVideo(1280, 720, 30); 404 CaptureAndDumpVideo(1280, 720, 30);
405 } 405 }
406 #endif 406 #endif
OLDNEW
« no previous file with comments | « content/browser/renderer_host/media/video_capture_host.cc ('k') | content/browser/renderer_host/render_message_filter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698