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

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

Issue 1899733002: NetEq: Simplify DecoderDatabase::DecoderInfo (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) 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 DecoderDatabase db; 46 DecoderDatabase db;
47 const uint8_t kPayloadType = 0; 47 const uint8_t kPayloadType = 0;
48 const std::string kCodecName = "Robert\'); DROP TABLE Students;"; 48 const std::string kCodecName = "Robert\'); DROP TABLE Students;";
49 EXPECT_EQ( 49 EXPECT_EQ(
50 DecoderDatabase::kOK, 50 DecoderDatabase::kOK,
51 db.RegisterPayload(kPayloadType, NetEqDecoder::kDecoderPCMu, kCodecName)); 51 db.RegisterPayload(kPayloadType, NetEqDecoder::kDecoderPCMu, kCodecName));
52 const DecoderDatabase::DecoderInfo* info; 52 const DecoderDatabase::DecoderInfo* info;
53 info = db.GetDecoderInfo(kPayloadType); 53 info = db.GetDecoderInfo(kPayloadType);
54 ASSERT_TRUE(info != NULL); 54 ASSERT_TRUE(info != NULL);
55 EXPECT_EQ(NetEqDecoder::kDecoderPCMu, info->codec_type); 55 EXPECT_EQ(NetEqDecoder::kDecoderPCMu, info->codec_type);
56 EXPECT_EQ(NULL, info->decoder); 56 EXPECT_EQ(nullptr, info->external_decoder);
57 EXPECT_EQ(8000, info->fs_hz); 57 EXPECT_EQ(8000, info->fs_hz);
58 EXPECT_EQ(kCodecName, info->name); 58 EXPECT_EQ(kCodecName, info->name);
59 EXPECT_FALSE(info->external); 59 EXPECT_FALSE(info->external_decoder);
hlundin-webrtc 2016/04/19 06:46:59 Lines 56 and 59 verify the same thing, in slightly
kwiberg-webrtc 2016/04/19 08:57:30 Done.
60 info = db.GetDecoderInfo(kPayloadType + 1); // Other payload type. 60 info = db.GetDecoderInfo(kPayloadType + 1); // Other payload type.
61 EXPECT_TRUE(info == NULL); // Should not be found. 61 EXPECT_TRUE(info == NULL); // Should not be found.
62 } 62 }
63 63
64 TEST(DecoderDatabase, GetRtpPayloadType) { 64 TEST(DecoderDatabase, GetRtpPayloadType) {
65 DecoderDatabase db; 65 DecoderDatabase db;
66 const uint8_t kPayloadType = 0; 66 const uint8_t kPayloadType = 0;
67 const std::string kCodecName = "Robert\'); DROP TABLE Students;"; 67 const std::string kCodecName = "Robert\'); DROP TABLE Students;";
68 EXPECT_EQ( 68 EXPECT_EQ(
69 DecoderDatabase::kOK, 69 DecoderDatabase::kOK,
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 kCodecName, 8000, &decoder)); 132 kCodecName, 8000, &decoder));
133 EXPECT_EQ(1, db.Size()); 133 EXPECT_EQ(1, db.Size());
134 // Get decoder and make sure we get the external one. 134 // Get decoder and make sure we get the external one.
135 EXPECT_EQ(&decoder, db.GetDecoder(kPayloadType)); 135 EXPECT_EQ(&decoder, db.GetDecoder(kPayloadType));
136 // Get the decoder info struct and check it too. 136 // Get the decoder info struct and check it too.
137 const DecoderDatabase::DecoderInfo* info; 137 const DecoderDatabase::DecoderInfo* info;
138 info = db.GetDecoderInfo(kPayloadType); 138 info = db.GetDecoderInfo(kPayloadType);
139 ASSERT_TRUE(info != NULL); 139 ASSERT_TRUE(info != NULL);
140 EXPECT_EQ(NetEqDecoder::kDecoderPCMu, info->codec_type); 140 EXPECT_EQ(NetEqDecoder::kDecoderPCMu, info->codec_type);
141 EXPECT_EQ(kCodecName, info->name); 141 EXPECT_EQ(kCodecName, info->name);
142 EXPECT_EQ(&decoder, info->decoder); 142 EXPECT_EQ(&decoder, info->external_decoder);
143 EXPECT_EQ(8000, info->fs_hz); 143 EXPECT_EQ(8000, info->fs_hz);
144 EXPECT_TRUE(info->external);
145 // Expect not to delete the decoder when removing it from the database, since 144 // Expect not to delete the decoder when removing it from the database, since
146 // it was declared externally. 145 // it was declared externally.
147 EXPECT_CALL(decoder, Die()).Times(0); 146 EXPECT_CALL(decoder, Die()).Times(0);
148 EXPECT_EQ(DecoderDatabase::kOK, db.Remove(kPayloadType)); 147 EXPECT_EQ(DecoderDatabase::kOK, db.Remove(kPayloadType));
149 EXPECT_TRUE(db.Empty()); 148 EXPECT_TRUE(db.Empty());
150 149
151 EXPECT_CALL(decoder, Die()).Times(1); // Will be called when |db| is deleted. 150 EXPECT_CALL(decoder, Die()).Times(1); // Will be called when |db| is deleted.
152 } 151 }
153 152
154 TEST(DecoderDatabase, CheckPayloadTypes) { 153 TEST(DecoderDatabase, CheckPayloadTypes) {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 EXPECT_EQ(DecoderDatabase::kOK, db.Remove(13)); 239 EXPECT_EQ(DecoderDatabase::kOK, db.Remove(13));
241 EXPECT_EQ(NULL, db.GetActiveCngDecoder()); 240 EXPECT_EQ(NULL, db.GetActiveCngDecoder());
242 241
243 // Try to set non-existing codecs as active. 242 // Try to set non-existing codecs as active.
244 EXPECT_EQ(DecoderDatabase::kDecoderNotFound, 243 EXPECT_EQ(DecoderDatabase::kDecoderNotFound,
245 db.SetActiveDecoder(17, &changed)); 244 db.SetActiveDecoder(17, &changed));
246 EXPECT_EQ(DecoderDatabase::kDecoderNotFound, 245 EXPECT_EQ(DecoderDatabase::kDecoderNotFound,
247 db.SetActiveCngDecoder(17)); 246 db.SetActiveCngDecoder(17));
248 } 247 }
249 } // namespace webrtc 248 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698