diff options
Diffstat (limited to 'media/audio/mac/audio_output_mac_unittest.cc')
-rw-r--r-- | media/audio/mac/audio_output_mac_unittest.cc | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/media/audio/mac/audio_output_mac_unittest.cc b/media/audio/mac/audio_output_mac_unittest.cc index c1f67e1..6b357e7 100644 --- a/media/audio/mac/audio_output_mac_unittest.cc +++ b/media/audio/mac/audio_output_mac_unittest.cc @@ -4,11 +4,34 @@ #include "base/basictypes.h" #include "media/audio/audio_output.h" +#include "media/audio/simple_sources.h" #include "testing/gtest/include/gtest/gtest.h" + +// Validate that the SineWaveAudioSource writes the expected values for +// the FORMAT_16BIT_MONO. +TEST(MacAudioTest, SineWaveAudio16MonoTest) { + const size_t samples = 1024; + const int freq = 200; + + SineWaveAudioSource source(SineWaveAudioSource::FORMAT_16BIT_LINEAR_PCM, 1, + freq, AudioManager::kTelephoneSampleRate); + + // TODO(cpu): Put the real test when the mock renderer is ported. + int16 buffer[samples] = { 0xffff }; + source.OnMoreData(NULL, buffer, sizeof(buffer)); + EXPECT_EQ(0, buffer[0]); + EXPECT_EQ(5126, buffer[1]); +} + +// =========================================================================== +// Validation of AudioManager::AUDIO_PCM_LINEAR +// +// Unlike windows, the tests can reliably detect the existense of real +// audio devices on the bots thus no need for 'headless' detection. + // Test that can it be created and closed. TEST(MacAudioTest, PCMWaveStreamGetAndClose) { - // TODO(cpu) : skip if headless. AudioManager* audio_man = AudioManager::GetAudioManager(); ASSERT_TRUE(NULL != audio_man); if (!audio_man->HasAudioDevices()) @@ -21,7 +44,6 @@ TEST(MacAudioTest, PCMWaveStreamGetAndClose) { // Test that it can be opened and closed. TEST(MacAudioTest, PCMWaveStreamOpenAndClose) { - // TODO(cpu) : skip if headless. AudioManager* audio_man = AudioManager::GetAudioManager(); ASSERT_TRUE(NULL != audio_man); if (!audio_man->HasAudioDevices()) |