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

Side by Side Diff: content/browser/renderer_host/media/media_stream_dispatcher_host_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 #include <string> 5 #include <string>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "content/browser/mock_resource_context.h" 9 #include "content/browser/mock_resource_context.h"
10 #include "content/browser/renderer_host/media/media_stream_dispatcher_host.h" 10 #include "content/browser/renderer_host/media/media_stream_dispatcher_host.h"
11 #include "content/browser/renderer_host/media/media_stream_manager.h" 11 #include "content/browser/renderer_host/media/media_stream_manager.h"
12 #include "content/browser/renderer_host/media/video_capture_manager.h" 12 #include "content/browser/renderer_host/media/video_capture_manager.h"
13 #include "content/browser/resource_context.h" 13 #include "content/browser/resource_context.h"
14 #include "content/common/media/media_stream_messages.h" 14 #include "content/common/media/media_stream_messages.h"
15 #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"
16 #include "ipc/ipc_message_macros.h" 17 #include "ipc/ipc_message_macros.h"
17 #include "testing/gmock/include/gmock/gmock.h" 18 #include "testing/gmock/include/gmock/gmock.h"
18 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
19 20
20 using ::testing::_; 21 using ::testing::_;
21 using ::testing::DeleteArg; 22 using ::testing::DeleteArg;
22 using ::testing::DoAll; 23 using ::testing::DoAll;
23 using ::testing::Return; 24 using ::testing::Return;
24 25
25 const int kProcessId = 5; 26 const int kProcessId = 5;
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 class MediaStreamDispatcherHostTest : public testing::Test { 135 class MediaStreamDispatcherHostTest : public testing::Test {
135 public: 136 public:
136 void WaitForResult() { 137 void WaitForResult() {
137 message_loop_->Run(); 138 message_loop_->Run();
138 } 139 }
139 140
140 protected: 141 protected:
141 virtual void SetUp() { 142 virtual void SetUp() {
142 message_loop_.reset(new MessageLoop(MessageLoop::TYPE_IO)); 143 message_loop_.reset(new MessageLoop(MessageLoop::TYPE_IO));
143 // ResourceContext must be created on UI thread. 144 // ResourceContext must be created on UI thread.
144 ui_thread_.reset(new BrowserThread(BrowserThread::UI, message_loop_.get())); 145 ui_thread_.reset(new content::TestBrowserThread(BrowserThread::UI,
146 message_loop_.get()));
145 // MediaStreamManager must be created and called on IO thread. 147 // MediaStreamManager must be created and called on IO thread.
146 io_thread_.reset(new BrowserThread(BrowserThread::IO, message_loop_.get())); 148 io_thread_.reset(new content::TestBrowserThread(BrowserThread::IO,
149 message_loop_.get()));
147 150
148 // Create a MediaStreamManager instance and hand over pointer to 151 // Create a MediaStreamManager instance and hand over pointer to
149 // ResourceContext. 152 // ResourceContext.
150 media_stream_manager_.reset(new MediaStreamManager()); 153 media_stream_manager_.reset(new MediaStreamManager());
151 // Make sure we use fake devices to avoid long delays. 154 // Make sure we use fake devices to avoid long delays.
152 media_stream_manager_->UseFakeDevice(); 155 media_stream_manager_->UseFakeDevice();
153 content::MockResourceContext::GetInstance()->set_media_stream_manager( 156 content::MockResourceContext::GetInstance()->set_media_stream_manager(
154 media_stream_manager_.get()); 157 media_stream_manager_.get());
155 158
156 host_ = new MockMediaStreamDispatcherHost( 159 host_ = new MockMediaStreamDispatcherHost(
(...skipping 29 matching lines...) Expand all
186 void SyncWithVideoCaptureManagerThread() { 189 void SyncWithVideoCaptureManagerThread() {
187 message_loop_->PostTask( 190 message_loop_->PostTask(
188 FROM_HERE, 191 FROM_HERE,
189 base::Bind(&PostQuitOnVideoCaptureManagerThread, 192 base::Bind(&PostQuitOnVideoCaptureManagerThread,
190 message_loop_.get(), media_stream_manager_.get())); 193 message_loop_.get(), media_stream_manager_.get()));
191 message_loop_->Run(); 194 message_loop_->Run();
192 } 195 }
193 196
194 scoped_refptr<MockMediaStreamDispatcherHost> host_; 197 scoped_refptr<MockMediaStreamDispatcherHost> host_;
195 scoped_ptr<MessageLoop> message_loop_; 198 scoped_ptr<MessageLoop> message_loop_;
196 scoped_ptr<BrowserThread> ui_thread_; 199 scoped_ptr<content::TestBrowserThread> ui_thread_;
197 scoped_ptr<BrowserThread> io_thread_; 200 scoped_ptr<content::TestBrowserThread> io_thread_;
198 scoped_ptr<MediaStreamManager> media_stream_manager_; 201 scoped_ptr<MediaStreamManager> media_stream_manager_;
199 }; 202 };
200 203
201 TEST_F(MediaStreamDispatcherHostTest, GenerateStream) { 204 TEST_F(MediaStreamDispatcherHostTest, GenerateStream) {
202 StreamOptions options(false, StreamOptions::kFacingUser); 205 StreamOptions options(false, StreamOptions::kFacingUser);
203 206
204 EXPECT_CALL(*host_, OnStreamGenerated(kRenderId, kPageRequestId, 0, 1)); 207 EXPECT_CALL(*host_, OnStreamGenerated(kRenderId, kPageRequestId, 0, 1));
205 host_->OnGenerateStream(kPageRequestId, options); 208 host_->OnGenerateStream(kPageRequestId, options);
206 209
207 WaitForResult(); 210 WaitForResult();
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 EXPECT_EQ(host_->video_devices_.size(), 0u); 273 EXPECT_EQ(host_->video_devices_.size(), 0u);
271 EXPECT_EQ(host_->NumberOfStreams(), 1u); 274 EXPECT_EQ(host_->NumberOfStreams(), 1u);
272 275
273 // TODO(perkj): test audio device failure? 276 // TODO(perkj): test audio device failure?
274 277
275 host_->OnStopGeneratedStream(label); 278 host_->OnStopGeneratedStream(label);
276 EXPECT_EQ(host_->NumberOfStreams(), 0u); 279 EXPECT_EQ(host_->NumberOfStreams(), 0u);
277 } 280 }
278 281
279 }; // namespace media_stream 282 }; // namespace media_stream
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698