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

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

Issue 1864993002: Remove the deprecated EncodeInternal interface from AudioEncoder (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: AudioEncoderOpus: Renamed MaxEncodedBytes to ApproximateEncodedBytes 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;
30 static const size_t kMaxNumSamples = 48 * 10 * 2; // 10 ms @ 48 kHz stereo. 29 static const size_t kMaxNumSamples = 48 * 10 * 2; // 10 ms @ 48 kHz stereo.
31 } 30 }
32 31
33 class AudioEncoderCopyRedTest : public ::testing::Test { 32 class AudioEncoderCopyRedTest : public ::testing::Test {
34 protected: 33 protected:
35 AudioEncoderCopyRedTest() 34 AudioEncoderCopyRedTest()
36 : mock_encoder_(new MockAudioEncoder), 35 : mock_encoder_(new MockAudioEncoder),
37 timestamp_(4711), 36 timestamp_(4711),
38 sample_rate_hz_(16000), 37 sample_rate_hz_(16000),
39 num_audio_samples_10ms(sample_rate_hz_ / 100), 38 num_audio_samples_10ms(sample_rate_hz_ / 100),
40 red_payload_type_(200) { 39 red_payload_type_(200) {
41 AudioEncoderCopyRed::Config config; 40 AudioEncoderCopyRed::Config config;
42 config.payload_type = red_payload_type_; 41 config.payload_type = red_payload_type_;
43 config.speech_encoder = std::unique_ptr<AudioEncoder>(mock_encoder_); 42 config.speech_encoder = std::unique_ptr<AudioEncoder>(mock_encoder_);
44 red_.reset(new AudioEncoderCopyRed(std::move(config))); 43 red_.reset(new AudioEncoderCopyRed(std::move(config)));
45 memset(audio_, 0, sizeof(audio_)); 44 memset(audio_, 0, sizeof(audio_));
46 EXPECT_CALL(*mock_encoder_, NumChannels()).WillRepeatedly(Return(1U)); 45 EXPECT_CALL(*mock_encoder_, NumChannels()).WillRepeatedly(Return(1U));
47 EXPECT_CALL(*mock_encoder_, SampleRateHz()) 46 EXPECT_CALL(*mock_encoder_, SampleRateHz())
48 .WillRepeatedly(Return(sample_rate_hz_)); 47 .WillRepeatedly(Return(sample_rate_hz_));
49 EXPECT_CALL(*mock_encoder_, MaxEncodedBytes())
50 .WillRepeatedly(Return(kMockMaxEncodedBytes));
51 } 48 }
52 49
53 void TearDown() override { 50 void TearDown() override {
54 EXPECT_CALL(*mock_encoder_, Die()).Times(1); 51 EXPECT_CALL(*mock_encoder_, Die()).Times(1);
55 red_.reset(); 52 red_.reset();
56 } 53 }
57 54
58 void Encode() { 55 void Encode() {
59 ASSERT_TRUE(red_.get() != NULL); 56 ASSERT_TRUE(red_.get() != NULL);
60 encoded_.Clear(); 57 encoded_.Clear();
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 config.speech_encoder = NULL; 297 config.speech_encoder = NULL;
301 EXPECT_DEATH(red = new AudioEncoderCopyRed(std::move(config)), 298 EXPECT_DEATH(red = new AudioEncoderCopyRed(std::move(config)),
302 "Speech encoder not provided."); 299 "Speech encoder not provided.");
303 // The delete operation is needed to avoid leak reports from memcheck. 300 // The delete operation is needed to avoid leak reports from memcheck.
304 delete red; 301 delete red;
305 } 302 }
306 303
307 #endif // GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) 304 #endif // GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID)
308 305
309 } // namespace webrtc 306 } // 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