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

Side by Side Diff: media/audio/mac/audio_output_mac_unittest.cc

Issue 357004: SetVolume and GetVolume take one volume instead of separate left and right vo... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « media/audio/mac/audio_output_mac.cc ('k') | media/audio/win/audio_output_win_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "media/audio/audio_output.h" 6 #include "media/audio/audio_output.h"
7 #include "media/audio/simple_sources.h" 7 #include "media/audio/simple_sources.h"
8 #include "testing/gmock/include/gmock/gmock.h" 8 #include "testing/gmock/include/gmock/gmock.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 audio_man->MakeAudioStream(AudioManager::AUDIO_PCM_LINEAR, 1, 85 audio_man->MakeAudioStream(AudioManager::AUDIO_PCM_LINEAR, 1,
86 AudioManager::kAudioCDSampleRate, 16); 86 AudioManager::kAudioCDSampleRate, 16);
87 ASSERT_TRUE(NULL != oas); 87 ASSERT_TRUE(NULL != oas);
88 88
89 SineWaveAudioSource source(SineWaveAudioSource::FORMAT_16BIT_LINEAR_PCM, 1, 89 SineWaveAudioSource source(SineWaveAudioSource::FORMAT_16BIT_LINEAR_PCM, 1,
90 200.0, AudioManager::kAudioCDSampleRate); 90 200.0, AudioManager::kAudioCDSampleRate);
91 size_t bytes_100_ms = (AudioManager::kAudioCDSampleRate / 10) * 2; 91 size_t bytes_100_ms = (AudioManager::kAudioCDSampleRate / 10) * 2;
92 92
93 EXPECT_TRUE(oas->Open(bytes_100_ms)); 93 EXPECT_TRUE(oas->Open(bytes_100_ms));
94 94
95 oas->SetVolume(0.5, 0.5); 95 oas->SetVolume(0.5);
96 oas->Start(&source); 96 oas->Start(&source);
97 usleep(1500000); 97 usleep(1500000);
98 98
99 // Test that the volume is within the set limits. 99 // Test that the volume is within the set limits.
100 double left_volume = 0.0; 100 double volume = 0.0;
101 double right_volume = 0.0; 101 oas->GetVolume(&volume);
102 oas->GetVolume(&left_volume, &right_volume); 102 EXPECT_LT(volume, 0.51);
103 EXPECT_LT(left_volume, 0.51); 103 EXPECT_GT(volume, 0.49);
104 EXPECT_GT(left_volume, 0.49);
105 EXPECT_LT(right_volume, 0.51);
106 EXPECT_GT(right_volume, 0.49);
107
108 oas->Stop(); 104 oas->Stop();
109 oas->Close(); 105 oas->Close();
110 } 106 }
111 107
112 // This test produces actual audio for 1.5 seconds on the default wave device at 108 // This test produces actual audio for 1.5 seconds on the default wave device at
113 // 22K s/sec. Parameters have been chosen carefully so you should not hear pops 109 // 22K s/sec. Parameters have been chosen carefully so you should not hear pops
114 // or noises while the sound is playing. The sound must also be identical to the 110 // or noises while the sound is playing. The sound must also be identical to the
115 // sound of PCMWaveStreamPlay200HzTone44KssMono test. 111 // sound of PCMWaveStreamPlay200HzTone44KssMono test.
116 TEST(MacAudioTest, PCMWaveStreamPlay200HzTone22KssMono) { 112 TEST(MacAudioTest, PCMWaveStreamPlay200HzTone22KssMono) {
117 AudioManager* audio_man = AudioManager::GetAudioManager(); 113 AudioManager* audio_man = AudioManager::GetAudioManager();
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 .WillOnce(Return(0)); 163 .WillOnce(Return(0));
168 EXPECT_CALL(source, OnMoreData(oas, NotNull(), bytes_100_ms, _)) 164 EXPECT_CALL(source, OnMoreData(oas, NotNull(), bytes_100_ms, _))
169 .Times(AnyNumber()) 165 .Times(AnyNumber())
170 .WillRepeatedly(Return(0)); 166 .WillRepeatedly(Return(0));
171 167
172 oas->Start(&source); 168 oas->Start(&source);
173 usleep(500000); 169 usleep(500000);
174 oas->Stop(); 170 oas->Stop();
175 oas->Close(); 171 oas->Close();
176 } 172 }
OLDNEW
« no previous file with comments | « media/audio/mac/audio_output_mac.cc ('k') | media/audio/win/audio_output_win_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698