OLD | NEW |
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 Loading... |
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) {} |
102 } | |
103 | 106 |
104 ~AudioOutputControllerTest() override {} | 107 ~AudioOutputControllerTest() override {} |
105 | 108 |
106 protected: | 109 protected: |
107 void Create(int samples_per_packet) { | 110 void Create(int samples_per_packet) { |
108 EXPECT_FALSE(create_event_.IsSignaled()); | 111 EXPECT_FALSE(create_event_.IsSignaled()); |
109 EXPECT_FALSE(play_event_.IsSignaled()); | 112 EXPECT_FALSE(play_event_.IsSignaled()); |
110 EXPECT_FALSE(read_event_.IsSignaled()); | 113 EXPECT_FALSE(read_event_.IsSignaled()); |
111 EXPECT_FALSE(pause_event_.IsSignaled()); | 114 EXPECT_FALSE(pause_event_.IsSignaled()); |
112 | 115 |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 // significantly more time. | 249 // significantly more time. |
247 static const int kNumIterations = 3; | 250 static const int kNumIterations = 3; |
248 for (int i = 0; i < kNumIterations; ++i) { | 251 for (int i = 0; i < kNumIterations; ++i) { |
249 read_event_.Wait(); | 252 read_event_.Wait(); |
250 } | 253 } |
251 } | 254 } |
252 void WaitForPause() { pause_event_.Wait(); } | 255 void WaitForPause() { pause_event_.Wait(); } |
253 | 256 |
254 private: | 257 private: |
255 base::MessageLoopForIO message_loop_; | 258 base::MessageLoopForIO message_loop_; |
256 scoped_ptr<AudioManager> audio_manager_; | 259 FakeAudioLogFactory fake_audio_log_factory_; |
| 260 ScopedAudioManagerPtr audio_manager_; |
257 MockAudioOutputControllerEventHandler mock_event_handler_; | 261 MockAudioOutputControllerEventHandler mock_event_handler_; |
258 MockAudioOutputControllerSyncReader mock_sync_reader_; | 262 MockAudioOutputControllerSyncReader mock_sync_reader_; |
259 MockAudioOutputStream mock_stream_; | 263 MockAudioOutputStream mock_stream_; |
260 base::WaitableEvent create_event_; | 264 base::WaitableEvent create_event_; |
261 base::WaitableEvent play_event_; | 265 base::WaitableEvent play_event_; |
262 base::WaitableEvent read_event_; | 266 base::WaitableEvent read_event_; |
263 base::WaitableEvent pause_event_; | 267 base::WaitableEvent pause_event_; |
264 AudioParameters params_; | 268 AudioParameters params_; |
265 scoped_refptr<AudioOutputController> controller_; | 269 scoped_refptr<AudioOutputController> controller_; |
266 | 270 |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 | 409 |
406 TEST_F(AudioOutputControllerTest, DivertRevertClose) { | 410 TEST_F(AudioOutputControllerTest, DivertRevertClose) { |
407 Create(kSamplesPerPacket); | 411 Create(kSamplesPerPacket); |
408 WaitForCreate(); | 412 WaitForCreate(); |
409 DivertNeverPlaying(); | 413 DivertNeverPlaying(); |
410 RevertWasNotPlaying(); | 414 RevertWasNotPlaying(); |
411 Close(); | 415 Close(); |
412 } | 416 } |
413 | 417 |
414 } // namespace media | 418 } // namespace media |
OLD | NEW |