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

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

Issue 8340028: Salient parts of http://codereview.chromium.org/8392042/ (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: 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
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 // Unit test for VideoCaptureManager 5 // Unit test for VideoCaptureManager
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.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 "content/browser/browser_thread.h"
14 #include "content/browser/renderer_host/media/media_stream_provider.h" 13 #include "content/browser/renderer_host/media/media_stream_provider.h"
15 #include "content/browser/renderer_host/media/video_capture_manager.h" 14 #include "content/browser/renderer_host/media/video_capture_manager.h"
16 #include "content/common/media/media_stream_options.h" 15 #include "content/common/media/media_stream_options.h"
16 #include "content/test/test_browser_thread.h"
17 #include "media/video/capture/video_capture_device.h" 17 #include "media/video/capture/video_capture_device.h"
18 #include "testing/gmock/include/gmock/gmock.h" 18 #include "testing/gmock/include/gmock/gmock.h"
19 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
20 20
21 using ::testing::_; 21 using ::testing::_;
22 using ::testing::AnyNumber; 22 using ::testing::AnyNumber;
23 using ::testing::InSequence; 23 using ::testing::InSequence;
24 using ::testing::Return; 24 using ::testing::Return;
25 25
26 namespace media_stream { 26 namespace media_stream {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 message_loop_(), 75 message_loop_(),
76 io_thread_(), 76 io_thread_(),
77 frame_observer_() { 77 frame_observer_() {
78 } 78 }
79 virtual ~VideoCaptureManagerTest() {} 79 virtual ~VideoCaptureManagerTest() {}
80 80
81 protected: 81 protected:
82 virtual void SetUp() { 82 virtual void SetUp() {
83 listener_.reset(new media_stream::MockMediaStreamProviderListener()); 83 listener_.reset(new media_stream::MockMediaStreamProviderListener());
84 message_loop_.reset(new MessageLoop(MessageLoop::TYPE_IO)); 84 message_loop_.reset(new MessageLoop(MessageLoop::TYPE_IO));
85 io_thread_.reset(new BrowserThread(BrowserThread::IO, message_loop_.get())); 85 io_thread_.reset(new content::TestBrowserThread(BrowserThread::IO,
86 message_loop_.get()));
86 vcm_.reset(new media_stream::VideoCaptureManager()); 87 vcm_.reset(new media_stream::VideoCaptureManager());
87 vcm_->UseFakeDevice(); 88 vcm_->UseFakeDevice();
88 vcm_->Register(listener_.get()); 89 vcm_->Register(listener_.get());
89 frame_observer_.reset(new MockFrameObserver()); 90 frame_observer_.reset(new MockFrameObserver());
90 } 91 }
91 92
92 virtual void TearDown() { 93 virtual void TearDown() {
93 io_thread_.reset(); 94 io_thread_.reset();
94 } 95 }
95 96
(...skipping 17 matching lines...) Expand all
113 void SyncWithVideoCaptureManagerThread() { 114 void SyncWithVideoCaptureManagerThread() {
114 message_loop_->PostTask( 115 message_loop_->PostTask(
115 FROM_HERE, base::Bind(&PostQuitOnVideoCaptureManagerThread, 116 FROM_HERE, base::Bind(&PostQuitOnVideoCaptureManagerThread,
116 message_loop_.get(), 117 message_loop_.get(),
117 vcm_.get())); 118 vcm_.get()));
118 message_loop_->Run(); 119 message_loop_->Run();
119 } 120 }
120 scoped_ptr<media_stream::VideoCaptureManager> vcm_; 121 scoped_ptr<media_stream::VideoCaptureManager> vcm_;
121 scoped_ptr<media_stream::MockMediaStreamProviderListener> listener_; 122 scoped_ptr<media_stream::MockMediaStreamProviderListener> listener_;
122 scoped_ptr<MessageLoop> message_loop_; 123 scoped_ptr<MessageLoop> message_loop_;
123 scoped_ptr<BrowserThread> io_thread_; 124 scoped_ptr<content::TestBrowserThread> io_thread_;
124 scoped_ptr<MockFrameObserver> frame_observer_; 125 scoped_ptr<MockFrameObserver> frame_observer_;
125 126
126 private: 127 private:
127 DISALLOW_COPY_AND_ASSIGN(VideoCaptureManagerTest); 128 DISALLOW_COPY_AND_ASSIGN(VideoCaptureManagerTest);
128 }; 129 };
129 130
130 // Test cases 131 // Test cases
131 132
132 // Try to open, start, stop and close a device. 133 // Try to open, start, stop and close a device.
133 TEST_F(VideoCaptureManagerTest, CreateAndClose) { 134 TEST_F(VideoCaptureManagerTest, CreateAndClose) {
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 vcm_->Open(*it); 299 vcm_->Open(*it);
299 300
300 // Wait to check callbacks before removing the listener 301 // Wait to check callbacks before removing the listener
301 SyncWithVideoCaptureManagerThread(); 302 SyncWithVideoCaptureManagerThread();
302 303
303 // Delete the manager. 304 // Delete the manager.
304 vcm_.reset(); 305 vcm_.reset();
305 } 306 }
306 307
307 } // namespace 308 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698