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

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

Issue 2435393003: Rename VideoCaptureHostTest to VideoCaptureTest to reflect what it is (Closed)
Patch Set: Created 4 years, 2 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
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 "content/browser/renderer_host/media/video_capture_host.h"
6
7 #include <stdint.h> 5 #include <stdint.h>
8 6
9 #include <map> 7 #include <map>
10 #include <memory> 8 #include <memory>
11 #include <string> 9 #include <string>
12 10
13 #include "base/bind.h" 11 #include "base/bind.h"
14 #include "base/command_line.h" 12 #include "base/command_line.h"
15 #include "base/location.h" 13 #include "base/location.h"
16 #include "base/macros.h" 14 #include "base/macros.h"
17 #include "base/memory/ptr_util.h" 15 #include "base/memory/ptr_util.h"
18 #include "base/run_loop.h" 16 #include "base/run_loop.h"
19 #include "base/single_thread_task_runner.h" 17 #include "base/single_thread_task_runner.h"
20 #include "base/threading/thread_task_runner_handle.h" 18 #include "base/threading/thread_task_runner_handle.h"
21 #include "build/build_config.h" 19 #include "build/build_config.h"
22 #include "content/browser/browser_thread_impl.h" 20 #include "content/browser/browser_thread_impl.h"
23 #include "content/browser/renderer_host/media/media_stream_manager.h" 21 #include "content/browser/renderer_host/media/media_stream_manager.h"
24 #include "content/browser/renderer_host/media/media_stream_requester.h" 22 #include "content/browser/renderer_host/media/media_stream_requester.h"
23 #include "content/browser/renderer_host/media/video_capture_host.h"
25 #include "content/browser/renderer_host/media/video_capture_manager.h" 24 #include "content/browser/renderer_host/media/video_capture_manager.h"
26 #include "content/public/common/content_switches.h" 25 #include "content/public/common/content_switches.h"
27 #include "content/public/test/mock_resource_context.h" 26 #include "content/public/test/mock_resource_context.h"
28 #include "content/public/test/test_browser_context.h" 27 #include "content/public/test/test_browser_context.h"
29 #include "content/public/test/test_browser_thread_bundle.h" 28 #include "content/public/test/test_browser_thread_bundle.h"
30 #include "content/test/test_content_browser_client.h" 29 #include "content/test/test_content_browser_client.h"
31 #include "media/audio/mock_audio_manager.h" 30 #include "media/audio/mock_audio_manager.h"
32 #include "media/base/media_switches.h" 31 #include "media/base/media_switches.h"
33 #include "media/base/video_capture_types.h" 32 #include "media/base/video_capture_types.h"
34 #include "mojo/public/cpp/bindings/binding.h" 33 #include "mojo/public/cpp/bindings/binding.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 DISALLOW_COPY_AND_ASSIGN(MockMediaStreamRequester); 83 DISALLOW_COPY_AND_ASSIGN(MockMediaStreamRequester);
85 }; 84 };
86 85
87 ACTION_P2(ExitMessageLoop, task_runner, quit_closure) { 86 ACTION_P2(ExitMessageLoop, task_runner, quit_closure) {
88 task_runner->PostTask(FROM_HERE, quit_closure); 87 task_runner->PostTask(FROM_HERE, quit_closure);
89 } 88 }
90 89
91 // This is an integration test of VideoCaptureHost in conjunction with 90 // This is an integration test of VideoCaptureHost in conjunction with
92 // MediaStreamManager, VideoCaptureManager, VideoCaptureController, and 91 // MediaStreamManager, VideoCaptureManager, VideoCaptureController, and
93 // VideoCaptureDevice. 92 // VideoCaptureDevice.
94 class VideoCaptureHostTest : public testing::Test, 93 class VideoCaptureTest : public testing::Test,
95 public mojom::VideoCaptureObserver { 94 public mojom::VideoCaptureObserver {
96 public: 95 public:
97 VideoCaptureHostTest() 96 VideoCaptureTest()
98 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), 97 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP),
99 audio_manager_( 98 audio_manager_(
100 new media::MockAudioManager(base::ThreadTaskRunnerHandle::Get())), 99 new media::MockAudioManager(base::ThreadTaskRunnerHandle::Get())),
101 task_runner_(base::ThreadTaskRunnerHandle::Get()), 100 task_runner_(base::ThreadTaskRunnerHandle::Get()),
102 opened_session_id_(kInvalidMediaCaptureSessionId), 101 opened_session_id_(kInvalidMediaCaptureSessionId),
103 observer_binding_(this) {} 102 observer_binding_(this) {}
104 103
105 void SetUp() override { 104 void SetUp() override {
106 SetBrowserClientForTesting(&browser_client_); 105 SetBrowserClientForTesting(&browser_client_);
107 106
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 media::ScopedAudioManagerPtr audio_manager_; 303 media::ScopedAudioManagerPtr audio_manager_;
305 content::TestBrowserContext browser_context_; 304 content::TestBrowserContext browser_context_;
306 content::TestContentBrowserClient browser_client_; 305 content::TestContentBrowserClient browser_client_;
307 const scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 306 const scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
308 int opened_session_id_; 307 int opened_session_id_;
309 std::string opened_device_label_; 308 std::string opened_device_label_;
310 309
311 std::unique_ptr<VideoCaptureHost> host_; 310 std::unique_ptr<VideoCaptureHost> host_;
312 mojo::Binding<mojom::VideoCaptureObserver> observer_binding_; 311 mojo::Binding<mojom::VideoCaptureObserver> observer_binding_;
313 312
314 DISALLOW_COPY_AND_ASSIGN(VideoCaptureHostTest); 313 DISALLOW_COPY_AND_ASSIGN(VideoCaptureTest);
315 }; 314 };
316 315
317 // Construct and destruct all objects. This is a non trivial sequence. 316 // Construct and destruct all objects. This is a non trivial sequence.
318 TEST_F(VideoCaptureHostTest, ConstructAndDestruct) {} 317 TEST_F(VideoCaptureTest, ConstructAndDestruct) {}
319 318
320 TEST_F(VideoCaptureHostTest, StartAndImmediateStop) { 319 TEST_F(VideoCaptureTest, StartAndImmediateStop) {
321 StartAndImmediateStopCapture(); 320 StartAndImmediateStopCapture();
322 } 321 }
323 322
324 TEST_F(VideoCaptureHostTest, StartAndCaptureAndStop) { 323 TEST_F(VideoCaptureTest, StartAndCaptureAndStop) {
325 StartCapture(); 324 StartCapture();
326 WaitForOneCapturedBuffer(); 325 WaitForOneCapturedBuffer();
327 WaitForOneCapturedBuffer(); 326 WaitForOneCapturedBuffer();
328 StopCapture(); 327 StopCapture();
329 } 328 }
330 329
331 TEST_F(VideoCaptureHostTest, StartAndErrorAndStop) { 330 TEST_F(VideoCaptureTest, StartAndErrorAndStop) {
332 StartCapture(); 331 StartCapture();
333 SimulateError(); 332 SimulateError();
334 StopCapture(); 333 StopCapture();
335 } 334 }
336 335
337 TEST_F(VideoCaptureHostTest, StartAndCaptureAndError) { 336 TEST_F(VideoCaptureTest, StartAndCaptureAndError) {
338 EXPECT_CALL(*this, OnStateChanged(mojom::VideoCaptureState::STOPPED)) 337 EXPECT_CALL(*this, OnStateChanged(mojom::VideoCaptureState::STOPPED))
339 .Times(0); 338 .Times(0);
340 StartCapture(); 339 StartCapture();
341 WaitForOneCapturedBuffer(); 340 WaitForOneCapturedBuffer();
342 SimulateError(); 341 SimulateError();
343 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(200)); 342 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(200));
344 } 343 }
345 344
346 TEST_F(VideoCaptureHostTest, StartAndPauseAndResumeAndStop) { 345 TEST_F(VideoCaptureTest, StartAndPauseAndResumeAndStop) {
347 StartCapture(); 346 StartCapture();
348 PauseResumeCapture(); 347 PauseResumeCapture();
349 StopCapture(); 348 StopCapture();
350 } 349 }
351 350
352 TEST_F(VideoCaptureHostTest, CloseSessionWithoutStopping) { 351 TEST_F(VideoCaptureTest, CloseSessionWithoutStopping) {
353 StartCapture(); 352 StartCapture();
354 353
355 // When the session is closed via the stream without stopping capture, the 354 // When the session is closed via the stream without stopping capture, the
356 // ENDED event is sent. 355 // ENDED event is sent.
357 EXPECT_CALL(*this, OnStateChanged(mojom::VideoCaptureState::ENDED)); 356 EXPECT_CALL(*this, OnStateChanged(mojom::VideoCaptureState::ENDED));
358 CloseSession(); 357 CloseSession();
359 base::RunLoop().RunUntilIdle(); 358 base::RunLoop().RunUntilIdle();
360 } 359 }
361 360
362 } // namespace content 361 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/media/video_capture_host_unittest.cc ('k') | content/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698