diff options
author | hclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-04 23:27:20 +0000 |
---|---|---|
committer | hclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-04 23:27:20 +0000 |
commit | d34f2bb9bf648a2ee4b5393df0650e5ad2de67dd (patch) | |
tree | 835497a711766797f328ba905ab81a7dbff11e50 /media | |
parent | a3a26e612baf4993203949d91243b5ae03ea815b (diff) | |
download | chromium_src-d34f2bb9bf648a2ee4b5393df0650e5ad2de67dd.zip chromium_src-d34f2bb9bf648a2ee4b5393df0650e5ad2de67dd.tar.gz chromium_src-d34f2bb9bf648a2ee4b5393df0650e5ad2de67dd.tar.bz2 |
Fix build bustage due to media_tests
It's not the right time to move SineWaveAudioSource to a common
unit test yet since linux doesn't have mock audio stream
implemented.
TBR=cpu, willchan
Review URL: http://codereview.chromium.org/118286
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17691 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r-- | media/audio/simple_sources_unittest.cc | 44 | ||||
-rw-r--r-- | media/audio/win/audio_output_win_unittest.cc | 45 |
2 files changed, 45 insertions, 44 deletions
diff --git a/media/audio/simple_sources_unittest.cc b/media/audio/simple_sources_unittest.cc index 0ebb335..b40c0b4 100644 --- a/media/audio/simple_sources_unittest.cc +++ b/media/audio/simple_sources_unittest.cc @@ -60,47 +60,3 @@ TEST(SimpleSourcesTest, PushSourceSmallerWrite) { push_source.OnClose(NULL);
}
-
- -// Validate that the SineWaveAudioSource writes the expected values for -// the FORMAT_16BIT_MONO. The values are carefully selected so rounding issues -// do not affect the result. We also test that AudioManager::GetLastMockBuffer -// works. -TEST(SimpleSourcesTest, SineWaveAudio16MonoTest) { - const size_t samples = 1024; - const size_t bytes_per_sample = 2; - const int freq = 200; - - SineWaveAudioSource source(SineWaveAudioSource::FORMAT_16BIT_LINEAR_PCM, 1, - freq, AudioManager::kTelephoneSampleRate); - - AudioManager* audio_man = AudioManager::GetAudioManager(); - ASSERT_TRUE(NULL != audio_man); - AudioOutputStream* oas = - audio_man->MakeAudioStream(AudioManager::AUDIO_MOCK, 1, - AudioManager::kTelephoneSampleRate, - bytes_per_sample * 2); - ASSERT_TRUE(NULL != oas); - EXPECT_TRUE(oas->Open(samples * bytes_per_sample)); - - oas->Start(&source); - oas->Stop(); - oas->Close(); - - const int16* last_buffer = - reinterpret_cast<const int16*>(audio_man->GetLastMockBuffer()); - ASSERT_TRUE(NULL != last_buffer); - - size_t half_period = AudioManager::kTelephoneSampleRate / (freq * 2); - - // Spot test positive incursion of sine wave. - EXPECT_EQ(0, last_buffer[0]); - EXPECT_EQ(5126, last_buffer[1]); - EXPECT_TRUE(last_buffer[1] < last_buffer[2]); - EXPECT_TRUE(last_buffer[2] < last_buffer[3]); - // Spot test negative incursion of sine wave. - EXPECT_EQ(0, last_buffer[half_period]); - EXPECT_EQ(-5126, last_buffer[half_period + 1]); - EXPECT_TRUE(last_buffer[half_period + 1] > last_buffer[half_period + 2]); - EXPECT_TRUE(last_buffer[half_period + 2] > last_buffer[half_period + 3]); -} diff --git a/media/audio/win/audio_output_win_unittest.cc b/media/audio/win/audio_output_win_unittest.cc index 00b9dd7..5e58798 100644 --- a/media/audio/win/audio_output_win_unittest.cc +++ b/media/audio/win/audio_output_win_unittest.cc @@ -193,6 +193,51 @@ TEST(WinAudioTest, MockStreamBasicCallbacks) { EXPECT_EQ(1, source.was_closed()); } +// Validate that the SineWaveAudioSource writes the expected values for +// the FORMAT_16BIT_MONO. The values are carefully selected so rounding issues +// do not affect the result. We also test that AudioManager::GetLastMockBuffer +// works. +// TODO(hclam): move this test to SimpleSourcesTest once mock audio stream is +// implemented on other platform. +TEST(WinAudioTest, SineWaveAudio16MonoTest) { + const size_t samples = 1024; + const size_t bytes_per_sample = 2; + const int freq = 200; + + SineWaveAudioSource source(SineWaveAudioSource::FORMAT_16BIT_LINEAR_PCM, 1, + freq, AudioManager::kTelephoneSampleRate); + + AudioManager* audio_man = AudioManager::GetAudioManager(); + ASSERT_TRUE(NULL != audio_man); + AudioOutputStream* oas = + audio_man->MakeAudioStream(AudioManager::AUDIO_MOCK, 1, + AudioManager::kTelephoneSampleRate, + bytes_per_sample * 2); + ASSERT_TRUE(NULL != oas); + EXPECT_TRUE(oas->Open(samples * bytes_per_sample)); + + oas->Start(&source); + oas->Stop(); + oas->Close(); + + const int16* last_buffer = + reinterpret_cast<const int16*>(audio_man->GetLastMockBuffer()); + ASSERT_TRUE(NULL != last_buffer); + + size_t half_period = AudioManager::kTelephoneSampleRate / (freq * 2); + + // Spot test positive incursion of sine wave. + EXPECT_EQ(0, last_buffer[0]); + EXPECT_EQ(5126, last_buffer[1]); + EXPECT_TRUE(last_buffer[1] < last_buffer[2]); + EXPECT_TRUE(last_buffer[2] < last_buffer[3]); + // Spot test negative incursion of sine wave. + EXPECT_EQ(0, last_buffer[half_period]); + EXPECT_EQ(-5126, last_buffer[half_period + 1]); + EXPECT_TRUE(last_buffer[half_period + 1] > last_buffer[half_period + 2]); + EXPECT_TRUE(last_buffer[half_period + 2] > last_buffer[half_period + 3]); +} + // =========================================================================== // Validation of AudioManager::AUDIO_PCM_LINEAR // |