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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/environment.h" | 6 #include "base/environment.h" |
7 #include "base/files/file_util.h" | 7 #include "base/files/file_util.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
11 #include "base/test/test_timeouts.h" | 11 #include "base/test/test_timeouts.h" |
12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
14 #include "media/audio/audio_io.h" | 14 #include "media/audio/audio_io.h" |
15 #include "media/audio/audio_manager_base.h" | 15 #include "media/audio/audio_manager_base.h" |
| 16 #include "media/audio/audio_unittest_util.h" |
16 #include "media/audio/fake_audio_log_factory.h" | 17 #include "media/audio/fake_audio_log_factory.h" |
17 #include "media/base/seekable_buffer.h" | 18 #include "media/base/seekable_buffer.h" |
18 #include "testing/gmock/include/gmock/gmock.h" | 19 #include "testing/gmock/include/gmock/gmock.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
20 | 21 |
21 #if defined(USE_PULSEAUDIO) | 22 #if defined(USE_PULSEAUDIO) |
22 #include "media/audio/pulse/audio_manager_pulse.h" | 23 #include "media/audio/pulse/audio_manager_pulse.h" |
23 #elif defined(USE_ALSA) | 24 #elif defined(USE_ALSA) |
24 #include "media/audio/alsa/audio_manager_alsa.h" | 25 #include "media/audio/alsa/audio_manager_alsa.h" |
25 #elif defined(USE_CRAS) | 26 #elif defined(USE_CRAS) |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 // Test fixture class. | 108 // Test fixture class. |
108 class AudioLowLatencyInputOutputTest : public testing::Test { | 109 class AudioLowLatencyInputOutputTest : public testing::Test { |
109 protected: | 110 protected: |
110 AudioLowLatencyInputOutputTest() {} | 111 AudioLowLatencyInputOutputTest() {} |
111 | 112 |
112 ~AudioLowLatencyInputOutputTest() override {} | 113 ~AudioLowLatencyInputOutputTest() override {} |
113 | 114 |
114 AudioManager* audio_manager() { return &mock_audio_manager_; } | 115 AudioManager* audio_manager() { return &mock_audio_manager_; } |
115 base::MessageLoopForUI* message_loop() { return &message_loop_; } | 116 base::MessageLoopForUI* message_loop() { return &message_loop_; } |
116 | 117 |
117 // Convenience method which ensures that we are not running on the build | |
118 // bots and that at least one valid input and output device can be found. | |
119 bool CanRunAudioTests() { | |
120 bool input = audio_manager()->HasAudioInputDevices(); | |
121 bool output = audio_manager()->HasAudioOutputDevices(); | |
122 LOG_IF(WARNING, !input) << "No input device detected."; | |
123 LOG_IF(WARNING, !output) << "No output device detected."; | |
124 return input && output; | |
125 } | |
126 | |
127 private: | 118 private: |
128 base::MessageLoopForUI message_loop_; | 119 base::MessageLoopForUI message_loop_; |
129 MockAudioManager mock_audio_manager_; | 120 MockAudioManager mock_audio_manager_; |
130 | 121 |
131 DISALLOW_COPY_AND_ASSIGN(AudioLowLatencyInputOutputTest); | 122 DISALLOW_COPY_AND_ASSIGN(AudioLowLatencyInputOutputTest); |
132 }; | 123 }; |
133 | 124 |
134 // This audio source/sink implementation should be used for manual tests | 125 // This audio source/sink implementation should be used for manual tests |
135 // only since delay measurements are stored on an output text file. | 126 // only since delay measurements are stored on an output text file. |
136 // All incoming/recorded audio packets are stored in an intermediate media | 127 // All incoming/recorded audio packets are stored in an intermediate media |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 // MATLAB example: | 368 // MATLAB example: |
378 // D=load('audio_delay_values_ms.txt'); | 369 // D=load('audio_delay_values_ms.txt'); |
379 // x=cumsum(D(:,1)); | 370 // x=cumsum(D(:,1)); |
380 // plot(x, D(:,2), x, D(:,3), x, D(:,4), x, D(:,2)+D(:,3)+D(:,4)); | 371 // plot(x, D(:,2), x, D(:,3), x, D(:,4), x, D(:,2)+D(:,3)+D(:,4)); |
381 // axis([0, max(x), 0, max(D(:,2)+D(:,3)+D(:,4))+10]); | 372 // axis([0, max(x), 0, max(D(:,2)+D(:,3)+D(:,4))+10]); |
382 // legend('buffer delay','input delay','output delay','total delay'); | 373 // legend('buffer delay','input delay','output delay','total delay'); |
383 // xlabel('time [msec]') | 374 // xlabel('time [msec]') |
384 // ylabel('delay [msec]') | 375 // ylabel('delay [msec]') |
385 // title('Full-duplex audio delay measurement'); | 376 // title('Full-duplex audio delay measurement'); |
386 TEST_F(AudioLowLatencyInputOutputTest, DISABLED_FullDuplexDelayMeasurement) { | 377 TEST_F(AudioLowLatencyInputOutputTest, DISABLED_FullDuplexDelayMeasurement) { |
387 if (!CanRunAudioTests()) | 378 ABORT_AUDIO_TEST_IF_NOT(audio_manager()->HasAudioInputDevices() && |
388 return; | 379 audio_manager()->HasAudioOutputDevices()); |
389 | 380 |
390 AudioInputStreamWrapper aisw(audio_manager()); | 381 AudioInputStreamWrapper aisw(audio_manager()); |
391 AudioInputStream* ais = aisw.Create(); | 382 AudioInputStream* ais = aisw.Create(); |
392 EXPECT_TRUE(ais); | 383 EXPECT_TRUE(ais); |
393 | 384 |
394 AudioOutputStreamWrapper aosw(audio_manager()); | 385 AudioOutputStreamWrapper aosw(audio_manager()); |
395 AudioOutputStream* aos = aosw.Create(); | 386 AudioOutputStream* aos = aosw.Create(); |
396 EXPECT_TRUE(aos); | 387 EXPECT_TRUE(aos); |
397 | 388 |
398 // This test only supports identical parameters in both directions. | 389 // This test only supports identical parameters in both directions. |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 | 427 |
437 // All Close() operations that run on the mocked audio thread, | 428 // All Close() operations that run on the mocked audio thread, |
438 // should be synchronous and not post additional close tasks to | 429 // should be synchronous and not post additional close tasks to |
439 // mocked the audio thread. Hence, there is no need to call | 430 // mocked the audio thread. Hence, there is no need to call |
440 // message_loop()->RunUntilIdle() after the Close() methods. | 431 // message_loop()->RunUntilIdle() after the Close() methods. |
441 aos->Close(); | 432 aos->Close(); |
442 ais->Close(); | 433 ais->Close(); |
443 } | 434 } |
444 | 435 |
445 } // namespace media | 436 } // namespace media |
OLD | NEW |