Chromium Code Reviews| Index: webrtc/modules/audio_mixer/test/audio_mixer_unittest.cc |
| diff --git a/webrtc/modules/audio_mixer/test/audio_mixer_unittest.cc b/webrtc/modules/audio_mixer/test/audio_mixer_unittest.cc |
| index 38f2b2ebff569981ea4b902f08748c9c316ab957..2b2ee16c34c078274c76279c86faa9af9cdcc889 100644 |
| --- a/webrtc/modules/audio_mixer/test/audio_mixer_unittest.cc |
| +++ b/webrtc/modules/audio_mixer/test/audio_mixer_unittest.cc |
| @@ -77,13 +77,14 @@ class MockMixerAudioSource : public MixerAudioSource { |
| } |
| private: |
| - AudioFrame fake_frame_; |
| + AudioFrame fake_frame_, output_frame_; |
| AudioFrameInfo fake_audio_frame_info_; |
| AudioFrameWithMuted FakeAudioFrameWithMuted(const int32_t id, |
| int sample_rate_hz) { |
| + output_frame_.CopyFrom(fake_frame_); |
| return { |
| - fake_frame(), // audio_frame_pointer |
| - fake_info(), // audio_frame_info |
| + &output_frame_, // audio_frame_pointer |
| + fake_info(), // audio_frame_info |
| }; |
| } |
| }; |
| @@ -370,6 +371,69 @@ TEST(AudioMixer, ParticipantNumberOfChannels) { |
| } |
| } |
| +// Test that the volume is reported as zero when the mixer input |
| +// comprises only zero values. |
| +TEST(AudioMixer, LevelIsZeroWhenMixingZeroes) { |
| + const int kId = 1; |
| + const int kSampleRateHz = 8000; |
|
kwiberg-webrtc
2016/08/23 12:58:26
Consider using constexpr instead of const when you
|
| + std::unique_ptr<NewAudioConferenceMixer> mixer( |
| + NewAudioConferenceMixer::Create(kId)); |
| + AudioFrame frame_for_mixing; |
| + |
| + MockMixerAudioSource participant; |
| + participant.fake_frame()->sample_rate_hz_ = kSampleRateHz; |
| + participant.fake_frame()->num_channels_ = 1; |
| + |
| + // Frame duration 10ms. |
| + participant.fake_frame()->samples_per_channel_ = kSampleRateHz / 100; |
| + |
| + EXPECT_EQ(0, mixer->SetMixabilityStatus(&participant, true)); |
| + for (size_t i = 0; i < 11; i++) { |
| + EXPECT_CALL(participant, GetAudioFrameWithMuted(_, kSampleRateHz)) |
| + .Times(Exactly(1)); |
| + mixer->Mix(8000, 1, &frame_for_mixing); |
| + } |
| + |
| + EXPECT_EQ(static_cast<uint32_t>(0), mixer->GetOutputAudioLevel()); |
| + EXPECT_EQ(static_cast<uint32_t>(0), mixer->GetOutputAudioLevelFullRange()); |
| +} |
| + |
| +// Test that the reported volume is maximal as full when the mixer |
| +// input comprises frames with maximal values. |
|
kwiberg-webrtc
2016/08/23 12:58:26
Broken grammar.
aleloi
2016/08/24 07:19:47
Thanks, fixed!
|
| +TEST(AudioMixer, LevelIsMaximalWhenMixingMaximalValues) { |
| + const int kId = 1; |
| + const int kSampleRateHz = 8000; |
|
kwiberg-webrtc
2016/08/23 12:58:26
constexpr
aleloi
2016/08/24 07:19:47
Done.
|
| + std::unique_ptr<NewAudioConferenceMixer> mixer( |
| + NewAudioConferenceMixer::Create(kId)); |
| + AudioFrame frame_for_mixing; |
| + |
| + MockMixerAudioSource participant; |
| + participant.fake_frame()->sample_rate_hz_ = kSampleRateHz; |
| + participant.fake_frame()->num_channels_ = 1; |
| + |
| + // Frame duration 10ms. |
| + participant.fake_frame()->samples_per_channel_ = kSampleRateHz / 100; |
| + |
| + // Fill participant frame data with maximal sound. |
| + std::fill(participant.fake_frame()->data_, |
| + participant.fake_frame()->data_ + kSampleRateHz / 100, |
| + std::numeric_limits<int16_t>::max()); |
| + |
| + EXPECT_EQ(0, mixer->SetMixabilityStatus(&participant, true)); |
| + for (size_t i = 0; i < 11; i++) { |
| + EXPECT_CALL(participant, GetAudioFrameWithMuted(_, kSampleRateHz)) |
| + .Times(Exactly(1)); |
| + mixer->Mix(8000, 1, &frame_for_mixing); |
| + } |
| + |
| + // 9 is the highest possible audio level |
| + EXPECT_EQ(static_cast<uint32_t>(9), mixer->GetOutputAudioLevel()); |
| + |
| + // 0x7fff = 32767 is the highest full range audio level. |
| + EXPECT_EQ(static_cast<uint32_t>(std::numeric_limits<int16_t>::max()), |
| + mixer->GetOutputAudioLevelFullRange()); |
| +} |
| + |
| TEST_F(BothMixersTest, CompareInitialFrameAudio) { |
| EXPECT_CALL(participant_, GetAudioFrameWithMuted(_, _)).Times(Exactly(1)); |