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

Side by Side Diff: webrtc/modules/audio_coding/codecs/red/audio_encoder_copy_red_unittest.cc

Issue 1883543002: Revert of Remove the deprecated EncodeInternal interface from AudioEncoder (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 8 months 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
OLDNEW
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
11 #include <memory> 11 #include <memory>
12 #include <vector> 12 #include <vector>
13 13
14 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
15 #include "webrtc/base/checks.h" 15 #include "webrtc/base/checks.h"
16 #include "webrtc/modules/audio_coding/codecs/red/audio_encoder_copy_red.h" 16 #include "webrtc/modules/audio_coding/codecs/red/audio_encoder_copy_red.h"
17 #include "webrtc/modules/audio_coding/codecs/mock/mock_audio_encoder.h" 17 #include "webrtc/modules/audio_coding/codecs/mock/mock_audio_encoder.h"
18 18
19 using ::testing::Return; 19 using ::testing::Return;
20 using ::testing::_; 20 using ::testing::_;
21 using ::testing::SetArgPointee; 21 using ::testing::SetArgPointee;
22 using ::testing::InSequence; 22 using ::testing::InSequence;
23 using ::testing::Invoke; 23 using ::testing::Invoke;
24 using ::testing::MockFunction; 24 using ::testing::MockFunction;
25 25
26 namespace webrtc { 26 namespace webrtc {
27 27
28 namespace { 28 namespace {
29 static const size_t kMockMaxEncodedBytes = 1000;
29 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.
30 } 31 }
31 32
32 class AudioEncoderCopyRedTest : public ::testing::Test { 33 class AudioEncoderCopyRedTest : public ::testing::Test {
33 protected: 34 protected:
34 AudioEncoderCopyRedTest() 35 AudioEncoderCopyRedTest()
35 : mock_encoder_(new MockAudioEncoder), 36 : mock_encoder_(new MockAudioEncoder),
36 timestamp_(4711), 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 = std::unique_ptr<AudioEncoder>(mock_encoder_); 43 config.speech_encoder = std::unique_ptr<AudioEncoder>(mock_encoder_);
43 red_.reset(new AudioEncoderCopyRed(std::move(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_));
49 EXPECT_CALL(*mock_encoder_, MaxEncodedBytes())
50 .WillRepeatedly(Return(kMockMaxEncodedBytes));
48 } 51 }
49 52
50 void TearDown() override { 53 void TearDown() override {
51 EXPECT_CALL(*mock_encoder_, Die()).Times(1); 54 EXPECT_CALL(*mock_encoder_, Die()).Times(1);
52 red_.reset(); 55 red_.reset();
53 } 56 }
54 57
55 void Encode() { 58 void Encode() {
56 ASSERT_TRUE(red_.get() != NULL); 59 ASSERT_TRUE(red_.get() != NULL);
57 encoded_.Clear(); 60 encoded_.Clear();
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 config.speech_encoder = NULL; 300 config.speech_encoder = NULL;
298 EXPECT_DEATH(red = new AudioEncoderCopyRed(std::move(config)), 301 EXPECT_DEATH(red = new AudioEncoderCopyRed(std::move(config)),
299 "Speech encoder not provided."); 302 "Speech encoder not provided.");
300 // The delete operation is needed to avoid leak reports from memcheck. 303 // The delete operation is needed to avoid leak reports from memcheck.
301 delete red; 304 delete red;
302 } 305 }
303 306
304 #endif // GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) 307 #endif // GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID)
305 308
306 } // namespace webrtc 309 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_coding/codecs/red/audio_encoder_copy_red.cc ('k') | webrtc/modules/modules.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698