Completed rewrite of codec test.

BUG=
TEST=

Review URL: http://webrtc-codereview.appspot.com/324011

git-svn-id: http://webrtc.googlecode.com/svn/trunk@1203 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
phoglund@webrtc.org 2011-12-15 10:40:19 +00:00
parent e8be22c192
commit 610e90e910
3 changed files with 83 additions and 54 deletions

View File

@ -0,0 +1,82 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "after_initialization_fixture.h"
class CodecBeforeStreamingTest : public AfterInitializationFixture {
protected:
void SetUp() {
memset(&codec_instance_, 0, sizeof(codec_instance_));
codec_instance_.channels = 1;
codec_instance_.plfreq = 16000;
codec_instance_.pacsize = 480;
channel_ = voe_base_->CreateChannel();
}
void TearDown() {
voe_base_->DeleteChannel(channel_);
}
webrtc::CodecInst codec_instance_;
int channel_;
};
// TODO(phoglund): add test which verifies default pltypes for various codecs.
TEST_F(CodecBeforeStreamingTest, GetRecPayloadTypeFailsForInvalidCodecName) {
strcpy(codec_instance_.plname, "SomeInvalidCodecName");
// Should fail since the codec name is invalid.
EXPECT_NE(0, voe_codec_->GetRecPayloadType(channel_, codec_instance_));
}
TEST_F(CodecBeforeStreamingTest, GetRecPayloadTypeRecognizesISAC) {
strcpy(codec_instance_.plname, "iSAC");
EXPECT_EQ(0, voe_codec_->GetRecPayloadType(channel_, codec_instance_));
strcpy(codec_instance_.plname, "ISAC");
EXPECT_EQ(0, voe_codec_->GetRecPayloadType(channel_, codec_instance_));
}
TEST_F(CodecBeforeStreamingTest, SetRecPayloadTypeCanChangeISACPayloadType) {
strcpy(codec_instance_.plname, "ISAC");
codec_instance_.pltype = 123;
EXPECT_EQ(0, voe_codec_->SetRecPayloadType(channel_, codec_instance_));
EXPECT_EQ(0, voe_codec_->GetRecPayloadType(channel_, codec_instance_));
EXPECT_EQ(123, codec_instance_.pltype);
codec_instance_.pltype = 104;
EXPECT_EQ(0, voe_codec_->SetRecPayloadType(channel_, codec_instance_));
EXPECT_EQ(0, voe_codec_->GetRecPayloadType(channel_, codec_instance_));
EXPECT_EQ(104, codec_instance_.pltype);
}
TEST_F(CodecBeforeStreamingTest, SetRecPayloadTypeCanChangeILBCPayloadType) {
strcpy(codec_instance_.plname, "iLBC");
codec_instance_.plfreq = 8000;
codec_instance_.pacsize = 240;
codec_instance_.rate = 13300;
EXPECT_EQ(0, voe_codec_->GetRecPayloadType(channel_, codec_instance_));
int original_pltype = codec_instance_.pltype;
codec_instance_.pltype = 123;
EXPECT_EQ(0, voe_codec_->SetRecPayloadType(channel_, codec_instance_));
EXPECT_EQ(0, voe_codec_->GetRecPayloadType(channel_, codec_instance_));
EXPECT_EQ(123, codec_instance_.pltype);
codec_instance_.pltype = original_pltype;
EXPECT_EQ(0, voe_codec_->SetRecPayloadType(channel_, codec_instance_));
EXPECT_EQ(0, voe_codec_->GetRecPayloadType(channel_, codec_instance_));
EXPECT_EQ(original_pltype, codec_instance_.pltype);
}

View File

@ -921,59 +921,6 @@ int VoETestManager::SetUp() {
return 0;
}
int VoETestManager::TestCodecsBeforeStreaming() {
CodecInst codec_instance;
memset(&codec_instance, 0, sizeof(codec_instance));
// This testing must be done before we start playing.
#ifdef _TEST_CODEC_
// Test that set and get payload type work.
#if defined(WEBRTC_CODEC_ISAC)
TEST_LOG("Getting payload type for iSAC\n");
strcpy(codec_instance.plname, "niklas");
codec_instance.channels = 1;
codec_instance.plfreq = 16000;
codec_instance.pacsize = 480;
// Should fail since niklas is not a valid codec name.
TEST_MUSTPASS(!voe_codec_->GetRecPayloadType(0, codec_instance));
// Both iSAC and ISAC should work here.
strcpy(codec_instance.plname, "iSAC");
TEST_MUSTPASS(voe_codec_->GetRecPayloadType(0, codec_instance));
strcpy(codec_instance.plname, "ISAC");
TEST_MUSTPASS(voe_codec_->GetRecPayloadType(0,codec_instance));
int original_pltype = codec_instance.pltype; // Default payload type is 103.
TEST_LOG("Setting payload type for iSAC to 127\n");
codec_instance.pltype = 123;
TEST_MUSTPASS(voe_codec_->SetRecPayloadType(0,codec_instance));
TEST_MUSTPASS(voe_codec_->GetRecPayloadType(0,codec_instance));
TEST_MUSTPASS(!(codec_instance.pltype==123));
TEST_LOG("Setting it back\n");
codec_instance.pltype = original_pltype;
TEST_MUSTPASS(voe_codec_->SetRecPayloadType(0,codec_instance));
TEST_MUSTPASS(voe_codec_->GetRecPayloadType(0,codec_instance));
TEST_MUSTPASS(!(codec_instance.pltype==original_pltype));
codec_instance.pltype = 123;
codec_instance.plfreq = 8000;
codec_instance.pacsize = 240;
codec_instance.rate = 13300;
#ifdef WEBRTC_CODEC_ILBC
strcpy(codec_instance.plname, "iLBC");
TEST_MUSTPASS(voe_codec_->GetRecPayloadType(0,codec_instance));
original_pltype = codec_instance.pltype;
codec_instance.pltype = 123;
TEST_MUSTPASS(voe_codec_->SetRecPayloadType(0,codec_instance));
TEST_MUSTPASS(voe_codec_->GetRecPayloadType(0,codec_instance));
TEST_LOG("Setting it back\n");
codec_instance.pltype = original_pltype;
TEST_MUSTPASS(voe_codec_->SetRecPayloadType(0,codec_instance));
TEST_MUSTPASS(voe_codec_->GetRecPayloadType(0,codec_instance));
TEST_MUSTPASS(!(codec_instance.pltype==original_pltype));
#endif // #ifdef WEBRTC_CODEC_ILBC
#endif // #if defined(WEBRTC_CODEC_ISAC)
#endif // #ifdef _TEST_CODEC_
return 0;
}
int VoETestManager::TestNetworkBeforeStreaming() {
///////////////////////////////////////////////
// Network (test before streaming is activated)
@ -1470,7 +1417,6 @@ int VoETestManager::DoStandardTest() {
if (SetUp() != 0) return -1;
if (TestCodecsBeforeStreaming() != 0) return -1;
if (TestNetworkBeforeStreaming() != 0) return -1;
// TODO(qhogpat): this gets verified way later - quite ugly. Make sure to

View File

@ -28,6 +28,7 @@
'auto_test/automated_mode.cc',
'auto_test/standard/after_initialization_fixture.cc',
'auto_test/standard/before_initialization_fixture.cc',
'auto_test/standard/codec_before_streaming_test.cc',
'auto_test/standard/hardware_before_initializing_test.cc',
'auto_test/standard/hardware_before_streaming_test.cc',
'auto_test/standard/rtp_rtcp_before_streaming_test.cc',