diff --git a/src/voice_engine/main/interface/voe_call_report.h b/src/voice_engine/main/interface/voe_call_report.h index d6934d2d1..c4d3abdf2 100644 --- a/src/voice_engine/main/interface/voe_call_report.h +++ b/src/voice_engine/main/interface/voe_call_report.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. + * Copyright (c) 2012 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 @@ -56,7 +56,8 @@ public: virtual int Release() = 0; // Performs a combined reset of all components involved in generating - // the call report for a specified |channel|. + // the call report for a specified |channel|. Pass in -1 to reset + // all channels. virtual int ResetCallReportStatistics(int channel) = 0; // Gets minimum, maximum and average levels for long-term echo metrics. diff --git a/src/voice_engine/main/test/auto_test/standard/call_report_test.cc b/src/voice_engine/main/test/auto_test/standard/call_report_test.cc new file mode 100644 index 000000000..c96b14d2f --- /dev/null +++ b/src/voice_engine/main/test/auto_test/standard/call_report_test.cc @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2012 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_streaming_fixture.h" +#include "testsupport/fileutils.h" + +class CallReportTest : public AfterStreamingFixture { +}; + +TEST_F(CallReportTest, ResetCallReportStatisticsFailsForBadInput) { + EXPECT_EQ(-1, voe_call_report_->ResetCallReportStatistics(-2)); + EXPECT_EQ(-1, voe_call_report_->ResetCallReportStatistics(1)); +} + +TEST_F(CallReportTest, ResetCallReportStatisticsSucceedsWithCorrectInput) { + EXPECT_EQ(0, voe_call_report_->ResetCallReportStatistics(channel_)); + EXPECT_EQ(0, voe_call_report_->ResetCallReportStatistics(-1)); +} + +TEST_F(CallReportTest, EchoMetricSummarySucceeds) { + EXPECT_EQ(0, voe_apm_->SetEcMetricsStatus(true)); + Sleep(1000); + + webrtc::EchoStatistics echo_statistics; + EXPECT_EQ(0, voe_call_report_->GetEchoMetricSummary(echo_statistics)); +} + +TEST_F(CallReportTest, GetRoundTripTimeSummaryReturnsAllMinusOnesIfRtcpIsOff) { + voe_rtp_rtcp_->SetRTCPStatus(channel_, false); + + webrtc::StatVal delays; + EXPECT_EQ(0, voe_call_report_->GetRoundTripTimeSummary(channel_, delays)); + EXPECT_EQ(-1, delays.average); + EXPECT_EQ(-1, delays.min); + EXPECT_EQ(-1, delays.max); +} + +TEST_F(CallReportTest, GetRoundTripTimesReturnsValuesIfRtcpIsOn) { + voe_rtp_rtcp_->SetRTCPStatus(channel_, true); + Sleep(1000); + + webrtc::StatVal delays; + EXPECT_EQ(0, voe_call_report_->GetRoundTripTimeSummary(channel_, delays)); + EXPECT_NE(-1, delays.average); + EXPECT_NE(-1, delays.min); + EXPECT_NE(-1, delays.max); +} + +TEST_F(CallReportTest, DeadOrAliveSummaryFailsIfDeadOrAliveTrackingNotActive) { + int count_the_dead; + int count_the_living; + EXPECT_EQ(-1, voe_call_report_->GetDeadOrAliveSummary(channel_, + count_the_dead, + count_the_living)); +} + +TEST_F(CallReportTest, + DeadOrAliveSummarySucceedsIfDeadOrAliveTrackingIsActive) { + EXPECT_EQ(0, voe_network_->SetPeriodicDeadOrAliveStatus(channel_, true, 1)); + Sleep(1200); + + int count_the_dead; + int count_the_living; + EXPECT_EQ(0, voe_call_report_->GetDeadOrAliveSummary(channel_, + count_the_dead, + count_the_living)); + + EXPECT_GE(count_the_dead, 0); + EXPECT_GE(count_the_living, 0); +} + +TEST_F(CallReportTest, WriteReportToFileFailsOnBadInput) { + EXPECT_EQ(-1, voe_call_report_->WriteReportToFile(NULL)); +} + +TEST_F(CallReportTest, WriteReportToFileSucceedsWithCorrectFilename) { + std::string output_path = webrtc::test::OutputPath(); + std::string report_filename = output_path + "call_report.txt"; + + EXPECT_EQ(0, voe_call_report_->WriteReportToFile(report_filename.c_str())); +} diff --git a/src/voice_engine/main/test/auto_test/voe_standard_test.cc b/src/voice_engine/main/test/auto_test/voe_standard_test.cc index 4962ec2b2..a6af7fab6 100644 --- a/src/voice_engine/main/test/auto_test/voe_standard_test.cc +++ b/src/voice_engine/main/test/auto_test/voe_standard_test.cc @@ -983,71 +983,6 @@ int VoETestManager::DoStandardTest() { if (TestStartStreaming(channel0_transport) != 0) return -1; if (TestStartPlaying() != 0) return -1; - //////////// - // Network - - /////////////// - // CallReport - -#ifdef _TEST_CALL_REPORT_ - TEST_LOG("\n\n+++ CallReport tests +++\n\n"); -#if (defined(WEBRTC_VOICE_ENGINE_ECHO) && defined(WEBRTC_VOICE_ENGINE_NR)) - TEST(ResetCallReportStatistics);ANL(); - TEST_MUSTPASS(!voe_call_report_->ResetCallReportStatistics(-2)); - TEST_MUSTPASS(!voe_call_report_->ResetCallReportStatistics(1)); - TEST_MUSTPASS(voe_call_report_->ResetCallReportStatistics(0)); - TEST_MUSTPASS(voe_call_report_->ResetCallReportStatistics(-1)); - - bool onOff; - TEST_MUSTPASS(voe_apm_->GetEcMetricsStatus(onOff)); - TEST_MUSTPASS(onOff != false); - TEST_MUSTPASS(voe_apm_->SetEcMetricsStatus(true)); - SLEEP(3000); - EchoStatistics echo; - TEST(GetEchoMetricSummary);ANL(); - // all outputs will be -100 in loopback (skip further tests) - TEST_MUSTPASS(voe_call_report_->GetEchoMetricSummary(echo)); - - StatVal delays; - TEST(GetRoundTripTimeSummary);ANL(); - voe_rtp_rtcp_->SetRTCPStatus(0, false); - // All values should be -1 since RTCP is off - TEST_MUSTPASS(voe_call_report_->GetRoundTripTimeSummary(0, delays)); - TEST_MUSTPASS(delays.min != -1); - TEST_MUSTPASS(delays.max != -1); - TEST_MUSTPASS(delays.average != -1); - voe_rtp_rtcp_->SetRTCPStatus(0, true); - SLEEP(5000); // gives time for RTCP - TEST_MUSTPASS(voe_call_report_->GetRoundTripTimeSummary(0, delays)); - TEST_MUSTPASS(delays.min == -1); - TEST_MUSTPASS(delays.max == -1); - TEST_MUSTPASS(delays.average == -1); - voe_rtp_rtcp_->SetRTCPStatus(0, false); - - int nDead = 0; - int nAlive = 0; - // -1 will be returned since dead-or-alive is not active - TEST(GetDeadOrAliveSummary);ANL(); - TEST_MUSTPASS(voe_call_report_->GetDeadOrAliveSummary(0, nDead, - nAlive) != -1); - // we don't need these callbacks any longer - TEST_MUSTPASS(voe_network_->DeRegisterDeadOrAliveObserver(0)); - TEST_MUSTPASS(voe_network_->SetPeriodicDeadOrAliveStatus(0, true, 1)); - SLEEP(2000); - // All results should be >= 0 since dead-or-alive is active - TEST_MUSTPASS(voe_call_report_->GetDeadOrAliveSummary(0, nDead, nAlive)); - TEST_MUSTPASS(nDead == -1);TEST_MUSTPASS(nAlive == -1) - TEST_MUSTPASS(voe_network_->SetPeriodicDeadOrAliveStatus(0, false)); - - TEST(WriteReportToFile);ANL(); - TEST_MUSTPASS(!voe_call_report_->WriteReportToFile(NULL)); - TEST_MUSTPASS(voe_call_report_->WriteReportToFile("call_report.txt")); -#else - TEST_LOG("Skipping CallReport tests since both EC and NS are required\n"); -#endif -#else - TEST_LOG("\n\n+++ CallReport tests NOT ENABLED +++\n"); -#endif // #ifdef _TEST_CALL_REPORT_ ////////////// // Video Sync diff --git a/src/voice_engine/main/test/voice_engine_tests.gypi b/src/voice_engine/main/test/voice_engine_tests.gypi index a9af9fe24..ad7891289 100644 --- a/src/voice_engine/main/test/voice_engine_tests.gypi +++ b/src/voice_engine/main/test/voice_engine_tests.gypi @@ -37,6 +37,7 @@ 'auto_test/fixtures/before_initialization_fixture.cc', 'auto_test/fixtures/before_initialization_fixture.h', 'auto_test/standard/audio_processing_test.cc', + 'auto_test/standard/call_report_test.cc', 'auto_test/standard/codec_before_streaming_test.cc', 'auto_test/standard/codec_test.cc', 'auto_test/standard/dtmf_test.cc',