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

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

Issue 2634263002: Pass camera facing info to audio client (Closed)
Patch Set: Pass VideoCaptureObserver as ctor parameter Created 3 years, 11 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/audio_output_delegate.h" 5 #include "content/browser/renderer_host/media/audio_output_delegate.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/memory/ptr_util.h" 14 #include "base/memory/ptr_util.h"
15 #include "base/message_loop/message_loop.h" 15 #include "base/message_loop/message_loop.h"
16 #include "base/run_loop.h" 16 #include "base/run_loop.h"
17 #include "component/arc/video_facing.h"
17 #include "content/browser/audio_manager_thread.h" 18 #include "content/browser/audio_manager_thread.h"
18 #include "content/browser/media/capture/audio_mirroring_manager.h" 19 #include "content/browser/media/capture/audio_mirroring_manager.h"
19 #include "content/browser/renderer_host/media/media_stream_manager.h" 20 #include "content/browser/renderer_host/media/media_stream_manager.h"
20 #include "content/public/browser/browser_thread.h" 21 #include "content/public/browser/browser_thread.h"
21 #include "content/public/browser/media_observer.h" 22 #include "content/public/browser/media_observer.h"
22 #include "content/public/test/test_browser_thread_bundle.h" 23 #include "content/public/test/test_browser_thread_bundle.h"
23 #include "media/audio/fake_audio_log_factory.h" 24 #include "media/audio/fake_audio_log_factory.h"
24 #include "media/audio/fake_audio_manager.h" 25 #include "media/audio/fake_audio_manager.h"
25 #include "media/base/media_switches.h" 26 #include "media/base/media_switches.h"
26 #include "testing/gmock/include/gmock/gmock.h" 27 #include "testing/gmock/include/gmock/gmock.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 public: 90 public:
90 // AudioOutputSteam implementation: 91 // AudioOutputSteam implementation:
91 bool Open() override { return true; } 92 bool Open() override { return true; }
92 void Start(AudioSourceCallback* cb) override {} 93 void Start(AudioSourceCallback* cb) override {}
93 void Stop() override {} 94 void Stop() override {}
94 void SetVolume(double volume) override {} 95 void SetVolume(double volume) override {}
95 void GetVolume(double* volume) override { *volume = 1; } 96 void GetVolume(double* volume) override { *volume = 1; }
96 void Close() override {} 97 void Close() override {}
97 }; 98 };
98 99
100 class MockVideoCaptureObserver : public component::VideoCaptureObserver {
101 public:
102 MOCK_METHOD1(OnVideoCaptureStarted, void(component::VideoFacingMode));
103 MOCK_METHOD1(OnVideoCaptureStopped, void(component::VideoFacingMode));
104 };
105
99 } // namespace 106 } // namespace
100 107
101 class AudioOutputDelegateTest : public testing::Test { 108 class AudioOutputDelegateTest : public testing::Test {
102 public: 109 public:
103 AudioOutputDelegateTest() { 110 AudioOutputDelegateTest() {
104 base::CommandLine::ForCurrentProcess()->AppendSwitch( 111 base::CommandLine::ForCurrentProcess()->AppendSwitch(
105 switches::kUseFakeDeviceForMediaStream); 112 switches::kUseFakeDeviceForMediaStream);
106 113
107 // This test uses real UI, IO and audio threads. 114 // This test uses real UI, IO and audio threads.
108 // AudioOutputDelegate mainly interacts with the IO and audio threads, 115 // AudioOutputDelegate mainly interacts with the IO and audio threads,
109 // but interacts with UI for bad messages, so using these threads should 116 // but interacts with UI for bad messages, so using these threads should
110 // approximate the real conditions of AudioOutputDelegate well. 117 // approximate the real conditions of AudioOutputDelegate well.
111 thread_bundle_ = base::MakeUnique<TestBrowserThreadBundle>( 118 thread_bundle_ = base::MakeUnique<TestBrowserThreadBundle>(
112 TestBrowserThreadBundle::Options::REAL_IO_THREAD); 119 TestBrowserThreadBundle::Options::REAL_IO_THREAD);
113 audio_thread_ = base::MakeUnique<AudioManagerThread>(); 120 audio_thread_ = base::MakeUnique<AudioManagerThread>();
114 121
115 audio_manager_.reset(new media::FakeAudioManager( 122 audio_manager_.reset(new media::FakeAudioManager(
116 audio_thread_->task_runner(), audio_thread_->worker_task_runner(), 123 audio_thread_->task_runner(), audio_thread_->worker_task_runner(),
117 &log_factory_)); 124 &log_factory_));
118 media_stream_manager_ = 125 media_stream_manager_ =
119 base::MakeUnique<MediaStreamManager>(audio_manager_.get()); 126 base::MakeUnique<MediaStreamManager>(audio_manager_.get(), new MockVideo CaptureObserver());
120 } 127 }
121 128
122 // Test bodies are here, so that we can run them on the IO thread. 129 // Test bodies are here, so that we can run them on the IO thread.
123 void CreateTest(base::Closure done) { 130 void CreateTest(base::Closure done) {
124 EXPECT_CALL(media_observer_, 131 EXPECT_CALL(media_observer_,
125 OnCreatingAudioStream(kRenderProcessId, kRenderFrameId)); 132 OnCreatingAudioStream(kRenderProcessId, kRenderFrameId));
126 EXPECT_CALL(event_handler_, 133 EXPECT_CALL(event_handler_,
127 OnStreamCreated(kStreamId, NotNull(), NotNull())); 134 OnStreamCreated(kStreamId, NotNull(), NotNull()));
128 EXPECT_CALL(mirroring_manager_, 135 EXPECT_CALL(mirroring_manager_,
129 AddDiverter(kRenderProcessId, kRenderFrameId, NotNull())); 136 AddDiverter(kRenderProcessId, kRenderFrameId, NotNull()));
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 TEST_F(AudioOutputDelegateTest, ErrorAndDestroy) { 588 TEST_F(AudioOutputDelegateTest, ErrorAndDestroy) {
582 base::RunLoop l; 589 base::RunLoop l;
583 BrowserThread::PostTask( 590 BrowserThread::PostTask(
584 BrowserThread::IO, FROM_HERE, 591 BrowserThread::IO, FROM_HERE,
585 base::Bind(&AudioOutputDelegateTest::PlayAndDestroyTest, 592 base::Bind(&AudioOutputDelegateTest::PlayAndDestroyTest,
586 base::Unretained(this), l.QuitClosure())); 593 base::Unretained(this), l.QuitClosure()));
587 l.Run(); 594 l.Run();
588 } 595 }
589 596
590 } // namespace content 597 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698