OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 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 15 matching lines...) Expand all Loading... |
26 namespace webrtc { | 26 namespace webrtc { |
27 | 27 |
28 namespace { | 28 namespace { |
29 static const size_t kMockMaxEncodedBytes = 1000; | 29 static const size_t kMockMaxEncodedBytes = 1000; |
30 static const size_t kMaxNumSamples = 48 * 10 * 2; // 10 ms @ 48 kHz stereo. | 30 static const size_t kMaxNumSamples = 48 * 10 * 2; // 10 ms @ 48 kHz stereo. |
31 } | 31 } |
32 | 32 |
33 class AudioEncoderCopyRedTest : public ::testing::Test { | 33 class AudioEncoderCopyRedTest : public ::testing::Test { |
34 protected: | 34 protected: |
35 AudioEncoderCopyRedTest() | 35 AudioEncoderCopyRedTest() |
36 : timestamp_(4711), | 36 : mock_encoder_(new MockAudioEncoder), |
| 37 timestamp_(4711), |
37 sample_rate_hz_(16000), | 38 sample_rate_hz_(16000), |
38 num_audio_samples_10ms(sample_rate_hz_ / 100), | 39 num_audio_samples_10ms(sample_rate_hz_ / 100), |
39 red_payload_type_(200) { | 40 red_payload_type_(200) { |
40 AudioEncoderCopyRed::Config config; | 41 AudioEncoderCopyRed::Config config; |
41 config.payload_type = red_payload_type_; | 42 config.payload_type = red_payload_type_; |
42 config.speech_encoder = &mock_encoder_; | 43 config.speech_encoder = std::unique_ptr<AudioEncoder>(mock_encoder_); |
43 red_.reset(new AudioEncoderCopyRed(config)); | 44 red_.reset(new AudioEncoderCopyRed(std::move(config))); |
44 memset(audio_, 0, sizeof(audio_)); | 45 memset(audio_, 0, sizeof(audio_)); |
45 EXPECT_CALL(mock_encoder_, NumChannels()).WillRepeatedly(Return(1U)); | 46 EXPECT_CALL(*mock_encoder_, NumChannels()).WillRepeatedly(Return(1U)); |
46 EXPECT_CALL(mock_encoder_, SampleRateHz()) | 47 EXPECT_CALL(*mock_encoder_, SampleRateHz()) |
47 .WillRepeatedly(Return(sample_rate_hz_)); | 48 .WillRepeatedly(Return(sample_rate_hz_)); |
48 EXPECT_CALL(mock_encoder_, MaxEncodedBytes()) | 49 EXPECT_CALL(*mock_encoder_, MaxEncodedBytes()) |
49 .WillRepeatedly(Return(kMockMaxEncodedBytes)); | 50 .WillRepeatedly(Return(kMockMaxEncodedBytes)); |
50 } | 51 } |
51 | 52 |
52 void TearDown() override { | 53 void TearDown() override { |
| 54 EXPECT_CALL(*mock_encoder_, Die()).Times(1); |
53 red_.reset(); | 55 red_.reset(); |
54 // Don't expect the red_ object to delete the AudioEncoder object. But it | |
55 // will be deleted with the test fixture. This is why we explicitly delete | |
56 // the red_ object above, and set expectations on mock_encoder_ afterwards. | |
57 EXPECT_CALL(mock_encoder_, Die()).Times(1); | |
58 } | 56 } |
59 | 57 |
60 void Encode() { | 58 void Encode() { |
61 ASSERT_TRUE(red_.get() != NULL); | 59 ASSERT_TRUE(red_.get() != NULL); |
62 encoded_.Clear(); | 60 encoded_.Clear(); |
63 encoded_info_ = red_->Encode( | 61 encoded_info_ = red_->Encode( |
64 timestamp_, | 62 timestamp_, |
65 rtc::ArrayView<const int16_t>(audio_, num_audio_samples_10ms), | 63 rtc::ArrayView<const int16_t>(audio_, num_audio_samples_10ms), |
66 &encoded_); | 64 &encoded_); |
67 timestamp_ += num_audio_samples_10ms; | 65 timestamp_ += num_audio_samples_10ms; |
68 } | 66 } |
69 | 67 |
70 MockAudioEncoder mock_encoder_; | 68 MockAudioEncoder* mock_encoder_; |
71 std::unique_ptr<AudioEncoderCopyRed> red_; | 69 std::unique_ptr<AudioEncoderCopyRed> red_; |
72 uint32_t timestamp_; | 70 uint32_t timestamp_; |
73 int16_t audio_[kMaxNumSamples]; | 71 int16_t audio_[kMaxNumSamples]; |
74 const int sample_rate_hz_; | 72 const int sample_rate_hz_; |
75 size_t num_audio_samples_10ms; | 73 size_t num_audio_samples_10ms; |
76 rtc::Buffer encoded_; | 74 rtc::Buffer encoded_; |
77 AudioEncoder::EncodedInfo encoded_info_; | 75 AudioEncoder::EncodedInfo encoded_info_; |
78 const int red_payload_type_; | 76 const int red_payload_type_; |
79 }; | 77 }; |
80 | 78 |
81 TEST_F(AudioEncoderCopyRedTest, CreateAndDestroy) { | 79 TEST_F(AudioEncoderCopyRedTest, CreateAndDestroy) { |
82 } | 80 } |
83 | 81 |
84 TEST_F(AudioEncoderCopyRedTest, CheckSampleRatePropagation) { | 82 TEST_F(AudioEncoderCopyRedTest, CheckSampleRatePropagation) { |
85 EXPECT_CALL(mock_encoder_, SampleRateHz()).WillOnce(Return(17)); | 83 EXPECT_CALL(*mock_encoder_, SampleRateHz()).WillOnce(Return(17)); |
86 EXPECT_EQ(17, red_->SampleRateHz()); | 84 EXPECT_EQ(17, red_->SampleRateHz()); |
87 } | 85 } |
88 | 86 |
89 TEST_F(AudioEncoderCopyRedTest, CheckNumChannelsPropagation) { | 87 TEST_F(AudioEncoderCopyRedTest, CheckNumChannelsPropagation) { |
90 EXPECT_CALL(mock_encoder_, NumChannels()).WillOnce(Return(17U)); | 88 EXPECT_CALL(*mock_encoder_, NumChannels()).WillOnce(Return(17U)); |
91 EXPECT_EQ(17U, red_->NumChannels()); | 89 EXPECT_EQ(17U, red_->NumChannels()); |
92 } | 90 } |
93 | 91 |
94 TEST_F(AudioEncoderCopyRedTest, CheckFrameSizePropagation) { | 92 TEST_F(AudioEncoderCopyRedTest, CheckFrameSizePropagation) { |
95 EXPECT_CALL(mock_encoder_, Num10MsFramesInNextPacket()).WillOnce(Return(17U)); | 93 EXPECT_CALL(*mock_encoder_, Num10MsFramesInNextPacket()) |
| 94 .WillOnce(Return(17U)); |
96 EXPECT_EQ(17U, red_->Num10MsFramesInNextPacket()); | 95 EXPECT_EQ(17U, red_->Num10MsFramesInNextPacket()); |
97 } | 96 } |
98 | 97 |
99 TEST_F(AudioEncoderCopyRedTest, CheckMaxFrameSizePropagation) { | 98 TEST_F(AudioEncoderCopyRedTest, CheckMaxFrameSizePropagation) { |
100 EXPECT_CALL(mock_encoder_, Max10MsFramesInAPacket()).WillOnce(Return(17U)); | 99 EXPECT_CALL(*mock_encoder_, Max10MsFramesInAPacket()).WillOnce(Return(17U)); |
101 EXPECT_EQ(17U, red_->Max10MsFramesInAPacket()); | 100 EXPECT_EQ(17U, red_->Max10MsFramesInAPacket()); |
102 } | 101 } |
103 | 102 |
104 TEST_F(AudioEncoderCopyRedTest, CheckSetBitratePropagation) { | 103 TEST_F(AudioEncoderCopyRedTest, CheckSetBitratePropagation) { |
105 EXPECT_CALL(mock_encoder_, SetTargetBitrate(4711)); | 104 EXPECT_CALL(*mock_encoder_, SetTargetBitrate(4711)); |
106 red_->SetTargetBitrate(4711); | 105 red_->SetTargetBitrate(4711); |
107 } | 106 } |
108 | 107 |
109 TEST_F(AudioEncoderCopyRedTest, CheckProjectedPacketLossRatePropagation) { | 108 TEST_F(AudioEncoderCopyRedTest, CheckProjectedPacketLossRatePropagation) { |
110 EXPECT_CALL(mock_encoder_, SetProjectedPacketLossRate(0.5)); | 109 EXPECT_CALL(*mock_encoder_, SetProjectedPacketLossRate(0.5)); |
111 red_->SetProjectedPacketLossRate(0.5); | 110 red_->SetProjectedPacketLossRate(0.5); |
112 } | 111 } |
113 | 112 |
114 // Checks that the an Encode() call is immediately propagated to the speech | 113 // Checks that the an Encode() call is immediately propagated to the speech |
115 // encoder. | 114 // encoder. |
116 TEST_F(AudioEncoderCopyRedTest, CheckImmediateEncode) { | 115 TEST_F(AudioEncoderCopyRedTest, CheckImmediateEncode) { |
117 // Interleaving the EXPECT_CALL sequence with expectations on the MockFunction | 116 // Interleaving the EXPECT_CALL sequence with expectations on the MockFunction |
118 // check ensures that exactly one call to EncodeImpl happens in each | 117 // check ensures that exactly one call to EncodeImpl happens in each |
119 // Encode call. | 118 // Encode call. |
120 InSequence s; | 119 InSequence s; |
121 MockFunction<void(int check_point_id)> check; | 120 MockFunction<void(int check_point_id)> check; |
122 for (int i = 1; i <= 6; ++i) { | 121 for (int i = 1; i <= 6; ++i) { |
123 EXPECT_CALL(mock_encoder_, EncodeImpl(_, _, _)) | 122 EXPECT_CALL(*mock_encoder_, EncodeImpl(_, _, _)) |
124 .WillRepeatedly(Return(AudioEncoder::EncodedInfo())); | 123 .WillRepeatedly(Return(AudioEncoder::EncodedInfo())); |
125 EXPECT_CALL(check, Call(i)); | 124 EXPECT_CALL(check, Call(i)); |
126 Encode(); | 125 Encode(); |
127 check.Call(i); | 126 check.Call(i); |
128 } | 127 } |
129 } | 128 } |
130 | 129 |
131 // Checks that no output is produced if the underlying codec doesn't emit any | 130 // Checks that no output is produced if the underlying codec doesn't emit any |
132 // new data, even if the RED codec is loaded with a secondary encoding. | 131 // new data, even if the RED codec is loaded with a secondary encoding. |
133 TEST_F(AudioEncoderCopyRedTest, CheckNoOutput) { | 132 TEST_F(AudioEncoderCopyRedTest, CheckNoOutput) { |
134 static const size_t kEncodedSize = 17; | 133 static const size_t kEncodedSize = 17; |
135 { | 134 { |
136 InSequence s; | 135 InSequence s; |
137 EXPECT_CALL(mock_encoder_, EncodeImpl(_, _, _)) | 136 EXPECT_CALL(*mock_encoder_, EncodeImpl(_, _, _)) |
138 .WillOnce(Invoke(MockAudioEncoder::FakeEncoding(kEncodedSize))) | 137 .WillOnce(Invoke(MockAudioEncoder::FakeEncoding(kEncodedSize))) |
139 .WillOnce(Invoke(MockAudioEncoder::FakeEncoding(0))) | 138 .WillOnce(Invoke(MockAudioEncoder::FakeEncoding(0))) |
140 .WillOnce(Invoke(MockAudioEncoder::FakeEncoding(kEncodedSize))); | 139 .WillOnce(Invoke(MockAudioEncoder::FakeEncoding(kEncodedSize))); |
141 } | 140 } |
142 | 141 |
143 // Start with one Encode() call that will produce output. | 142 // Start with one Encode() call that will produce output. |
144 Encode(); | 143 Encode(); |
145 // First call is a special case, since it does not include a secondary | 144 // First call is a special case, since it does not include a secondary |
146 // payload. | 145 // payload. |
147 EXPECT_EQ(1u, encoded_info_.redundant.size()); | 146 EXPECT_EQ(1u, encoded_info_.redundant.size()); |
(...skipping 10 matching lines...) Expand all Loading... |
158 } | 157 } |
159 | 158 |
160 // Checks that the correct payload sizes are populated into the redundancy | 159 // Checks that the correct payload sizes are populated into the redundancy |
161 // information. | 160 // information. |
162 TEST_F(AudioEncoderCopyRedTest, CheckPayloadSizes) { | 161 TEST_F(AudioEncoderCopyRedTest, CheckPayloadSizes) { |
163 // Let the mock encoder return payload sizes 1, 2, 3, ..., 10 for the sequence | 162 // Let the mock encoder return payload sizes 1, 2, 3, ..., 10 for the sequence |
164 // of calls. | 163 // of calls. |
165 static const int kNumPackets = 10; | 164 static const int kNumPackets = 10; |
166 InSequence s; | 165 InSequence s; |
167 for (int encode_size = 1; encode_size <= kNumPackets; ++encode_size) { | 166 for (int encode_size = 1; encode_size <= kNumPackets; ++encode_size) { |
168 EXPECT_CALL(mock_encoder_, EncodeImpl(_, _, _)) | 167 EXPECT_CALL(*mock_encoder_, EncodeImpl(_, _, _)) |
169 .WillOnce(Invoke(MockAudioEncoder::FakeEncoding(encode_size))); | 168 .WillOnce(Invoke(MockAudioEncoder::FakeEncoding(encode_size))); |
170 } | 169 } |
171 | 170 |
172 // First call is a special case, since it does not include a secondary | 171 // First call is a special case, since it does not include a secondary |
173 // payload. | 172 // payload. |
174 Encode(); | 173 Encode(); |
175 EXPECT_EQ(1u, encoded_info_.redundant.size()); | 174 EXPECT_EQ(1u, encoded_info_.redundant.size()); |
176 EXPECT_EQ(1u, encoded_info_.encoded_bytes); | 175 EXPECT_EQ(1u, encoded_info_.encoded_bytes); |
177 | 176 |
178 for (size_t i = 2; i <= kNumPackets; ++i) { | 177 for (size_t i = 2; i <= kNumPackets; ++i) { |
179 Encode(); | 178 Encode(); |
180 ASSERT_EQ(2u, encoded_info_.redundant.size()); | 179 ASSERT_EQ(2u, encoded_info_.redundant.size()); |
181 EXPECT_EQ(i, encoded_info_.redundant[0].encoded_bytes); | 180 EXPECT_EQ(i, encoded_info_.redundant[0].encoded_bytes); |
182 EXPECT_EQ(i - 1, encoded_info_.redundant[1].encoded_bytes); | 181 EXPECT_EQ(i - 1, encoded_info_.redundant[1].encoded_bytes); |
183 EXPECT_EQ(i + i - 1, encoded_info_.encoded_bytes); | 182 EXPECT_EQ(i + i - 1, encoded_info_.encoded_bytes); |
184 } | 183 } |
185 } | 184 } |
186 | 185 |
187 // Checks that the correct timestamps are returned. | 186 // Checks that the correct timestamps are returned. |
188 TEST_F(AudioEncoderCopyRedTest, CheckTimestamps) { | 187 TEST_F(AudioEncoderCopyRedTest, CheckTimestamps) { |
189 uint32_t primary_timestamp = timestamp_; | 188 uint32_t primary_timestamp = timestamp_; |
190 AudioEncoder::EncodedInfo info; | 189 AudioEncoder::EncodedInfo info; |
191 info.encoded_bytes = 17; | 190 info.encoded_bytes = 17; |
192 info.encoded_timestamp = timestamp_; | 191 info.encoded_timestamp = timestamp_; |
193 | 192 |
194 EXPECT_CALL(mock_encoder_, EncodeImpl(_, _, _)) | 193 EXPECT_CALL(*mock_encoder_, EncodeImpl(_, _, _)) |
195 .WillOnce(Invoke(MockAudioEncoder::FakeEncoding(info))); | 194 .WillOnce(Invoke(MockAudioEncoder::FakeEncoding(info))); |
196 | 195 |
197 // First call is a special case, since it does not include a secondary | 196 // First call is a special case, since it does not include a secondary |
198 // payload. | 197 // payload. |
199 Encode(); | 198 Encode(); |
200 EXPECT_EQ(primary_timestamp, encoded_info_.encoded_timestamp); | 199 EXPECT_EQ(primary_timestamp, encoded_info_.encoded_timestamp); |
201 | 200 |
202 uint32_t secondary_timestamp = primary_timestamp; | 201 uint32_t secondary_timestamp = primary_timestamp; |
203 primary_timestamp = timestamp_; | 202 primary_timestamp = timestamp_; |
204 info.encoded_timestamp = timestamp_; | 203 info.encoded_timestamp = timestamp_; |
205 EXPECT_CALL(mock_encoder_, EncodeImpl(_, _, _)) | 204 EXPECT_CALL(*mock_encoder_, EncodeImpl(_, _, _)) |
206 .WillOnce(Invoke(MockAudioEncoder::FakeEncoding(info))); | 205 .WillOnce(Invoke(MockAudioEncoder::FakeEncoding(info))); |
207 | 206 |
208 Encode(); | 207 Encode(); |
209 ASSERT_EQ(2u, encoded_info_.redundant.size()); | 208 ASSERT_EQ(2u, encoded_info_.redundant.size()); |
210 EXPECT_EQ(primary_timestamp, encoded_info_.redundant[0].encoded_timestamp); | 209 EXPECT_EQ(primary_timestamp, encoded_info_.redundant[0].encoded_timestamp); |
211 EXPECT_EQ(secondary_timestamp, encoded_info_.redundant[1].encoded_timestamp); | 210 EXPECT_EQ(secondary_timestamp, encoded_info_.redundant[1].encoded_timestamp); |
212 EXPECT_EQ(primary_timestamp, encoded_info_.encoded_timestamp); | 211 EXPECT_EQ(primary_timestamp, encoded_info_.encoded_timestamp); |
213 } | 212 } |
214 | 213 |
215 // Checks that the primary and secondary payloads are written correctly. | 214 // Checks that the primary and secondary payloads are written correctly. |
216 TEST_F(AudioEncoderCopyRedTest, CheckPayloads) { | 215 TEST_F(AudioEncoderCopyRedTest, CheckPayloads) { |
217 // Let the mock encoder write payloads with increasing values. The first | 216 // Let the mock encoder write payloads with increasing values. The first |
218 // payload will have values 0, 1, 2, ..., kPayloadLenBytes - 1. | 217 // payload will have values 0, 1, 2, ..., kPayloadLenBytes - 1. |
219 static const size_t kPayloadLenBytes = 5; | 218 static const size_t kPayloadLenBytes = 5; |
220 uint8_t payload[kPayloadLenBytes]; | 219 uint8_t payload[kPayloadLenBytes]; |
221 for (uint8_t i = 0; i < kPayloadLenBytes; ++i) { | 220 for (uint8_t i = 0; i < kPayloadLenBytes; ++i) { |
222 payload[i] = i; | 221 payload[i] = i; |
223 } | 222 } |
224 EXPECT_CALL(mock_encoder_, EncodeImpl(_, _, _)) | 223 EXPECT_CALL(*mock_encoder_, EncodeImpl(_, _, _)) |
225 .WillRepeatedly(Invoke(MockAudioEncoder::CopyEncoding(payload))); | 224 .WillRepeatedly(Invoke(MockAudioEncoder::CopyEncoding(payload))); |
226 | 225 |
227 // First call is a special case, since it does not include a secondary | 226 // First call is a special case, since it does not include a secondary |
228 // payload. | 227 // payload. |
229 Encode(); | 228 Encode(); |
230 EXPECT_EQ(kPayloadLenBytes, encoded_info_.encoded_bytes); | 229 EXPECT_EQ(kPayloadLenBytes, encoded_info_.encoded_bytes); |
231 for (size_t i = 0; i < kPayloadLenBytes; ++i) { | 230 for (size_t i = 0; i < kPayloadLenBytes; ++i) { |
232 EXPECT_EQ(i, encoded_.data()[i]); | 231 EXPECT_EQ(i, encoded_.data()[i]); |
233 } | 232 } |
234 | 233 |
(...skipping 15 matching lines...) Expand all Loading... |
250 } | 249 } |
251 } | 250 } |
252 | 251 |
253 // Checks correct propagation of payload type. | 252 // Checks correct propagation of payload type. |
254 // Checks that the correct timestamps are returned. | 253 // Checks that the correct timestamps are returned. |
255 TEST_F(AudioEncoderCopyRedTest, CheckPayloadType) { | 254 TEST_F(AudioEncoderCopyRedTest, CheckPayloadType) { |
256 const int primary_payload_type = red_payload_type_ + 1; | 255 const int primary_payload_type = red_payload_type_ + 1; |
257 AudioEncoder::EncodedInfo info; | 256 AudioEncoder::EncodedInfo info; |
258 info.encoded_bytes = 17; | 257 info.encoded_bytes = 17; |
259 info.payload_type = primary_payload_type; | 258 info.payload_type = primary_payload_type; |
260 EXPECT_CALL(mock_encoder_, EncodeImpl(_, _, _)) | 259 EXPECT_CALL(*mock_encoder_, EncodeImpl(_, _, _)) |
261 .WillOnce(Invoke(MockAudioEncoder::FakeEncoding(info))); | 260 .WillOnce(Invoke(MockAudioEncoder::FakeEncoding(info))); |
262 | 261 |
263 // First call is a special case, since it does not include a secondary | 262 // First call is a special case, since it does not include a secondary |
264 // payload. | 263 // payload. |
265 Encode(); | 264 Encode(); |
266 ASSERT_EQ(1u, encoded_info_.redundant.size()); | 265 ASSERT_EQ(1u, encoded_info_.redundant.size()); |
267 EXPECT_EQ(primary_payload_type, encoded_info_.redundant[0].payload_type); | 266 EXPECT_EQ(primary_payload_type, encoded_info_.redundant[0].payload_type); |
268 EXPECT_EQ(red_payload_type_, encoded_info_.payload_type); | 267 EXPECT_EQ(red_payload_type_, encoded_info_.payload_type); |
269 | 268 |
270 const int secondary_payload_type = red_payload_type_ + 2; | 269 const int secondary_payload_type = red_payload_type_ + 2; |
271 info.payload_type = secondary_payload_type; | 270 info.payload_type = secondary_payload_type; |
272 EXPECT_CALL(mock_encoder_, EncodeImpl(_, _, _)) | 271 EXPECT_CALL(*mock_encoder_, EncodeImpl(_, _, _)) |
273 .WillOnce(Invoke(MockAudioEncoder::FakeEncoding(info))); | 272 .WillOnce(Invoke(MockAudioEncoder::FakeEncoding(info))); |
274 | 273 |
275 Encode(); | 274 Encode(); |
276 ASSERT_EQ(2u, encoded_info_.redundant.size()); | 275 ASSERT_EQ(2u, encoded_info_.redundant.size()); |
277 EXPECT_EQ(secondary_payload_type, encoded_info_.redundant[0].payload_type); | 276 EXPECT_EQ(secondary_payload_type, encoded_info_.redundant[0].payload_type); |
278 EXPECT_EQ(primary_payload_type, encoded_info_.redundant[1].payload_type); | 277 EXPECT_EQ(primary_payload_type, encoded_info_.redundant[1].payload_type); |
279 EXPECT_EQ(red_payload_type_, encoded_info_.payload_type); | 278 EXPECT_EQ(red_payload_type_, encoded_info_.payload_type); |
280 } | 279 } |
281 | 280 |
282 #if GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) | 281 #if GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) |
283 | 282 |
284 // This test fixture tests various error conditions that makes the | 283 // This test fixture tests various error conditions that makes the |
285 // AudioEncoderCng die via CHECKs. | 284 // AudioEncoderCng die via CHECKs. |
286 class AudioEncoderCopyRedDeathTest : public AudioEncoderCopyRedTest { | 285 class AudioEncoderCopyRedDeathTest : public AudioEncoderCopyRedTest { |
287 protected: | 286 protected: |
288 AudioEncoderCopyRedDeathTest() : AudioEncoderCopyRedTest() {} | 287 AudioEncoderCopyRedDeathTest() : AudioEncoderCopyRedTest() {} |
289 }; | 288 }; |
290 | 289 |
291 TEST_F(AudioEncoderCopyRedDeathTest, WrongFrameSize) { | 290 TEST_F(AudioEncoderCopyRedDeathTest, WrongFrameSize) { |
292 num_audio_samples_10ms *= 2; // 20 ms frame. | 291 num_audio_samples_10ms *= 2; // 20 ms frame. |
293 EXPECT_DEATH(Encode(), ""); | 292 EXPECT_DEATH(Encode(), ""); |
294 num_audio_samples_10ms = 0; // Zero samples. | 293 num_audio_samples_10ms = 0; // Zero samples. |
295 EXPECT_DEATH(Encode(), ""); | 294 EXPECT_DEATH(Encode(), ""); |
296 } | 295 } |
297 | 296 |
298 TEST_F(AudioEncoderCopyRedDeathTest, NullSpeechEncoder) { | 297 TEST_F(AudioEncoderCopyRedDeathTest, NullSpeechEncoder) { |
299 AudioEncoderCopyRed* red = NULL; | 298 AudioEncoderCopyRed* red = NULL; |
300 AudioEncoderCopyRed::Config config; | 299 AudioEncoderCopyRed::Config config; |
301 config.speech_encoder = NULL; | 300 config.speech_encoder = NULL; |
302 EXPECT_DEATH(red = new AudioEncoderCopyRed(config), | 301 EXPECT_DEATH(red = new AudioEncoderCopyRed(std::move(config)), |
303 "Speech encoder not provided."); | 302 "Speech encoder not provided."); |
304 // The delete operation is needed to avoid leak reports from memcheck. | 303 // The delete operation is needed to avoid leak reports from memcheck. |
305 delete red; | 304 delete red; |
306 } | 305 } |
307 | 306 |
308 #endif // GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) | 307 #endif // GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) |
309 | 308 |
310 } // namespace webrtc | 309 } // namespace webrtc |
OLD | NEW |