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 ExpandUntilMuted(num_channels_, &expand_); |
| 190 expand_.Reset(); |
| 191 EXPECT_FALSE(expand_.Muted()); // Should be back to unmuted. |
| 192 |
| 193 ExpandUntilMuted(num_channels_, &expand_); |
| 194 expand_.SetParametersForMergeAfterExpand(); |
| 195 EXPECT_FALSE(expand_.Muted()); // Should be back to unmuted. |
| 196 |
| 197 expand_.Reset(); // Must reset in order to start a new expand period. |
| 198 ExpandUntilMuted(num_channels_, &expand_); |
| 199 expand_.SetParametersForNormalAfterExpand(); |
| 200 EXPECT_FALSE(expand_.Muted()); // Should be back to unmuted. |
| 201 } |
| 202 |
172 // TODO(hlundin): Write more tests. | 203 // TODO(hlundin): Write more tests. |
173 | 204 |
174 } // namespace webrtc | 205 } // namespace webrtc |
OLD | NEW |