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

Unified Diff: webrtc/modules/audio_coding/main/acm2/codec_owner_unittest.cc

Issue 1364193002: CodecOwner::SetEncoders: Return error code when given bad arguments (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Add unittest Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/modules/audio_coding/main/acm2/codec_owner.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/audio_coding/main/acm2/codec_owner_unittest.cc
diff --git a/webrtc/modules/audio_coding/main/acm2/codec_owner_unittest.cc b/webrtc/modules/audio_coding/main/acm2/codec_owner_unittest.cc
index 9c1707333942639914f71d4c539aaf7659c23b9c..6c232615a74838ca3b75e24ab1b11ef2c336bcda 100644
--- a/webrtc/modules/audio_coding/main/acm2/codec_owner_unittest.cc
+++ b/webrtc/modules/audio_coding/main/acm2/codec_owner_unittest.cc
@@ -8,6 +8,8 @@
* be found in the AUTHORS file in the root of the source tree.
*/
+#include <cstring>
+
#include "testing/gtest/include/gtest/gtest.h"
#include "webrtc/base/arraysize.h"
#include "webrtc/base/safe_conversions.h"
@@ -34,7 +36,8 @@ class CodecOwnerTest : public ::testing::Test {
CodecOwnerTest() : timestamp_(0) {}
void CreateCodec() {
- codec_owner_.SetEncoders(kDefaultCodecInst, kCngPt, VADNormal, -1);
+ ASSERT_TRUE(
+ codec_owner_.SetEncoders(kDefaultCodecInst, kCngPt, VADNormal, -1));
}
void EncodeAndVerify(size_t expected_out_length,
@@ -167,7 +170,7 @@ TEST_F(CodecOwnerTest, ExternalEncoder) {
// Change to internal encoder.
CodecInst codec_inst = kDefaultCodecInst;
codec_inst.pacsize = kPacketSizeSamples;
- codec_owner_.SetEncoders(codec_inst, -1, VADNormal, -1);
+ ASSERT_TRUE(codec_owner_.SetEncoders(codec_inst, -1, VADNormal, -1));
// Don't expect any more calls to the external encoder.
info = codec_owner_.Encoder()->Encode(1, audio, arraysize(audio),
arraysize(encoded), encoded);
@@ -196,5 +199,12 @@ TEST_F(CodecOwnerTest, NoCngAndRedNoSpeechEncoderReset) {
TestCngAndRedResetSpeechEncoder(false, false);
}
+TEST_F(CodecOwnerTest, SetEncodersError) {
+ CodecInst codec_inst = kDefaultCodecInst;
+ static const char bad_name[] = "Robert'); DROP TABLE Students;";
hlundin-webrtc 2015/09/24 11:24:03 Bonus points for the xkcd archaeology!
+ std::memcpy(codec_inst.plname, bad_name, sizeof bad_name);
+ EXPECT_FALSE(codec_owner_.SetEncoders(codec_inst, -1, VADNormal, -1));
+}
+
} // namespace acm2
} // namespace webrtc
« no previous file with comments | « webrtc/modules/audio_coding/main/acm2/codec_owner.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698