Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 162 } | 162 } |
| 163 EXPECT_EQ(0, statistics_.last_outage_duration_ms()); | 163 EXPECT_EQ(0, statistics_.last_outage_duration_ms()); |
| 164 } | 164 } |
| 165 expand_.SetParametersForNormalAfterExpand(); | 165 expand_.SetParametersForNormalAfterExpand(); |
| 166 // Convert |sum_output_len_samples| to milliseconds. | 166 // Convert |sum_output_len_samples| to milliseconds. |
| 167 EXPECT_EQ(rtc::checked_cast<int>(sum_output_len_samples / | 167 EXPECT_EQ(rtc::checked_cast<int>(sum_output_len_samples / |
| 168 (test_sample_rate_hz_ / 1000)), | 168 (test_sample_rate_hz_ / 1000)), |
| 169 statistics_.last_outage_duration_ms()); | 169 statistics_.last_outage_duration_ms()); |
| 170 } | 170 } |
| 171 | 171 |
| 172 namespace { | |
| 173 // Runs expand until Muted() returns true. Times out after 1000 calls. | |
| 174 void ExpandUntilMuted(size_t num_channels, Expand* expand) { | |
| 175 EXPECT_FALSE(expand->Muted()) << "Instance is muted from the start"; | |
| 176 AudioMultiVector output(num_channels); | |
| 177 int num_calls = 0; | |
| 178 while (!expand->Muted()) { | |
| 179 ASSERT_LT(num_calls++, 1000) << "Test timed out"; | |
| 180 EXPECT_EQ(0, expand->Process(&output)); | |
| 181 } | |
| 182 } | |
| 183 } // namespace | |
| 184 | |
| 185 // Verifies that Muted() returns true after a long expand period. Also verifies | |
| 186 // that Muted() is reset to false after calling Reset(), | |
| 187 // SetParametersForMergeAfterExpand() and SetParametersForNormalAfterExpand(). | |
| 188 TEST_F(ExpandTest, Muted) { | |
| 189 EXPECT_FALSE(expand_.Muted()); // Should start unmuted. | |
|
minyue-webrtc
2016/05/10 11:43:12
not needed, since checked in 175 also.
hlundin-webrtc
2016/05/10 11:52:39
Done.
| |
| 190 ExpandUntilMuted(num_channels_, &expand_); | |
| 191 expand_.Reset(); | |
| 192 EXPECT_FALSE(expand_.Muted()); // Should be back to unmuted. | |
| 193 | |
| 194 ExpandUntilMuted(num_channels_, &expand_); | |
| 195 expand_.SetParametersForMergeAfterExpand(); | |
| 196 EXPECT_FALSE(expand_.Muted()); // Should be back to unmuted. | |
| 197 | |
| 198 expand_.Reset(); // Must reset in order to start a new expand period. | |
| 199 ExpandUntilMuted(num_channels_, &expand_); | |
| 200 expand_.SetParametersForNormalAfterExpand(); | |
| 201 EXPECT_FALSE(expand_.Muted()); // Should be back to unmuted. | |
| 202 } | |
| 203 | |
| 172 // TODO(hlundin): Write more tests. | 204 // TODO(hlundin): Write more tests. |
| 173 | 205 |
| 174 } // namespace webrtc | 206 } // namespace webrtc |
| OLD | NEW |