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

Side by Side Diff: webrtc/modules/audio_coding/neteq/decoder_database_unittest.cc

Issue 2348233002: AcmReceiver: Ask NetEq to delete all decoders at once instead of one by one (Closed)
Patch Set: unit tests Created 4 years, 3 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) 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 29 matching lines...) Expand all
40 EXPECT_EQ( 40 EXPECT_EQ(
41 DecoderDatabase::kOK, 41 DecoderDatabase::kOK,
42 db.RegisterPayload(kPayloadType, NetEqDecoder::kDecoderPCMu, kCodecName)); 42 db.RegisterPayload(kPayloadType, NetEqDecoder::kDecoderPCMu, kCodecName));
43 EXPECT_EQ(1, db.Size()); 43 EXPECT_EQ(1, db.Size());
44 EXPECT_FALSE(db.Empty()); 44 EXPECT_FALSE(db.Empty());
45 EXPECT_EQ(DecoderDatabase::kOK, db.Remove(kPayloadType)); 45 EXPECT_EQ(DecoderDatabase::kOK, db.Remove(kPayloadType));
46 EXPECT_EQ(0, db.Size()); 46 EXPECT_EQ(0, db.Size());
47 EXPECT_TRUE(db.Empty()); 47 EXPECT_TRUE(db.Empty());
48 } 48 }
49 49
50 TEST(DecoderDatabase, InsertAndRemoveAll) {
51 DecoderDatabase db(new rtc::RefCountedObject<MockAudioDecoderFactory>);
52 const std::string kCodecName1 = "Robert\'); DROP TABLE Students;";
53 const std::string kCodecName2 = "https://xkcd.com/327/";
54 EXPECT_EQ(DecoderDatabase::kOK,
55 db.RegisterPayload(0, NetEqDecoder::kDecoderPCMu, kCodecName1));
56 EXPECT_EQ(DecoderDatabase::kOK,
57 db.RegisterPayload(1, NetEqDecoder::kDecoderPCMa, kCodecName2));
58 EXPECT_EQ(2, db.Size());
59 EXPECT_FALSE(db.Empty());
60 db.RemoveAll();
61 EXPECT_EQ(0, db.Size());
62 EXPECT_TRUE(db.Empty());
63 }
64
50 TEST(DecoderDatabase, GetDecoderInfo) { 65 TEST(DecoderDatabase, GetDecoderInfo) {
51 rtc::scoped_refptr<MockAudioDecoderFactory> factory( 66 rtc::scoped_refptr<MockAudioDecoderFactory> factory(
52 new rtc::RefCountedObject<MockAudioDecoderFactory>); 67 new rtc::RefCountedObject<MockAudioDecoderFactory>);
53 auto* decoder = new MockAudioDecoder; 68 auto* decoder = new MockAudioDecoder;
54 EXPECT_CALL(*factory, MakeAudioDecoderMock(_, _)) 69 EXPECT_CALL(*factory, MakeAudioDecoderMock(_, _))
55 .WillOnce(Invoke([decoder](const SdpAudioFormat& format, 70 .WillOnce(Invoke([decoder](const SdpAudioFormat& format,
56 std::unique_ptr<AudioDecoder>* dec) { 71 std::unique_ptr<AudioDecoder>* dec) {
57 EXPECT_EQ("pcmu", format.name); 72 EXPECT_EQ("pcmu", format.name);
58 dec->reset(decoder); 73 dec->reset(decoder);
59 })); 74 }));
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 EXPECT_EQ(DecoderDatabase::kOK, db.Remove(13)); 264 EXPECT_EQ(DecoderDatabase::kOK, db.Remove(13));
250 EXPECT_EQ(NULL, db.GetActiveCngDecoder()); 265 EXPECT_EQ(NULL, db.GetActiveCngDecoder());
251 266
252 // Try to set non-existing codecs as active. 267 // Try to set non-existing codecs as active.
253 EXPECT_EQ(DecoderDatabase::kDecoderNotFound, 268 EXPECT_EQ(DecoderDatabase::kDecoderNotFound,
254 db.SetActiveDecoder(17, &changed)); 269 db.SetActiveDecoder(17, &changed));
255 EXPECT_EQ(DecoderDatabase::kDecoderNotFound, 270 EXPECT_EQ(DecoderDatabase::kDecoderNotFound,
256 db.SetActiveCngDecoder(17)); 271 db.SetActiveCngDecoder(17));
257 } 272 }
258 } // namespace webrtc 273 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_coding/neteq/decoder_database.cc ('k') | webrtc/modules/audio_coding/neteq/include/neteq.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698