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

Side by Side Diff: media/audio/audio_output_controller_unittest.cc

Issue 1806313003: Pass task runners to AudioManager constructor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Pass task runners into AudioManager::Create Created 4 years, 9 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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/environment.h" 8 #include "base/environment.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
14 #include "base/synchronization/waitable_event.h" 14 #include "base/synchronization/waitable_event.h"
15 #include "media/audio/audio_manager_base.h" 15 #include "media/audio/audio_manager_base.h"
16 #include "media/audio/audio_output_controller.h" 16 #include "media/audio/audio_output_controller.h"
17 #include "media/audio/audio_parameters.h" 17 #include "media/audio/audio_parameters.h"
18 #include "media/audio/fake_audio_log_factory.h"
18 #include "media/base/audio_bus.h" 19 #include "media/base/audio_bus.h"
19 #include "testing/gmock/include/gmock/gmock.h" 20 #include "testing/gmock/include/gmock/gmock.h"
20 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
21 22
22 using ::testing::_; 23 using ::testing::_;
23 using ::testing::AtLeast; 24 using ::testing::AtLeast;
24 using ::testing::DoAll; 25 using ::testing::DoAll;
25 using ::testing::Invoke; 26 using ::testing::Invoke;
26 using ::testing::NotNull; 27 using ::testing::NotNull;
27 using ::testing::Return; 28 using ::testing::Return;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 ACTION(PopulateBuffer) { 88 ACTION(PopulateBuffer) {
88 arg0->Zero(); 89 arg0->Zero();
89 // Note: To confirm the buffer will be populated in these tests, it's 90 // Note: To confirm the buffer will be populated in these tests, it's
90 // sufficient that only the first float in channel 0 is set to the value. 91 // sufficient that only the first float in channel 0 is set to the value.
91 arg0->channel(0)[0] = kBufferNonZeroData; 92 arg0->channel(0)[0] = kBufferNonZeroData;
92 } 93 }
93 94
94 class AudioOutputControllerTest : public testing::Test { 95 class AudioOutputControllerTest : public testing::Test {
95 public: 96 public:
96 AudioOutputControllerTest() 97 AudioOutputControllerTest()
97 : audio_manager_(AudioManager::CreateForTesting()), 98 : audio_manager_(AudioManager::Create(nullptr,
99 nullptr,
100 nullptr,
101 &fake_audio_log_factory_)),
98 create_event_(false, false), 102 create_event_(false, false),
99 play_event_(false, false), 103 play_event_(false, false),
100 read_event_(false, false), 104 read_event_(false, false),
101 pause_event_(false, false) { 105 pause_event_(false, false) {}
106
107 ~AudioOutputControllerTest() override {
108 AudioManager::Destroy(audio_manager_.release());
102 } 109 }
103 110
104 ~AudioOutputControllerTest() override {}
105
106 protected: 111 protected:
107 void Create(int samples_per_packet) { 112 void Create(int samples_per_packet) {
108 EXPECT_FALSE(create_event_.IsSignaled()); 113 EXPECT_FALSE(create_event_.IsSignaled());
109 EXPECT_FALSE(play_event_.IsSignaled()); 114 EXPECT_FALSE(play_event_.IsSignaled());
110 EXPECT_FALSE(read_event_.IsSignaled()); 115 EXPECT_FALSE(read_event_.IsSignaled());
111 EXPECT_FALSE(pause_event_.IsSignaled()); 116 EXPECT_FALSE(pause_event_.IsSignaled());
112 117
113 params_ = AudioParameters( 118 params_ = AudioParameters(
114 AudioParameters::AUDIO_FAKE, kChannelLayout, 119 AudioParameters::AUDIO_FAKE, kChannelLayout,
115 kSampleRate, kBitsPerSample, samples_per_packet); 120 kSampleRate, kBitsPerSample, samples_per_packet);
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 // significantly more time. 251 // significantly more time.
247 static const int kNumIterations = 3; 252 static const int kNumIterations = 3;
248 for (int i = 0; i < kNumIterations; ++i) { 253 for (int i = 0; i < kNumIterations; ++i) {
249 read_event_.Wait(); 254 read_event_.Wait();
250 } 255 }
251 } 256 }
252 void WaitForPause() { pause_event_.Wait(); } 257 void WaitForPause() { pause_event_.Wait(); }
253 258
254 private: 259 private:
255 base::MessageLoopForIO message_loop_; 260 base::MessageLoopForIO message_loop_;
261 FakeAudioLogFactory fake_audio_log_factory_;
256 scoped_ptr<AudioManager> audio_manager_; 262 scoped_ptr<AudioManager> audio_manager_;
257 MockAudioOutputControllerEventHandler mock_event_handler_; 263 MockAudioOutputControllerEventHandler mock_event_handler_;
258 MockAudioOutputControllerSyncReader mock_sync_reader_; 264 MockAudioOutputControllerSyncReader mock_sync_reader_;
259 MockAudioOutputStream mock_stream_; 265 MockAudioOutputStream mock_stream_;
260 base::WaitableEvent create_event_; 266 base::WaitableEvent create_event_;
261 base::WaitableEvent play_event_; 267 base::WaitableEvent play_event_;
262 base::WaitableEvent read_event_; 268 base::WaitableEvent read_event_;
263 base::WaitableEvent pause_event_; 269 base::WaitableEvent pause_event_;
264 AudioParameters params_; 270 AudioParameters params_;
265 scoped_refptr<AudioOutputController> controller_; 271 scoped_refptr<AudioOutputController> controller_;
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 411
406 TEST_F(AudioOutputControllerTest, DivertRevertClose) { 412 TEST_F(AudioOutputControllerTest, DivertRevertClose) {
407 Create(kSamplesPerPacket); 413 Create(kSamplesPerPacket);
408 WaitForCreate(); 414 WaitForCreate();
409 DivertNeverPlaying(); 415 DivertNeverPlaying();
410 RevertWasNotPlaying(); 416 RevertWasNotPlaying();
411 Close(); 417 Close();
412 } 418 }
413 419
414 } // namespace media 420 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698