From c4c56ed20b677ee8a230a5965762ca2af6cafcee Mon Sep 17 00:00:00 2001 From: "phoglund@webrtc.org" Date: Wed, 23 Nov 2011 15:23:11 +0000 Subject: [PATCH] Rewrote vie_auto_test to use googletest macros. Removed error counting entirely - that's completely managed by googletest now, except for custom call, loopback and simulcast call. Rewrote remaining tests to use GTest asserts. Rewrote more tests to use GTest macros. The External Codec module is now in the build by default. Merge branch 'master' into macro_improvements Rewrote some more code to use GTest asserts. The manual standard tests now also go through gtest. BUG= TEST= Review URL: http://webrtc-codereview.appspot.com/287002 git-svn-id: http://webrtc.googlecode.com/svn/trunk@1004 4adac7df-926f-26a2-2b94-8c16560cd09d --- src/video_engine/main/interface/vie_errors.h | 4 +- .../automated/vie_api_integration_test.cc | 18 +- .../vie_extended_integration_test.cc | 18 +- .../automated/vie_integration_test_base.cc | 3 +- .../vie_standard_integration_test.cc | 18 +- .../auto_test/interface/tb_capture_device.h | 3 +- .../test/auto_test/interface/tb_interfaces.h | 8 +- .../auto_test/interface/tb_video_channel.h | 7 +- .../test/auto_test/interface/vie_autotest.h | 77 +- .../interface/vie_autotest_defines.h | 34 +- .../auto_test/interface/vie_autotest_main.h | 45 +- .../interface/vie_comparison_tests.h | 4 - .../auto_test/primitives/base_primitives.cc | 54 +- .../auto_test/primitives/base_primitives.h | 1 - .../auto_test/primitives/codec_primitives.cc | 171 +-- .../auto_test/primitives/codec_primitives.h | 2 - .../primitives/general_primitives.cc | 74 +- .../auto_test/primitives/general_primitives.h | 4 - .../auto_test/source/tb_capture_device.cc | 49 +- .../test/auto_test/source/tb_interfaces.cc | 113 +- .../test/auto_test/source/tb_video_channel.cc | 94 +- .../test/auto_test/source/vie_autotest.cc | 92 +- .../auto_test/source/vie_autotest_base.cc | 288 ++--- .../auto_test/source/vie_autotest_capture.cc | 677 ++++------- .../auto_test/source/vie_autotest_codec.cc | 824 ++++--------- .../source/vie_autotest_custom_call.cc | 44 +- .../source/vie_autotest_encryption.cc | 775 ++++-------- .../auto_test/source/vie_autotest_file.cc | 597 ++------- .../source/vie_autotest_image_process.cc | 369 ++---- .../auto_test/source/vie_autotest_linux.cc | 36 +- .../auto_test/source/vie_autotest_main.cc | 459 +++---- .../auto_test/source/vie_autotest_network.cc | 1069 +++++------------ .../auto_test/source/vie_autotest_render.cc | 381 ++---- .../auto_test/source/vie_autotest_rtp_rtcp.cc | 894 ++++---------- .../auto_test/source/vie_comparison_tests.cc | 68 +- src/video_engine/vie_capture_impl.cc | 18 +- src/video_engine/vie_input_manager.cc | 2 +- 37 files changed, 2095 insertions(+), 5299 deletions(-) diff --git a/src/video_engine/main/interface/vie_errors.h b/src/video_engine/main/interface/vie_errors.h index 78ae5520b..96a6c9468 100644 --- a/src/video_engine/main/interface/vie_errors.h +++ b/src/video_engine/main/interface/vie_errors.h @@ -12,7 +12,7 @@ #define WEBRTC_VIDEO_ENGINE_MAIN_INTERFACE_VIE_ERRORS_H_ -enum ViEErrors { +enum ViEErrors { //ViEBase kViENotInitialized = 12000, // Init has not been called successfully. @@ -45,7 +45,7 @@ enum ViEErrors { //ViECapture kViECaptureDeviceAlreadyConnected = 12300, // ConnectCaptureDevice - A capture device has already been connected to this video channel. - kViECaptureDeviceDoesnNotExist, // No capture device exist with the provided capture id or unique name. + kViECaptureDeviceDoesNotExist, // No capture device exist with the provided capture id or unique name. kViECaptureDeviceInvalidChannelId, // ConnectCaptureDevice, DisconnectCaptureDevice- No Channel exist with the provided channel id. kViECaptureDeviceNotConnected, // DisconnectCaptureDevice- No capture device is connected to the channel. kViECaptureDeviceNotStarted, // Stop- The capture device is not started. diff --git a/src/video_engine/test/auto_test/automated/vie_api_integration_test.cc b/src/video_engine/test/auto_test/automated/vie_api_integration_test.cc index 08160940f..1a4a76820 100644 --- a/src/video_engine/test/auto_test/automated/vie_api_integration_test.cc +++ b/src/video_engine/test/auto_test/automated/vie_api_integration_test.cc @@ -22,39 +22,39 @@ class ViEApiIntegrationTest: public ViEIntegrationTest { }; TEST_F(ViEApiIntegrationTest, RunsBaseTestWithoutErrors) { - ASSERT_EQ(0, tests_->ViEBaseAPITest()); + tests_->ViEBaseAPITest(); } TEST_F(ViEApiIntegrationTest, RunsCaptureTestWithoutErrors) { - ASSERT_EQ(0, tests_->ViECaptureAPITest()); + tests_->ViECaptureAPITest(); } TEST_F(ViEApiIntegrationTest, RunsCodecTestWithoutErrors) { - ASSERT_EQ(0, tests_->ViECodecAPITest()); + tests_->ViECodecAPITest(); } TEST_F(ViEApiIntegrationTest, RunsEncryptionTestWithoutErrors) { - ASSERT_EQ(0, tests_->ViEEncryptionAPITest()); + tests_->ViEEncryptionAPITest(); } TEST_F(ViEApiIntegrationTest, RunsFileTestWithoutErrors) { - ASSERT_EQ(0, tests_->ViEFileAPITest()); + tests_->ViEFileAPITest(); } TEST_F(ViEApiIntegrationTest, RunsImageProcessTestWithoutErrors) { - ASSERT_EQ(0, tests_->ViEImageProcessAPITest()); + tests_->ViEImageProcessAPITest(); } TEST_F(ViEApiIntegrationTest, RunsNetworkTestWithoutErrors) { - ASSERT_EQ(0, tests_->ViENetworkAPITest()); + tests_->ViENetworkAPITest(); } TEST_F(ViEApiIntegrationTest, RunsRenderTestWithoutErrors) { - ASSERT_EQ(0, tests_->ViERenderAPITest()); + tests_->ViERenderAPITest(); } TEST_F(ViEApiIntegrationTest, RunsRtpRtcpTestWithoutErrors) { - ASSERT_EQ(0, tests_->ViERtpRtcpAPITest()); + tests_->ViERtpRtcpAPITest(); } } // namespace diff --git a/src/video_engine/test/auto_test/automated/vie_extended_integration_test.cc b/src/video_engine/test/auto_test/automated/vie_extended_integration_test.cc index 6a84d7ca2..1b830157f 100644 --- a/src/video_engine/test/auto_test/automated/vie_extended_integration_test.cc +++ b/src/video_engine/test/auto_test/automated/vie_extended_integration_test.cc @@ -22,39 +22,39 @@ class ViEExtendedIntegrationTest: public ViEIntegrationTest { }; TEST_F(ViEExtendedIntegrationTest, RunsBaseTestWithoutErrors) { - ASSERT_EQ(0, tests_->ViEBaseExtendedTest()); + tests_->ViEBaseExtendedTest(); } TEST_F(ViEExtendedIntegrationTest, RunsCaptureTestWithoutErrors) { - ASSERT_EQ(0, tests_->ViECaptureExtendedTest()); + tests_->ViECaptureExtendedTest(); } TEST_F(ViEExtendedIntegrationTest, RunsCodecTestWithoutErrors) { - ASSERT_EQ(0, tests_->ViECodecExtendedTest()); + tests_->ViECodecExtendedTest(); } TEST_F(ViEExtendedIntegrationTest, RunsEncryptionTestWithoutErrors) { - ASSERT_EQ(0, tests_->ViEEncryptionExtendedTest()); + tests_->ViEEncryptionExtendedTest(); } TEST_F(ViEExtendedIntegrationTest, RunsFileTestWithoutErrors) { - ASSERT_EQ(0, tests_->ViEFileExtendedTest()); + tests_->ViEFileExtendedTest(); } TEST_F(ViEExtendedIntegrationTest, RunsImageProcessTestWithoutErrors) { - ASSERT_EQ(0, tests_->ViEImageProcessExtendedTest()); + tests_->ViEImageProcessExtendedTest(); } TEST_F(ViEExtendedIntegrationTest, RunsNetworkTestWithoutErrors) { - ASSERT_EQ(0, tests_->ViENetworkExtendedTest()); + tests_->ViENetworkExtendedTest(); } TEST_F(ViEExtendedIntegrationTest, RunsRenderTestWithoutErrors) { - ASSERT_EQ(0, tests_->ViERenderExtendedTest()); + tests_->ViERenderExtendedTest(); } TEST_F(ViEExtendedIntegrationTest, RunsRtpRtcpTestWithoutErrors) { - ASSERT_EQ(0, tests_->ViERtpRtcpExtendedTest()); + tests_->ViERtpRtcpExtendedTest(); } } // namespace diff --git a/src/video_engine/test/auto_test/automated/vie_integration_test_base.cc b/src/video_engine/test/auto_test/automated/vie_integration_test_base.cc index 2624f5064..5de60776e 100644 --- a/src/video_engine/test/auto_test/automated/vie_integration_test_base.cc +++ b/src/video_engine/test/auto_test/automated/vie_integration_test_base.cc @@ -22,8 +22,7 @@ void ViEIntegrationTest::SetUpTestCase() { // Create the test cases tests_ = new ViEAutoTest(window_manager->GetWindow1(), - window_manager->GetWindow2(), - ViETest::kUseGTestExpectsForTestErrors); + window_manager->GetWindow2()); } void ViEIntegrationTest::TearDownTestCase() { diff --git a/src/video_engine/test/auto_test/automated/vie_standard_integration_test.cc b/src/video_engine/test/auto_test/automated/vie_standard_integration_test.cc index fa6d0faec..cdebd8860 100644 --- a/src/video_engine/test/auto_test/automated/vie_standard_integration_test.cc +++ b/src/video_engine/test/auto_test/automated/vie_standard_integration_test.cc @@ -33,39 +33,39 @@ class ViEStandardIntegrationTest: public ViEIntegrationTest { }; TEST_F(ViEStandardIntegrationTest, RunsBaseTestWithoutErrors) { - ASSERT_EQ(0, tests_->ViEBaseStandardTest()); + tests_->ViEBaseStandardTest(); } TEST_F(ViEStandardIntegrationTest, RunsCodecTestWithoutErrors) { - ASSERT_EQ(0, tests_->ViECodecStandardTest()); + tests_->ViECodecStandardTest(); } TEST_F(ViEStandardIntegrationTest, RunsCaptureTestWithoutErrors) { - ASSERT_EQ(0, tests_->ViECaptureStandardTest()); + tests_->ViECaptureStandardTest(); } TEST_F(ViEStandardIntegrationTest, RunsEncryptionTestWithoutErrors) { - ASSERT_EQ(0, tests_->ViEEncryptionStandardTest()); + tests_->ViEEncryptionStandardTest(); } TEST_F(ViEStandardIntegrationTest, RunsFileTestWithoutErrors) { - ASSERT_EQ(0, tests_->ViEFileStandardTest()); + tests_->ViEFileStandardTest(); } TEST_F(ViEStandardIntegrationTest, RunsImageProcessTestWithoutErrors) { - ASSERT_EQ(0, tests_->ViEImageProcessStandardTest()); + tests_->ViEImageProcessStandardTest(); } TEST_F(ViEStandardIntegrationTest, RunsNetworkTestWithoutErrors) { - ASSERT_EQ(0, tests_->ViENetworkStandardTest()); + tests_->ViENetworkStandardTest(); } TEST_F(ViEStandardIntegrationTest, RunsRenderTestWithoutErrors) { - ASSERT_EQ(0, tests_->ViERenderStandardTest()); + tests_->ViERenderStandardTest(); } TEST_F(ViEStandardIntegrationTest, RunsRtpRctpTestWithoutErrors) { - ASSERT_EQ(0, tests_->ViERtpRtcpStandardTest()); + tests_->ViERtpRtcpStandardTest(); } } // namespace diff --git a/src/video_engine/test/auto_test/interface/tb_capture_device.h b/src/video_engine/test/auto_test/interface/tb_capture_device.h index 50cce3f8f..3ade1e0ea 100644 --- a/src/video_engine/test/auto_test/interface/tb_capture_device.h +++ b/src/video_engine/test/auto_test/interface/tb_capture_device.h @@ -17,14 +17,13 @@ class TbCaptureDevice { public: - TbCaptureDevice(TbInterfaces& Engine, int& nrOfErrors); + TbCaptureDevice(TbInterfaces& Engine); ~TbCaptureDevice(void); int captureId; void ConnectTo(int videoChannel); void Disconnect(int videoChannel); private: - int& numberOfErrors; TbInterfaces& ViE; webrtc::VideoCaptureModule* vcpm_; }; diff --git a/src/video_engine/test/auto_test/interface/tb_interfaces.h b/src/video_engine/test/auto_test/interface/tb_interfaces.h index 3f46d66bd..63e78a32c 100644 --- a/src/video_engine/test/auto_test/interface/tb_interfaces.h +++ b/src/video_engine/test/auto_test/interface/tb_interfaces.h @@ -30,7 +30,7 @@ class TbInterfaces { public: - TbInterfaces(const char* test_name, int& number_of_errors); + TbInterfaces(const char* test_name); ~TbInterfaces(void); webrtc::VideoEngine* video_engine; @@ -43,13 +43,9 @@ public: webrtc::ViEImageProcess* image_process; webrtc::ViEEncryption* encryption; - int LastError() - { + int LastError() { return base->LastError(); } - -private: - int& numberOfErrors; }; #endif // WEBRTC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_INTERFACE_TB_INTERFACES_H_ diff --git a/src/video_engine/test/auto_test/interface/tb_video_channel.h b/src/video_engine/test/auto_test/interface/tb_video_channel.h index b6c0023ae..5961e6207 100644 --- a/src/video_engine/test/auto_test/interface/tb_video_channel.h +++ b/src/video_engine/test/auto_test/interface/tb_video_channel.h @@ -12,15 +12,15 @@ #define WEBRTC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_INTERFACE_TB_VIDEO_CHANNEL_H_ #include "tb_interfaces.h" -class tbVideoChannel +class TbVideoChannel { public: - tbVideoChannel(TbInterfaces& Engine, int& nrOfErrors, + TbVideoChannel(TbInterfaces& Engine, webrtc::VideoCodecType sendCodec = webrtc::kVideoCodecVP8, int width = 352, int height = 288, int frameRate = 30, int startBitrate = 300); - ~tbVideoChannel(void); + ~TbVideoChannel(void); void SetFrameSettings(int width, int height, int frameRate); @@ -35,7 +35,6 @@ public: int videoChannel; private: - int& numberOfErrors; TbInterfaces& ViE; }; diff --git a/src/video_engine/test/auto_test/interface/vie_autotest.h b/src/video_engine/test/auto_test/interface/vie_autotest.h index 1a1261f17..20faee76e 100644 --- a/src/video_engine/test/auto_test/interface/vie_autotest.h +++ b/src/video_engine/test/auto_test/interface/vie_autotest.h @@ -42,68 +42,73 @@ class TbInterfaces; class ViEToFileRenderer; +// This class provides a bunch of methods, implemented across several .cc +// files, which runs tests on the video engine. All methods will report +// errors using standard googletest macros, except when marked otherwise. class ViEAutoTest { public: - ViEAutoTest(void* window1, void* window2, - ViETest::TestErrorMode testErrorMode); + ViEAutoTest(void* window1, void* window2); ~ViEAutoTest(); - int ViEStandardTest(); - int ViEExtendedTest(); - int ViEAPITest(); + // These three are special and should not be run in a googletest harness. + // They keep track of their errors by themselves and return the number + // of errors. int ViELoopbackCall(); int ViESimulcastCall(); - - // custom call and helper functions int ViECustomCall(); + // All following functions are meant to run in a googletest harness. + void ViEStandardTest(); + void ViEExtendedTest(); + void ViEAPITest(); + // vie_autotest_base.cc - int ViEBaseStandardTest(); - int ViEBaseExtendedTest(); - int ViEBaseAPITest(); + void ViEBaseStandardTest(); + void ViEBaseExtendedTest(); + void ViEBaseAPITest(); // vie_autotest_capture.cc - int ViECaptureStandardTest(); - int ViECaptureExtendedTest(); - int ViECaptureAPITest(); - int ViECaptureExternalCaptureTest(); + void ViECaptureStandardTest(); + void ViECaptureExtendedTest(); + void ViECaptureAPITest(); + void ViECaptureExternalCaptureTest(); // vie_autotest_codec.cc - int ViECodecStandardTest(); - int ViECodecExtendedTest(); - int ViECodecExternalCodecTest(); - int ViECodecAPITest(); + void ViECodecStandardTest(); + void ViECodecExtendedTest(); + void ViECodecExternalCodecTest(); + void ViECodecAPITest(); // vie_autotest_encryption.cc - int ViEEncryptionStandardTest(); - int ViEEncryptionExtendedTest(); - int ViEEncryptionAPITest(); + void ViEEncryptionStandardTest(); + void ViEEncryptionExtendedTest(); + void ViEEncryptionAPITest(); // vie_autotest_file.ccs - int ViEFileStandardTest(); - int ViEFileExtendedTest(); - int ViEFileAPITest(); + void ViEFileStandardTest(); + void ViEFileExtendedTest(); + void ViEFileAPITest(); // vie_autotest_image_process.cc - int ViEImageProcessStandardTest(); - int ViEImageProcessExtendedTest(); - int ViEImageProcessAPITest(); + void ViEImageProcessStandardTest(); + void ViEImageProcessExtendedTest(); + void ViEImageProcessAPITest(); // vie_autotest_network.cc - int ViENetworkStandardTest(); - int ViENetworkExtendedTest(); - int ViENetworkAPITest(); + void ViENetworkStandardTest(); + void ViENetworkExtendedTest(); + void ViENetworkAPITest(); // vie_autotest_render.cc - int ViERenderStandardTest(); - int ViERenderExtendedTest(); - int ViERenderAPITest(); + void ViERenderStandardTest(); + void ViERenderExtendedTest(); + void ViERenderAPITest(); // vie_autotest_rtp_rtcp.cc - int ViERtpRtcpStandardTest(); - int ViERtpRtcpExtendedTest(); - int ViERtpRtcpAPITest(); + void ViERtpRtcpStandardTest(); + void ViERtpRtcpExtendedTest(); + void ViERtpRtcpAPITest(); private: void PrintAudioCodec(const webrtc::CodecInst audioCodec); diff --git a/src/video_engine/test/auto_test/interface/vie_autotest_defines.h b/src/video_engine/test/auto_test/interface/vie_autotest_defines.h index 77a49e6ed..abbb98445 100644 --- a/src/video_engine/test/auto_test/interface/vie_autotest_defines.h +++ b/src/video_engine/test/auto_test/interface/vie_autotest_defines.h @@ -95,14 +95,8 @@ struct AutoTestRect { // ============================================ class ViETest { -public: - enum TestErrorMode { - kUseGTestExpectsForTestErrors, kUseAssertsForTestErrors - }; - - // The test error mode tells how we should assert when an error - // occurs, provided that VIE_ASSERT_ERROR is defined. - static int Init(TestErrorMode test_error_mode) { + public: + static int Init() { #ifdef VIE_LOG_TO_FILE log_file_ = fopen(VIE_LOG_FILE_NAME, "w+t"); #else @@ -110,8 +104,6 @@ public: #endif log_str_ = new char[kMaxLogSize]; memset(log_str_, 0, kMaxLogSize); - - test_error_mode_ = test_error_mode; return 0; } @@ -156,14 +148,8 @@ public: #endif } - static int TestError(bool expr) { - if (!expr) { - AssertError(""); - return 1; - } - return 0; - } - + // Deprecated(qhogpat): Prefer to use googletest macros in all cases + // except the custom call case. static int TestError(bool expr, const char* fmt, ...) { if (!expr) { va_list va; @@ -185,15 +171,7 @@ public: private: static void AssertError(const char* message) { #ifdef VIE_ASSERT_ERROR - if (test_error_mode_ == kUseAssertsForTestErrors) { - assert(false); - } else if (test_error_mode_ == kUseGTestExpectsForTestErrors) { - // Note that the failure gets added here, but information about where - // the real error occurred is usually in the message. - ADD_FAILURE() << message ; - } else { - assert(false && "Internal test framework logical error: unknown mode"); - } + assert(false); #endif } @@ -202,8 +180,6 @@ private: kMaxLogSize = 512 }; static char* log_str_; - - static TestErrorMode test_error_mode_; }; // milliseconds diff --git a/src/video_engine/test/auto_test/interface/vie_autotest_main.h b/src/video_engine/test/auto_test/interface/vie_autotest_main.h index 10629869c..4e8dd2216 100644 --- a/src/video_engine/test/auto_test/interface/vie_autotest_main.h +++ b/src/video_engine/test/auto_test/interface/vie_autotest_main.h @@ -12,24 +12,39 @@ #define WEBRTC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_INTERFACE_VIE_AUTOTEST_MAIN_H_ #include +#include -class ViEAutoTestMain -{ -public: - ViEAutoTestMain(); - bool BeginOSIndependentTesting(); - bool GetAnswer(int index, std::string* answer); - int GetClassTestSelection(); - bool GetNextAnswer(std::string& answer); - bool IsUsingAnswerFile(); - bool UseAnswerFile(const char* fileName); +class ViEAutoTestMain { + public: + ViEAutoTestMain(); + bool BeginOSIndependentTesting(); + bool GetAnswer(int index, std::string* answer); + int AskUserForTestCase(); + bool GetNextAnswer(std::string& answer); + bool IsUsingAnswerFile(); + bool UseAnswerFile(const char* fileName); -private: + private: + std::string answers_[1024]; + int answers_count_; + int answers_index_; + bool use_answer_file_; + std::map index_to_test_method_map_; - std::string _answers[1024]; - int _answersCount; - int _answersIndex; - bool _useAnswerFile; + static const int kInvalidChoice = -1; + + // Prompts the user for a specific test method in the provided test case. + // Returns 0 on success, nonzero otherwise. + int RunSpecificTestCaseIn(const std::string test_case_name); + // Retrieves a number from the user in the interval + // [min_allowed, max_allowed]. Returns kInvalidChoice on failure. + int AskUserForNumber(int min_allowed, int max_allowed); + // Runs all tests matching the provided filter. * are wildcards. + // Returns the test runner result (0 == OK). + int RunTestMatching(const std::string test_case, + const std::string test_method); + // Runs a non-gtest test case. Choice must be [7,9]. Returns 0 on success. + int RunSpecialTestCase(int choice); }; #endif // WEBRTC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_INTERFACE_VIE_AUTOTEST_MAIN_H_ diff --git a/src/video_engine/test/auto_test/interface/vie_comparison_tests.h b/src/video_engine/test/auto_test/interface/vie_comparison_tests.h index d70f44f7c..4ed5d0117 100644 --- a/src/video_engine/test/auto_test/interface/vie_comparison_tests.h +++ b/src/video_engine/test/auto_test/interface/vie_comparison_tests.h @@ -31,9 +31,6 @@ class ViEToFileRenderer; // input is restarted between stages. class ViEComparisonTests { public: - ViEComparisonTests(); - ~ViEComparisonTests(); - // Test a typical simple call setup. void TestCallSetup( const std::string& i420_test_video_path, @@ -49,7 +46,6 @@ class ViEComparisonTests { int height, ViEToFileRenderer* local_file_renderer, ViEToFileRenderer* remote_file_renderer); - }; #endif // SRC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_INTERFACE_VIE_COMPARISON_TESTS_H_ diff --git a/src/video_engine/test/auto_test/primitives/base_primitives.cc b/src/video_engine/test/auto_test/primitives/base_primitives.cc index f138ece6f..068af1b6d 100644 --- a/src/video_engine/test/auto_test/primitives/base_primitives.cc +++ b/src/video_engine/test/auto_test/primitives/base_primitives.cc @@ -18,68 +18,44 @@ void TestI420CallSetup(webrtc::ViECodec* codec_interface, webrtc::VideoEngine* video_engine, webrtc::ViEBase* base_interface, webrtc::ViENetwork* network_interface, - int* number_of_errors, int video_channel, const unsigned char *device_name) { - int error; webrtc::VideoCodec video_codec; memset(&video_codec, 0, sizeof(webrtc::VideoCodec)); // Set up the codec interface with all known receive codecs and with // I420 as the send codec. for (int i = 0; i < codec_interface->NumberOfCodecs(); i++) { - error = codec_interface->GetCodec(i, video_codec); - *number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, codec_interface->GetCodec(i, video_codec)); // Try to keep the test frame size small when I420. if (video_codec.codecType == webrtc::kVideoCodecI420) { video_codec.width = 176; video_codec.height = 144; - error = codec_interface->SetSendCodec(video_channel, video_codec); - *number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, codec_interface->SetSendCodec(video_channel, video_codec)); } - error = codec_interface->SetReceiveCodec(video_channel, video_codec); - *number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, codec_interface->SetReceiveCodec(video_channel, video_codec)); } // Verify that we really found the I420 codec. - error = codec_interface->GetSendCodec(video_channel, video_codec); - *number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - *number_of_errors += ViETest::TestError( - video_codec.codecType == webrtc::kVideoCodecI420, - "ERROR: %s at line %d", __FUNCTION__, __LINE__); + EXPECT_EQ(0, codec_interface->GetSendCodec(video_channel, video_codec)); + EXPECT_EQ(webrtc::kVideoCodecI420, video_codec.codecType); // Set up senders and receivers. char version[1024] = ""; - error = base_interface->GetVersion(version); + EXPECT_EQ(0, base_interface->GetVersion(version)); ViETest::Log("\nUsing WebRTC Video Engine version: %s", version); - *number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + const char *ipAddress = "127.0.0.1"; WebRtc_UWord16 rtpPortListen = 6100; WebRtc_UWord16 rtpPortSend = 6100; - error = network_interface->SetLocalReceiver(video_channel, rtpPortListen); - *number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = base_interface->StartReceive(video_channel); - *number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = network_interface->SetSendDestination(video_channel, ipAddress, - rtpPortSend); - *number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = base_interface->StartSend(video_channel); - *number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, network_interface->SetLocalReceiver(video_channel, + rtpPortListen)); + EXPECT_EQ(0, base_interface->StartReceive(video_channel)); + EXPECT_EQ(0, network_interface->SetSendDestination(video_channel, ipAddress, + rtpPortSend)); + EXPECT_EQ(0, base_interface->StartSend(video_channel)); // Call started. ViETest::Log("Call started"); @@ -89,7 +65,5 @@ void TestI420CallSetup(webrtc::ViECodec* codec_interface, AutoTestSleep(KAutoTestSleepTimeMs); // Done. - error = base_interface->StopSend(video_channel); - *number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, base_interface->StopSend(video_channel)); } diff --git a/src/video_engine/test/auto_test/primitives/base_primitives.h b/src/video_engine/test/auto_test/primitives/base_primitives.h index 6dc73c3dd..19b6f239d 100644 --- a/src/video_engine/test/auto_test/primitives/base_primitives.h +++ b/src/video_engine/test/auto_test/primitives/base_primitives.h @@ -26,7 +26,6 @@ void TestI420CallSetup(webrtc::ViECodec* codec_interface, webrtc::VideoEngine* video_engine, webrtc::ViEBase* base_interface, webrtc::ViENetwork* network_interface, - int* number_of_errors, int video_channel, const unsigned char *device_name); diff --git a/src/video_engine/test/auto_test/primitives/codec_primitives.cc b/src/video_engine/test/auto_test/primitives/codec_primitives.cc index 196a1bad8..74e4c022a 100644 --- a/src/video_engine/test/auto_test/primitives/codec_primitives.cc +++ b/src/video_engine/test/auto_test/primitives/codec_primitives.cc @@ -43,19 +43,12 @@ void SetSuitableResolution(webrtc::VideoCodec* video_codec, void TestCodecImageProcess(webrtc::VideoCodec video_codec, webrtc::ViECodec* codec_interface, int video_channel, - int* number_of_errors, webrtc::ViEImageProcess* image_process) { - int error = codec_interface->SetSendCodec(video_channel, video_codec); - *number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, codec_interface->SetSendCodec(video_channel, video_codec)); ViEAutoTestEffectFilter frame_counter; - error = image_process->RegisterRenderEffectFilter(video_channel, - frame_counter); - *number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, image_process->RegisterRenderEffectFilter(video_channel, + frame_counter)); AutoTestSleep (KAutoTestSleepTimeMs); int max_number_of_rendered_frames = video_codec.maxFramerate * @@ -65,27 +58,16 @@ void TestCodecImageProcess(webrtc::VideoCodec video_codec, // Due to that I420 needs a huge bandwidth, rate control can set // frame rate very low. This happen since we use the same channel // as we just tested with vp8. - *number_of_errors += ViETest::TestError(frame_counter.numFrames > 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_GT(frame_counter.numFrames, 0); } else { #ifdef WEBRTC_ANDROID // Special case to get the autotest to pass on some slow devices - *number_of_errors += ViETest::TestError(frameCounter.numFrames - > max_number_of_rendered_frames / 6, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_GT(frame_counter.numFrames, max_number_of_rendered_frames / 6); #else - *number_of_errors += ViETest::TestError(frame_counter.numFrames - > max_number_of_rendered_frames / 4, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_GT(frame_counter.numFrames, max_number_of_rendered_frames / 4); #endif } - error = image_process->DeregisterRenderEffectFilter(video_channel); - *number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, image_process->DeregisterRenderEffectFilter(video_channel)); } // Test switching from i420 to VP8 as send codec and make sure that @@ -93,64 +75,47 @@ void TestCodecImageProcess(webrtc::VideoCodec video_codec, void TestCodecCallbacks(webrtc::ViEBase *& base_interface, webrtc::ViECodec *codec_interface, int video_channel, - int* number_of_errors, int forced_codec_width, int forced_codec_height) { // Set I420 as send codec so we don't make any assumptions about what // we currently have as send codec: SetSendCodec(webrtc::kVideoCodecI420, codec_interface, video_channel, - number_of_errors, forced_codec_width, forced_codec_height); + forced_codec_width, forced_codec_height); // Register the observer: ViEAutotestCodecObserver codec_observer; - int error = codec_interface->RegisterEncoderObserver(video_channel, - codec_observer); - *number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = codec_interface->RegisterDecoderObserver(video_channel, - codec_observer); - *number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, codec_interface->RegisterEncoderObserver(video_channel, + codec_observer)); + EXPECT_EQ(0, codec_interface->RegisterDecoderObserver(video_channel, + codec_observer)); - // Make the switch + // Make the switch. ViETest::Log("Testing codec callbacks..."); SetSendCodec(webrtc::kVideoCodecVP8, codec_interface, video_channel, - number_of_errors, forced_codec_width, forced_codec_height); + forced_codec_width, forced_codec_height); AutoTestSleep (KAutoTestSleepTimeMs); - // Verify that we got the right codec - *number_of_errors += ViETest::TestError( - codec_observer.incomingCodec.codecType == webrtc::kVideoCodecVP8, - "ERROR: %s at line %d", __FUNCTION__, __LINE__); + // Verify that we got the right codec. + EXPECT_EQ(webrtc::kVideoCodecVP8, codec_observer.incomingCodec.codecType); - // Clean up - error = codec_interface->DeregisterEncoderObserver(video_channel); - *number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = codec_interface->DeregisterDecoderObserver(video_channel); - *number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - *number_of_errors += ViETest::TestError( - codec_observer.incomingCodecCalled > 0, - "ERROR: %s at line %d", __FUNCTION__, __LINE__); - *number_of_errors += ViETest::TestError( - codec_observer.incomingRatecalled > 0, - "ERROR: %s at line %d", __FUNCTION__, __LINE__); - *number_of_errors += ViETest::TestError( - codec_observer.outgoingRatecalled > 0, - "ERROR: %s at line %d", __FUNCTION__, __LINE__); + // Clean up. + EXPECT_EQ(0, codec_interface->DeregisterEncoderObserver(video_channel)); + EXPECT_EQ(0, codec_interface->DeregisterDecoderObserver(video_channel)); + + // Verify results. + EXPECT_GT(codec_observer.incomingCodecCalled, 0); + EXPECT_GT(codec_observer.incomingRatecalled, 0); + EXPECT_GT(codec_observer.outgoingRatecalled, 0); } void TestCodecs(const TbInterfaces& interfaces, - int & number_of_errors, int capture_id, int video_channel, int forced_codec_width, int forced_codec_height) { - int error; webrtc::VideoEngine *video_engine_interface = interfaces.video_engine; webrtc::ViEBase *base_interface = interfaces.base; webrtc::ViECapture *capture_interface = interfaces.capture; @@ -167,46 +132,30 @@ void TestCodecs(const TbInterfaces& interfaces, // Set up all receive codecs. This basically trains the codec interface // to be able to recognize all receive codecs based on payload type. for (int idx = 0; idx < codec_interface->NumberOfCodecs(); idx++) { - error = codec_interface->GetCodec(idx, video_codec); - number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, codec_interface->GetCodec(idx, video_codec)); SetSuitableResolution(&video_codec, forced_codec_width, forced_codec_height); - error = codec_interface->SetReceiveCodec(video_channel, video_codec); - number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, codec_interface->SetReceiveCodec(video_channel, video_codec)); } const char *ip_address = "127.0.0.1"; const unsigned short rtp_port = 6000; - error = network_interface->SetLocalReceiver(video_channel, rtp_port); - number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = base_interface->StartReceive(video_channel); - number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = network_interface->SetSendDestination(video_channel, ip_address, - rtp_port); - number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = base_interface->StartSend(video_channel); - number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, network_interface->SetLocalReceiver(video_channel, rtp_port)); + EXPECT_EQ(0, base_interface->StartReceive(video_channel)); + EXPECT_EQ(0, network_interface->SetSendDestination(video_channel, ip_address, + rtp_port)); + EXPECT_EQ(0, base_interface->StartSend(video_channel)); + // Run all found codecs webrtc::ViEImageProcess *image_process = webrtc::ViEImageProcess::GetInterface(video_engine_interface); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_TRUE(image_process != NULL); ViETest::Log("Loop through all codecs for %d seconds", KAutoTestSleepTimeMs / 1000); for (int i = 0; i < codec_interface->NumberOfCodecs(); i++) { - error = codec_interface->GetCodec(i, video_codec); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, codec_interface->GetCodec(i, video_codec)); if (video_codec.codecType == webrtc::kVideoCodecMPEG4 || video_codec.codecType == webrtc::kVideoCodecRED || @@ -214,67 +163,45 @@ void TestCodecs(const TbInterfaces& interfaces, ViETest::Log("\t %d. %s not tested", i, video_codec.plName); } else { ViETest::Log("\t %d. %s", i, video_codec.plName); - SetSuitableResolution(&video_codec, - forced_codec_width, forced_codec_height); + SetSuitableResolution(&video_codec, forced_codec_width, + forced_codec_height); TestCodecImageProcess(video_codec, codec_interface, video_channel, - &number_of_errors, image_process); + image_process); } } image_process->Release(); TestCodecCallbacks(base_interface, codec_interface, video_channel, - &number_of_errors, forced_codec_width, - forced_codec_height); + forced_codec_width, forced_codec_height); ViETest::Log("Done!"); // *************************************************************** // Testing finished. Tear down Video Engine // *************************************************************** - error = base_interface->StopSend(video_channel); - number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = base_interface->StopReceive(video_channel); - number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = render_interface->StopRender(capture_id); - number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = render_interface->StopRender(video_channel); - number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = render_interface->RemoveRenderer(capture_id); - number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = render_interface->RemoveRenderer(video_channel); - number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = capture_interface->DisconnectCaptureDevice(video_channel); - number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = base_interface->DeleteChannel(video_channel); - number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, base_interface->StopSend(video_channel)); + EXPECT_EQ(0, base_interface->StopReceive(video_channel)); + EXPECT_EQ(0, render_interface->StopRender(capture_id)); + EXPECT_EQ(0, render_interface->StopRender(video_channel)); + EXPECT_EQ(0, render_interface->RemoveRenderer(capture_id)); + EXPECT_EQ(0, render_interface->RemoveRenderer(video_channel)); + EXPECT_EQ(0, capture_interface->DisconnectCaptureDevice(video_channel)); + EXPECT_EQ(0, base_interface->DeleteChannel(video_channel)); } void SetSendCodec(webrtc::VideoCodecType of_type, webrtc::ViECodec* codec_interface, int video_channel, - int* number_of_errors, int forced_codec_width, int forced_codec_height) { webrtc::VideoCodec codec; - bool ok = FindSpecificCodec(of_type, codec_interface, &codec); - *number_of_errors += ViETest::TestError(ok == true, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + bool ok; + EXPECT_TRUE(ok = FindSpecificCodec(of_type, codec_interface, &codec)); if (!ok) { return; } SetSuitableResolution(&codec, forced_codec_width, forced_codec_height); - int error = codec_interface->SetSendCodec(video_channel, codec); - *number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, codec_interface->SetSendCodec(video_channel, codec)); } diff --git a/src/video_engine/test/auto_test/primitives/codec_primitives.h b/src/video_engine/test/auto_test/primitives/codec_primitives.h index fa7def9da..cecb8782b 100644 --- a/src/video_engine/test/auto_test/primitives/codec_primitives.h +++ b/src/video_engine/test/auto_test/primitives/codec_primitives.h @@ -27,7 +27,6 @@ const int kDoNotForceResolution = 0; // be seen as a end-user-visible quality measure - it is more a sanity check // that the codec at least gets some frames through. void TestCodecs(const TbInterfaces& interfaces, - int & number_of_errors, int capture_id, int video_channel, int forced_codec_width, @@ -39,7 +38,6 @@ void TestCodecs(const TbInterfaces& interfaces, void SetSendCodec(webrtc::VideoCodecType of_type, webrtc::ViECodec* codec_interface, int video_channel, - int* number_of_errors, int forced_codec_width, int forced_codec_height); diff --git a/src/video_engine/test/auto_test/primitives/general_primitives.cc b/src/video_engine/test/auto_test/primitives/general_primitives.cc index a277e4384..7ee532c63 100644 --- a/src/video_engine/test/auto_test/primitives/general_primitives.cc +++ b/src/video_engine/test/auto_test/primitives/general_primitives.cc @@ -19,7 +19,6 @@ void FindCaptureDeviceOnSystem(webrtc::ViECapture* capture, unsigned char* device_name, unsigned int device_name_length, int* device_id, - int* number_of_errors, webrtc::VideoCaptureModule** device_video) { bool capture_device_set = false; @@ -31,18 +30,15 @@ void FindCaptureDeviceOnSystem(webrtc::ViECapture* capture, memset(unique_id, 0, kMaxUniqueIdLength); for (unsigned int i = 0; i < dev_info->NumberOfDevices(); i++) { - int error = dev_info->GetDeviceName(i, device_name, device_name_length, - unique_id, kMaxUniqueIdLength); - *number_of_errors += ViETest::TestError( - error == 0, "ERROR: %s at line %d", __FUNCTION__, __LINE__); - *device_video = - webrtc::VideoCaptureFactory::Create(4571, unique_id); + EXPECT_EQ(0, dev_info->GetDeviceName(i, device_name, device_name_length, + unique_id, kMaxUniqueIdLength)); + + *device_video = webrtc::VideoCaptureFactory::Create(4571, unique_id); + EXPECT_TRUE(*device_video != NULL); - *number_of_errors += ViETest::TestError( - *device_video != NULL, "ERROR: %s at line %d", __FUNCTION__, __LINE__); (*device_video)->AddRef(); - error = capture->AllocateCaptureDevice(**device_video, *device_id); + int error = capture->AllocateCaptureDevice(**device_video, *device_id); if (error == 0) { ViETest::Log("Using capture device: %s, captureId: %d.", device_name, *device_id); @@ -54,69 +50,43 @@ void FindCaptureDeviceOnSystem(webrtc::ViECapture* capture, } } delete dev_info; - *number_of_errors += ViETest::TestError( - capture_device_set, "ERROR: %s at line %d - Could not set capture device", - __FUNCTION__, __LINE__); + EXPECT_TRUE(capture_device_set) << "Found no suitable camera on your system."; } void RenderInWindow(webrtc::ViERender* video_render_interface, - int* numberOfErrors, int frame_provider_id, void* os_window, float z_index) { - int error = video_render_interface->AddRenderer(frame_provider_id, os_window, - z_index, 0.0, 0.0, 1.0, 1.0); - *numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = video_render_interface->StartRender(frame_provider_id); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, + video_render_interface->AddRenderer(frame_provider_id, os_window, + z_index, 0.0, 0.0, 1.0, 1.0)); + EXPECT_EQ(0, video_render_interface->StartRender(frame_provider_id)); } void RenderToFile(webrtc::ViERender* renderer_interface, int frame_provider_id, ViEToFileRenderer *to_file_renderer) { - int result = renderer_interface->AddRenderer(frame_provider_id, - webrtc::kVideoI420, - to_file_renderer); - ViETest::TestError(result == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - result = renderer_interface->StartRender(frame_provider_id); - ViETest::TestError(result == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, renderer_interface->AddRenderer( + frame_provider_id, webrtc::kVideoI420, to_file_renderer)); + EXPECT_EQ(0, renderer_interface->StartRender(frame_provider_id)); } void StopAndRemoveRenderers(webrtc::ViEBase* base_interface, webrtc::ViERender* render_interface, - int* number_of_errors, int channel_id, int capture_id) { - int error = render_interface->StopRender(channel_id); - *number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = render_interface->RemoveRenderer(channel_id); - *number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = render_interface->RemoveRenderer(capture_id); - *number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, render_interface->StopRender(channel_id)); + EXPECT_EQ(0, render_interface->RemoveRenderer(channel_id)); + EXPECT_EQ(0, render_interface->RemoveRenderer(capture_id)); } void ConfigureRtpRtcp(webrtc::ViERTP_RTCP* rtcp_interface, - int* number_of_errors, int video_channel) { - int error = rtcp_interface->SetRTCPStatus( - video_channel, webrtc::kRtcpCompound_RFC4585); - *number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = rtcp_interface->SetKeyFrameRequestMethod( - video_channel, webrtc::kViEKeyFrameRequestPliRtcp); - *number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = rtcp_interface->SetTMMBRStatus(video_channel, true); - *number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, rtcp_interface->SetRTCPStatus(video_channel, + webrtc::kRtcpCompound_RFC4585)); + EXPECT_EQ(0, rtcp_interface->SetKeyFrameRequestMethod( + video_channel, webrtc::kViEKeyFrameRequestPliRtcp)); + EXPECT_EQ(0, rtcp_interface->SetTMMBRStatus(video_channel, true)); } bool FindSpecificCodec(webrtc::VideoCodecType of_type, diff --git a/src/video_engine/test/auto_test/primitives/general_primitives.h b/src/video_engine/test/auto_test/primitives/general_primitives.h index 472cb9f6e..d998c0e3e 100644 --- a/src/video_engine/test/auto_test/primitives/general_primitives.h +++ b/src/video_engine/test/auto_test/primitives/general_primitives.h @@ -33,7 +33,6 @@ void FindCaptureDeviceOnSystem(webrtc::ViECapture* capture, unsigned char* device_name, const unsigned int kDeviceNameLength, int* device_id, - int* number_of_errors, webrtc::VideoCaptureModule** device_video); // Sets up rendering in a window previously created using a Window Manager @@ -41,7 +40,6 @@ void FindCaptureDeviceOnSystem(webrtc::ViECapture* capture, // those). The frame provider id is a source of video frames, for instance // a capture device or a video channel. void RenderInWindow(webrtc::ViERender* video_render_interface, - int* numberOfErrors, int frame_provider_id, void* os_window, float z_index); @@ -57,13 +55,11 @@ void RenderToFile(webrtc::ViERender* renderer_interface, // and a video channel set up for rendering. void StopAndRemoveRenderers(webrtc::ViEBase* base_interface, webrtc::ViERender* render_interface, - int* number_of_errors, int channel_id, int capture_id); // Configures RTP-RTCP. void ConfigureRtpRtcp(webrtc::ViERTP_RTCP* rtcp_interface, - int* number_of_errors, int video_channel); // Finds a codec in the codec list. Returns true on success, false otherwise. diff --git a/src/video_engine/test/auto_test/source/tb_capture_device.cc b/src/video_engine/test/auto_test/source/tb_capture_device.cc index 4089ed85d..0d4e46ad5 100644 --- a/src/video_engine/test/auto_test/source/tb_capture_device.cc +++ b/src/video_engine/test/auto_test/source/tb_capture_device.cc @@ -10,9 +10,8 @@ #include "tb_capture_device.h" -TbCaptureDevice::TbCaptureDevice(TbInterfaces& Engine, int& nrOfErrors) : +TbCaptureDevice::TbCaptureDevice(TbInterfaces& Engine) : captureId(-1), - numberOfErrors(nrOfErrors), ViE(Engine), vcpm_(NULL) { @@ -23,7 +22,6 @@ TbCaptureDevice::TbCaptureDevice(TbInterfaces& Engine, int& nrOfErrors) : WebRtc_UWord8 uniqueId[KMaxUniqueIdLength]; memset(uniqueId, 0, KMaxUniqueIdLength); - int error; bool captureDeviceSet = false; webrtc::VideoCaptureModule::DeviceInfo* devInfo = @@ -32,22 +30,19 @@ TbCaptureDevice::TbCaptureDevice(TbInterfaces& Engine, int& nrOfErrors) : captureIdx < devInfo->NumberOfDevices(); captureIdx++) { - error = devInfo->GetDeviceName(captureIdx, deviceName, - KMaxDeviceNameLength, uniqueId, - KMaxUniqueIdLength); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, devInfo->GetDeviceName(captureIdx, deviceName, + KMaxDeviceNameLength, uniqueId, + KMaxUniqueIdLength)); vcpm_ = webrtc::VideoCaptureFactory::Create( captureIdx, uniqueId); - if (vcpm_ == NULL) // Failed to open this device. Try next. + if (vcpm_ == NULL) // Failed to open this device. Try next. { continue; } vcpm_->AddRef(); - error = ViE.capture->AllocateCaptureDevice(*vcpm_, captureId); + int error = ViE.capture->AllocateCaptureDevice(*vcpm_, captureId); if (error == 0) { ViETest::Log("Using capture device: %s, captureId: %d", deviceName, @@ -57,44 +52,30 @@ TbCaptureDevice::TbCaptureDevice(TbInterfaces& Engine, int& nrOfErrors) : } } delete devInfo; - numberOfErrors += ViETest::TestError( - captureDeviceSet, "ERROR: %s at line %d - Could not set capture device", - __FUNCTION__, __LINE__); + EXPECT_TRUE(captureDeviceSet); + if (!captureDeviceSet) { + return; + } ViETest::Log("Starting capture device %s with captureId %d\n", deviceName, captureId); - - error = ViE.capture->StartCapture(captureId); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.capture->StartCapture(captureId)); } TbCaptureDevice::~TbCaptureDevice(void) { ViETest::Log("Stopping capture device with id %d\n", captureId); - int error; - error = ViE.capture->StopCapture(captureId); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ViE.capture->ReleaseCaptureDevice(captureId); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.capture->StopCapture(captureId)); + EXPECT_EQ(0, ViE.capture->ReleaseCaptureDevice(captureId)); vcpm_->Release(); } void TbCaptureDevice::ConnectTo(int videoChannel) { - int error; - error = ViE.capture->ConnectCaptureDevice(captureId, videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.capture->ConnectCaptureDevice(captureId, videoChannel)); } void TbCaptureDevice::Disconnect(int videoChannel) { - int error = 0; - error = ViE.capture->DisconnectCaptureDevice(videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.capture->DisconnectCaptureDevice(videoChannel)); } diff --git a/src/video_engine/test/auto_test/source/tb_interfaces.cc b/src/video_engine/test/auto_test/source/tb_interfaces.cc index 4e5300458..bd6a17d3b 100644 --- a/src/video_engine/test/auto_test/source/tb_interfaces.cc +++ b/src/video_engine/test/auto_test/source/tb_interfaces.cc @@ -10,9 +10,9 @@ #include "tb_interfaces.h" -TbInterfaces::TbInterfaces(const char* testName, int& nrOfErrors) : - numberOfErrors(nrOfErrors) -{ +#include "gtest/gtest.h" + +TbInterfaces::TbInterfaces(const char* testName) { char traceFile[256] = ""; #ifdef WEBRTC_ANDROID @@ -24,111 +24,50 @@ TbInterfaces::TbInterfaces(const char* testName, int& nrOfErrors) : ViETest::Log("Creating ViE Interfaces for test %s\n", testName); video_engine = webrtc::VideoEngine::Create(); - numberOfErrors += ViETest::TestError(video_engine != NULL, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); + EXPECT_TRUE(video_engine != NULL); - int error = video_engine->SetTraceFile(traceFile); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = video_engine->SetTraceFilter(webrtc::kTraceAll); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, video_engine->SetTraceFile(traceFile)); + EXPECT_EQ(0, video_engine->SetTraceFilter(webrtc::kTraceAll)); base = webrtc::ViEBase::GetInterface(video_engine); - numberOfErrors += ViETest::TestError(base != NULL, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); + EXPECT_TRUE(base != NULL); - error = base->Init(); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, base->Init()); capture = webrtc::ViECapture::GetInterface(video_engine); - numberOfErrors += ViETest::TestError(capture != NULL, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); + EXPECT_TRUE(capture != NULL); rtp_rtcp = webrtc::ViERTP_RTCP::GetInterface(video_engine); - numberOfErrors += ViETest::TestError(rtp_rtcp != NULL, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); + EXPECT_TRUE(rtp_rtcp != NULL); render = webrtc::ViERender::GetInterface(video_engine); - numberOfErrors += ViETest::TestError(render != NULL, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); + EXPECT_TRUE(render != NULL); codec = webrtc::ViECodec::GetInterface(video_engine); - numberOfErrors += ViETest::TestError(codec != NULL, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); + EXPECT_TRUE(codec != NULL); network = webrtc::ViENetwork::GetInterface(video_engine); - numberOfErrors += ViETest::TestError(network != NULL, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); + EXPECT_TRUE(network != NULL); image_process = webrtc::ViEImageProcess::GetInterface(video_engine); - numberOfErrors += ViETest::TestError(image_process != NULL, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); + EXPECT_TRUE(image_process != NULL); encryption = webrtc::ViEEncryption::GetInterface(video_engine); - numberOfErrors += ViETest::TestError(encryption != NULL, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); + EXPECT_TRUE(encryption != NULL); } TbInterfaces::~TbInterfaces(void) { - int numberOfErrors = 0; - int remainingInterfaces = 0; - - remainingInterfaces = encryption->Release(); - numberOfErrors += ViETest::TestError(remainingInterfaces == 0, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); - - remainingInterfaces = image_process->Release(); - numberOfErrors += ViETest::TestError(remainingInterfaces == 0, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); - - remainingInterfaces = codec->Release(); - numberOfErrors += ViETest::TestError(remainingInterfaces == 0, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); - - remainingInterfaces = capture->Release(); - numberOfErrors += ViETest::TestError(remainingInterfaces == 0, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); - - remainingInterfaces = render->Release(); - numberOfErrors += ViETest::TestError(remainingInterfaces == 0, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); - - remainingInterfaces = rtp_rtcp->Release(); - numberOfErrors += ViETest::TestError(remainingInterfaces == 0, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); - - remainingInterfaces = network->Release(); - numberOfErrors += ViETest::TestError(remainingInterfaces == 0, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); - - remainingInterfaces = base->Release(); - numberOfErrors += ViETest::TestError(remainingInterfaces == 0, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); - - bool deleted = webrtc::VideoEngine::Delete(video_engine); - numberOfErrors += ViETest::TestError(deleted == true, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); + EXPECT_EQ(0, encryption->Release()); + EXPECT_EQ(0, image_process->Release()); + EXPECT_EQ(0, codec->Release()); + EXPECT_EQ(0, capture->Release()); + EXPECT_EQ(0, render->Release()); + EXPECT_EQ(0, rtp_rtcp->Release()); + EXPECT_EQ(0, network->Release()); + EXPECT_EQ(0, base->Release()); + EXPECT_TRUE(webrtc::VideoEngine::Delete(video_engine)) << + "Since we have released all interfaces at this point, deletion " + "should be successful."; } diff --git a/src/video_engine/test/auto_test/source/tb_video_channel.cc b/src/video_engine/test/auto_test/source/tb_video_channel.cc index 41df12691..1e62a6ba2 100644 --- a/src/video_engine/test/auto_test/source/tb_video_channel.cc +++ b/src/video_engine/test/auto_test/source/tb_video_channel.cc @@ -10,25 +10,19 @@ #include "tb_video_channel.h" -tbVideoChannel::tbVideoChannel(TbInterfaces& Engine, int& nrOfErrors, +TbVideoChannel::TbVideoChannel(TbInterfaces& Engine, webrtc::VideoCodecType sendCodec, int width, int height, int frameRate, int startBitrate) : - videoChannel(-1), numberOfErrors(nrOfErrors), ViE(Engine) + videoChannel(-1), ViE(Engine) { - int error; - error = ViE.base->CreateChannel(videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.base->CreateChannel(videoChannel)); webrtc::VideoCodec videoCodec; memset(&videoCodec, 0, sizeof(webrtc::VideoCodec)); bool sendCodecSet = false; for (int idx = 0; idx < ViE.codec->NumberOfCodecs(); idx++) { - error = ViE.codec->GetCodec(idx, videoCodec); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.codec->GetCodec(idx, videoCodec)); videoCodec.width = width; videoCodec.height = height; videoCodec.maxFramerate = frameRate; @@ -40,10 +34,7 @@ tbVideoChannel::tbVideoChannel(TbInterfaces& Engine, int& nrOfErrors, videoCodec.startBitrate = startBitrate; videoCodec.maxBitrate = startBitrate * 3; } - error = ViE.codec->SetSendCodec(videoChannel, videoCodec); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.codec->SetSendCodec(videoChannel, videoCodec)); sendCodecSet = true; } if (videoCodec.codecType == webrtc::kVideoCodecVP8) @@ -51,84 +42,49 @@ tbVideoChannel::tbVideoChannel(TbInterfaces& Engine, int& nrOfErrors, videoCodec.width = 352; videoCodec.height = 288; } - error = ViE.codec->SetReceiveCodec(videoChannel, videoCodec); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.codec->SetReceiveCodec(videoChannel, videoCodec)); } - numberOfErrors += ViETest::TestError(sendCodecSet == true, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); - + EXPECT_TRUE(sendCodecSet); } -tbVideoChannel::~tbVideoChannel(void) +TbVideoChannel::~TbVideoChannel(void) { - int error; - error = ViE.base->DeleteChannel(videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.base->DeleteChannel(videoChannel)); } -void tbVideoChannel::StartSend(const unsigned short rtpPort /*= 11000*/, +void TbVideoChannel::StartSend(const unsigned short rtpPort /*= 11000*/, const char* ipAddress /*= "127.0.0.1"*/) { - int error; - error = ViE.network->SetSendDestination(videoChannel, ipAddress, - rtpPort); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.network->SetSendDestination(videoChannel, ipAddress, + rtpPort)); - error = ViE.base->StartSend(videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.base->StartSend(videoChannel)); } -void tbVideoChannel::SetFrameSettings(int width, int height, int frameRate) +void TbVideoChannel::SetFrameSettings(int width, int height, int frameRate) { - int error; webrtc::VideoCodec videoCodec; - error = ViE.codec->GetSendCodec(videoChannel, videoCodec); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.codec->GetSendCodec(videoChannel, videoCodec)); videoCodec.width = width; videoCodec.height = height; videoCodec.maxFramerate = frameRate; - error = ViE.codec->SetSendCodec(videoChannel, videoCodec); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ViE.codec->SetReceiveCodec(videoChannel, videoCodec); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - + EXPECT_EQ(0, ViE.codec->SetSendCodec(videoChannel, videoCodec)); + EXPECT_EQ(0, ViE.codec->SetReceiveCodec(videoChannel, videoCodec)); } -void tbVideoChannel::StopSend() + +void TbVideoChannel::StopSend() { - int error; - error = ViE.base->StopSend(videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.base->StopSend(videoChannel)); } -void tbVideoChannel::StartReceive(const unsigned short rtpPort /*= 11000*/) +void TbVideoChannel::StartReceive(const unsigned short rtpPort /*= 11000*/) { - int error; - - error = ViE.network->SetLocalReceiver(videoChannel, rtpPort); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ViE.base->StartReceive(videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.network->SetLocalReceiver(videoChannel, rtpPort)); + EXPECT_EQ(0, ViE.base->StartReceive(videoChannel)); } -void tbVideoChannel::StopReceive() +void TbVideoChannel::StopReceive() { - int error; - error = ViE.base->StopReceive(videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.base->StopReceive(videoChannel)); } diff --git a/src/video_engine/test/auto_test/source/vie_autotest.cc b/src/video_engine/test/auto_test/source/vie_autotest.cc index 4713938b6..8cfa5a4b5 100644 --- a/src/video_engine/test/auto_test/source/vie_autotest.cc +++ b/src/video_engine/test/auto_test/source/vie_autotest.cc @@ -21,10 +21,8 @@ FILE* ViETest::log_file_ = NULL; char* ViETest::log_str_ = NULL; -ViETest::TestErrorMode ViETest::test_error_mode_; -ViEAutoTest::ViEAutoTest(void* window1, void* window2, - ViETest::TestErrorMode testErrorMode) : +ViEAutoTest::ViEAutoTest(void* window1, void* window2) : _window1(window1), _window2(window2), _renderType(webrtc::kRenderDefault), @@ -35,8 +33,6 @@ ViEAutoTest::ViEAutoTest(void* window1, void* window2, { assert(_vrm1); assert(_vrm2); - - ViETest::Init(testErrorMode); } ViEAutoTest::~ViEAutoTest() @@ -45,71 +41,45 @@ ViEAutoTest::~ViEAutoTest() _vrm1 = NULL; webrtc::VideoRender::DestroyVideoRender(_vrm2); _vrm2 = NULL; - - ViETest::Terminate(); } -int ViEAutoTest::ViEStandardTest() +void ViEAutoTest::ViEStandardTest() { - int numErrors = 0; - numErrors += ViEBaseStandardTest(); - numErrors += ViECaptureStandardTest(); - numErrors += ViECodecStandardTest(); - numErrors += ViEEncryptionStandardTest(); - numErrors += ViEFileStandardTest(); - numErrors += ViEImageProcessStandardTest(); - numErrors += ViENetworkStandardTest(); - numErrors += ViERenderStandardTest(); - numErrors += ViERtpRtcpStandardTest(); - - if (numErrors > 0) - { - ViETest::Log("Standard Test Failed, with %d erros\n", numErrors); - return numErrors; - } - return numErrors; + ViEBaseStandardTest(); + ViECaptureStandardTest(); + ViECodecStandardTest(); + ViEEncryptionStandardTest(); + ViEFileStandardTest(); + ViEImageProcessStandardTest(); + ViENetworkStandardTest(); + ViERenderStandardTest(); + ViERtpRtcpStandardTest(); } -int ViEAutoTest::ViEExtendedTest() +void ViEAutoTest::ViEExtendedTest() { - int numErrors = 0; - numErrors += ViEBaseExtendedTest(); - numErrors += ViECaptureExtendedTest(); - numErrors += ViECodecExtendedTest(); - numErrors += ViEEncryptionExtendedTest(); - numErrors += ViEFileExtendedTest(); - numErrors += ViEImageProcessExtendedTest(); - numErrors += ViENetworkExtendedTest(); - numErrors += ViERenderExtendedTest(); - numErrors += ViERtpRtcpExtendedTest(); - - if (numErrors > 0) - { - ViETest::Log("Extended Test Failed, with %d erros\n", numErrors); - return numErrors; - } - return numErrors; + ViEBaseExtendedTest(); + ViECaptureExtendedTest(); + ViECodecExtendedTest(); + ViEEncryptionExtendedTest(); + ViEFileExtendedTest(); + ViEImageProcessExtendedTest(); + ViENetworkExtendedTest(); + ViERenderExtendedTest(); + ViERtpRtcpExtendedTest(); } -int ViEAutoTest::ViEAPITest() +void ViEAutoTest::ViEAPITest() { - int numErrors = 0; - numErrors += ViEBaseAPITest(); - numErrors += ViECaptureAPITest(); - numErrors += ViECodecAPITest(); - numErrors += ViEEncryptionAPITest(); - numErrors += ViEFileAPITest(); - numErrors += ViEImageProcessAPITest(); - numErrors += ViENetworkAPITest(); - numErrors += ViERenderAPITest(); - numErrors += ViERtpRtcpAPITest(); - - if (numErrors > 0) - { - ViETest::Log("API Test Failed, with %d erros\n", numErrors); - return numErrors; - } - return 0; + ViEBaseAPITest(); + ViECaptureAPITest(); + ViECodecAPITest(); + ViEEncryptionAPITest(); + ViEFileAPITest(); + ViEImageProcessAPITest(); + ViENetworkAPITest(); + ViERenderAPITest(); + ViERtpRtcpAPITest(); } void ViEAutoTest::PrintVideoCodec(const webrtc::VideoCodec videoCodec) diff --git a/src/video_engine/test/auto_test/source/vie_autotest_base.cc b/src/video_engine/test/auto_test/source/vie_autotest_base.cc index 7fed82a41..af986009a 100644 --- a/src/video_engine/test/auto_test/source/vie_autotest_base.cc +++ b/src/video_engine/test/auto_test/source/vie_autotest_base.cc @@ -27,26 +27,18 @@ class BaseObserver : public webrtc::ViEBaseObserver { unsigned int cpu_load_; }; -int ViEAutoTest::ViEBaseStandardTest() { - ViETest::Log(" "); - ViETest::Log("========================================"); - ViETest::Log(" ViEBase Standard Test"); - +void ViEAutoTest::ViEBaseStandardTest() { // *************************************************************** // Begin create/initialize WebRTC Video Engine for testing // *************************************************************** - int number_of_errors = 0; - - TbInterfaces interfaces("ViEBaseStandardTest", number_of_errors); + TbInterfaces interfaces("ViEBaseStandardTest"); // *************************************************************** // Engine ready. Set up the test case: // *************************************************************** int video_channel = -1; - int error = interfaces.base->CreateChannel(video_channel); - number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, interfaces.base->CreateChannel(video_channel)); webrtc::VideoCaptureModule* video_capture_module(NULL); const unsigned int kMaxDeviceNameLength = 128; @@ -62,294 +54,152 @@ int ViEAutoTest::ViEBaseStandardTest() { device_name, kMaxDeviceNameLength, &capture_id, - &number_of_errors, &video_capture_module); - error = capture_interface->ConnectCaptureDevice(capture_id, - video_channel); - number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, capture_interface->ConnectCaptureDevice(capture_id, + video_channel)); + EXPECT_EQ(0, capture_interface->StartCapture(capture_id)); - error = capture_interface->StartCapture(capture_id); - number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + ConfigureRtpRtcp(interfaces.rtp_rtcp, video_channel); - ConfigureRtpRtcp(interfaces.rtp_rtcp, &number_of_errors, video_channel); + EXPECT_EQ(0, render_interface->RegisterVideoRenderModule(*_vrm1)); + EXPECT_EQ(0, render_interface->RegisterVideoRenderModule(*_vrm2)); - error = render_interface->RegisterVideoRenderModule(*_vrm1); - number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = render_interface->RegisterVideoRenderModule(*_vrm2); - number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - RenderInWindow(render_interface, &number_of_errors, capture_id, - _window1, 0); - RenderInWindow(render_interface, &number_of_errors, video_channel, - _window2, 1); + RenderInWindow(render_interface, capture_id, _window1, 0); + RenderInWindow(render_interface, video_channel, _window2, 1); // *************************************************************** // Run the actual test: // *************************************************************** - TestI420CallSetup(interfaces.codec, interfaces.video_engine, - base_interface, interfaces.network, &number_of_errors, - video_channel, device_name); + ::TestI420CallSetup(interfaces.codec, interfaces.video_engine, + base_interface, interfaces.network, video_channel, + device_name); // *************************************************************** // Testing finished. Tear down Video Engine // *************************************************************** - error = capture_interface->StopCapture(capture_id); - number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = base_interface->StopReceive(video_channel); - number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, capture_interface->StopCapture(capture_id)); + EXPECT_EQ(0, base_interface->StopReceive(video_channel)); - StopAndRemoveRenderers(base_interface, render_interface, &number_of_errors, - video_channel, capture_id); + StopAndRemoveRenderers(base_interface, render_interface, video_channel, + capture_id); - error = render_interface->DeRegisterVideoRenderModule(*_vrm1); - number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = render_interface->DeRegisterVideoRenderModule(*_vrm2); - number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, render_interface->DeRegisterVideoRenderModule(*_vrm1)); + EXPECT_EQ(0, render_interface->DeRegisterVideoRenderModule(*_vrm2)); - error = capture_interface->ReleaseCaptureDevice(capture_id); - number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, capture_interface->ReleaseCaptureDevice(capture_id)); video_capture_module->Release(); video_capture_module = NULL; - error = base_interface->DeleteChannel(video_channel); - number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - if (number_of_errors > 0) { - // Test failed - ViETest::Log(" "); - ViETest::Log(" ERROR ViEBase Standard Test FAILED!"); - ViETest::Log(" Number of errors: %d", number_of_errors); - ViETest::Log("========================================"); - ViETest::Log(" "); - return number_of_errors; - } - - ViETest::Log(" "); - ViETest::Log(" ViEBase Standard Test PASSED!"); - ViETest::Log("========================================"); - ViETest::Log(" "); - return 0; + EXPECT_EQ(0, base_interface->DeleteChannel(video_channel)); } -int ViEAutoTest::ViEBaseExtendedTest() { +void ViEAutoTest::ViEBaseExtendedTest() { // Start with standard test ViEBaseAPITest(); ViEBaseStandardTest(); - ViETest::Log(" "); - ViETest::Log("========================================"); - ViETest::Log(" ViEBase Extended Test"); - // *************************************************************** // Test BaseObserver // *************************************************************** // TODO(mflodman) Add test for base observer. Cpu load must be over 75%. // BaseObserver base_observer; -// error = ptrViEBase->RegisterObserver(base_observer); -// numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", -// __FUNCTION__, __LINE__); +// EXPECT_EQ(ptrViEBase->RegisterObserver(base_observer), 0); // // AutoTestSleep(KAutoTestSleepTimeMs); // -// error = ptrViEBase->DeregisterObserver(); -// numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", -// __FUNCTION__, __LINE__); -// numberOfErrors += ViETest::TestError(base_observer.cpu_load_ > 0, -// "ERROR: %s at line %d", -// __FUNCTION__, __LINE__); - - ViETest::Log(" "); - ViETest::Log(" ViEBase Extended Test PASSED!"); - ViETest::Log("========================================"); - ViETest::Log(" "); - - return 0; +// EXPECT_EQ(ptrViEBase->DeregisterObserver(), 0); +// EXPECT_GT(base_observer.cpu_load, 0); } -int ViEAutoTest::ViEBaseAPITest() { - ViETest::Log(" "); - ViETest::Log("========================================"); - ViETest::Log(" ViEBase API Test"); - +void ViEAutoTest::ViEBaseAPITest() { // *************************************************************** // Begin create/initialize WebRTC Video Engine for testing // *************************************************************** - int error = 0; - int numberOfErrors = 0; - - webrtc::VideoEngine* ptrViE = NULL; - webrtc::ViEBase* ptrViEBase = NULL; - // Get the ViEBase API - ptrViEBase = webrtc::ViEBase::GetInterface(ptrViE); - numberOfErrors += ViETest::TestError(ptrViEBase == NULL); + webrtc::ViEBase* ptrViEBase = webrtc::ViEBase::GetInterface(NULL); + EXPECT_EQ(NULL, ptrViEBase) << "Should return null for a bad ViE pointer"; - ptrViE = webrtc::VideoEngine::Create(); - numberOfErrors += ViETest::TestError(ptrViE != NULL, "VideoEngine::Create"); + webrtc::VideoEngine* ptrViE = webrtc::VideoEngine::Create(); + EXPECT_TRUE(NULL != ptrViE); #ifdef WEBRTC_ANDROID - error = video_engine->SetTraceFile("/sdcard/WebRTC/ViEBaseAPI_trace.txt"); - numberOfErrors += ViETest::TestError(error == 0, "SetTraceFile error"); + EXPECT_EQ(0, + video_engine->SetTraceFile("/sdcard/WebRTC/ViEBaseAPI_trace.txt")); #else - error = ptrViE->SetTraceFile("ViEBaseAPI_trace.txt"); - numberOfErrors += ViETest::TestError(error == 0, "SetTraceFile error"); + EXPECT_EQ(0, ptrViE->SetTraceFile("ViEBaseAPI_trace.txt")); #endif ptrViEBase = webrtc::ViEBase::GetInterface(ptrViE); - numberOfErrors += ViETest::TestError(ptrViEBase != NULL); + EXPECT_TRUE(NULL != ptrViEBase); // *************************************************************** // Engine ready. Begin testing class // *************************************************************** - char version[1024] = ""; - error = ptrViEBase->GetVersion(version); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ptrViEBase->LastError(); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ptrViEBase->GetVersion(version)); + EXPECT_EQ(0, ptrViEBase->LastError()); // Create without init int videoChannel = -1; - error = ptrViEBase->CreateChannel(videoChannel); - numberOfErrors += ViETest::TestError(error != 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ptrViEBase->Init(); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ptrViEBase->CreateChannel(videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_NE(0, ptrViEBase->CreateChannel(videoChannel)) << + "Should fail since Init has not been called yet"; + EXPECT_EQ(0, ptrViEBase->Init()); + EXPECT_EQ(0, ptrViEBase->CreateChannel(videoChannel)); int videoChannel2 = -1; - error = ptrViEBase->CreateChannel(videoChannel2); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError(videoChannel != videoChannel2, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); + EXPECT_EQ(0, ptrViEBase->CreateChannel(videoChannel2)); + EXPECT_NE(videoChannel, videoChannel2) << + "Should allocate new number for independent channel"; - error = ptrViEBase->DeleteChannel(videoChannel2); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ptrViEBase->DeleteChannel(videoChannel2)); - // Channel doesn't exist - error = ptrViEBase->CreateChannel(videoChannel2, videoChannel + 1); - numberOfErrors += ViETest::TestError(error == -1, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(-1, ptrViEBase->CreateChannel(videoChannel2, videoChannel + 1)) << + "Should fail since neither channel exists (the second must)"; - // Channel doesn't exist - error = ptrViEBase->CreateChannel(videoChannel2, videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ptrViEBase->CreateChannel(videoChannel2, videoChannel)); - // VoiceEngine + // Test Voice Engine integration with Video Engine. webrtc::VoiceEngine* ptrVoE = NULL; webrtc::VoEBase* ptrVoEBase = NULL; int audioChannel = -1; ptrVoE = webrtc::VoiceEngine::Create(); - numberOfErrors += ViETest::TestError(ptrVoE != NULL, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); + EXPECT_TRUE(NULL != ptrVoE); ptrVoEBase = webrtc::VoEBase::GetInterface(ptrVoE); - numberOfErrors += ViETest::TestError(ptrVoEBase != NULL, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); - - error = ptrVoEBase->Init(); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_TRUE(NULL != ptrVoEBase); + EXPECT_EQ(0, ptrVoEBase->Init()); audioChannel = ptrVoEBase->CreateChannel(); - numberOfErrors += ViETest::TestError(audioChannel != -1, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); + EXPECT_NE(-1, audioChannel); - // Connect before setting VoE - error = ptrViEBase->ConnectAudioChannel(videoChannel, audioChannel); - numberOfErrors += ViETest::TestError(error != 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + // Connect before setting VoE. + EXPECT_NE(0, ptrViEBase->ConnectAudioChannel(videoChannel, audioChannel)) << + "Should fail since Voice Engine is not set yet."; - error = ptrViEBase->SetVoiceEngine(ptrVoE); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ptrViEBase->ConnectAudioChannel(videoChannel, audioChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + // Then do it right. + EXPECT_EQ(0, ptrViEBase->SetVoiceEngine(ptrVoE)); + EXPECT_EQ(0, ptrViEBase->ConnectAudioChannel(videoChannel, audioChannel)); // *************************************************************** // Testing finished. Tear down Video Engine // *************************************************************** - error = ptrViEBase->DisconnectAudioChannel(videoChannel + 5); - numberOfErrors += ViETest::TestError(error != 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_NE(0, ptrViEBase->DisconnectAudioChannel(videoChannel + 5)) << + "Should fail: disconnecting bogus channel"; - error = ptrViEBase->DisconnectAudioChannel(videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ptrViEBase->SetVoiceEngine(NULL); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ptrViEBase->DisconnectAudioChannel(videoChannel)); + EXPECT_EQ(0, ptrViEBase->SetVoiceEngine(NULL)); webrtc::ViEBase* ptrViEBase2 = webrtc::ViEBase::GetInterface(ptrViE); - numberOfErrors += ViETest::TestError(ptrViEBase2 != NULL, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); + EXPECT_TRUE(NULL != ptrViEBase2); - int remainingInterfaces = ptrViEBase->Release(); - numberOfErrors += ViETest::TestError(remainingInterfaces == 1, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); + EXPECT_EQ(1, ptrViEBase->Release()) << "There should be one interface left."; - bool vieDeleted = webrtc::VideoEngine::Delete(ptrViE); - numberOfErrors += ViETest::TestError(vieDeleted == false, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); + EXPECT_FALSE(webrtc::VideoEngine::Delete(ptrViE)) << + "Should fail since there are interfaces left."; - remainingInterfaces = ptrViEBase->Release(); - numberOfErrors += ViETest::TestError(remainingInterfaces == 0, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); - - vieDeleted = webrtc::VideoEngine::Delete(ptrViE); - numberOfErrors += ViETest::TestError(vieDeleted == true, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); - - if (numberOfErrors > 0) { - ViETest::Log(" "); - ViETest::Log(" ERROR ViEBase API Test FAILED! "); - ViETest::Log(" Number of errors: %d", numberOfErrors); - ViETest::Log("========================================"); - ViETest::Log(" "); - - return numberOfErrors; - } - - ViETest::Log(" "); - ViETest::Log(" ViEBase API Test PASSED!"); - ViETest::Log("========================================"); - ViETest::Log(" "); - - return 0; + EXPECT_EQ(0, ptrViEBase->Release()); + EXPECT_TRUE(webrtc::VideoEngine::Delete(ptrViE)); } diff --git a/src/video_engine/test/auto_test/source/vie_autotest_capture.cc b/src/video_engine/test/auto_test/source/vie_autotest_capture.cc index c35245083..7ed0b5e21 100644 --- a/src/video_engine/test/auto_test/source/vie_autotest_capture.cc +++ b/src/video_engine/test/auto_test/source/vie_autotest_capture.cc @@ -85,73 +85,56 @@ public: unsigned char _frameRate; }; -class CaptureEffectFilter: public webrtc::ViEEffectFilter +class CaptureEffectFilter: public webrtc::ViEEffectFilter { + public: + CaptureEffectFilter(unsigned int expected_width, unsigned int expected_height) + : number_of_captured_frames_(0), + expected_width_(expected_width), + expected_height_(expected_height) { + } + + // Implements ViEEffectFilter + virtual int Transform(int size, unsigned char* frameBuffer, + unsigned int timeStamp90KHz, unsigned int width, + unsigned int height) { + EXPECT_TRUE(frameBuffer != NULL); + EXPECT_EQ(expected_width_, width); + EXPECT_EQ(expected_height_, height); + ++number_of_captured_frames_; + return 0; + } + + int number_of_captured_frames_; + + protected: + unsigned int expected_width_; + unsigned int expected_height_; + }; + +void ViEAutoTest::ViECaptureStandardTest() { -public: - CaptureEffectFilter(unsigned int reqWidth, unsigned int reqHeight, - int& numberOfErrors) : - _numberOfCapturedFrames(0), - _reqWidth(reqWidth), - _reqHeight(reqHeight), - _numberOfErrors(numberOfErrors) - { - } - // Implements ViEEffectFilter - virtual int Transform(int size, unsigned char* frameBuffer, - unsigned int timeStamp90KHz, unsigned int width, - unsigned int height) - { - _numberOfErrors += ViETest::TestError( - frameBuffer != 0 - && width == _reqWidth - && height == _reqHeight, - "ERROR: %s at line %d", __FUNCTION__, __LINE__); - ++_numberOfCapturedFrames; - return 0; - } - - int _numberOfCapturedFrames; - -protected: - unsigned int _reqWidth; - unsigned int _reqHeight; - int& _numberOfErrors; -}; - -int ViEAutoTest::ViECaptureStandardTest() -{ - int numberOfErrors = 0; - ViETest::Log(" "); - ViETest::Log("========================================"); - ViETest::Log(" ViECapture StandardTest Test\n"); - //*************************************************************** // Begin create/initialize WebRTC Video Engine for testing //*************************************************************** - //*************************************************************** // Engine ready. Begin testing class //*************************************************************** - - int error = 0; - TbInterfaces ViE("ViECaptureStandardTest", numberOfErrors); + TbInterfaces ViE("ViECaptureStandardTest"); webrtc::VideoCaptureModule::DeviceInfo* devInfo = webrtc::VideoCaptureFactory::CreateDeviceInfo(0); int numberOfCaptureDevices = devInfo->NumberOfDevices(); ViETest::Log("Number of capture devices %d", numberOfCaptureDevices); - numberOfErrors += ViETest::TestError(numberOfCaptureDevices > 0, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); + EXPECT_GT(numberOfCaptureDevices, 0); int captureDeviceId[10]; webrtc::VideoCaptureModule* vcpms[10]; memset(vcpms, 0, sizeof(vcpms)); - //Check capabilities + // Check capabilities for (int deviceIndex = 0; deviceIndex < numberOfCaptureDevices; ++deviceIndex) @@ -159,42 +142,33 @@ int ViEAutoTest::ViECaptureStandardTest() WebRtc_UWord8 deviceName[128]; WebRtc_UWord8 deviceUniqueName[512]; - error = devInfo->GetDeviceName(deviceIndex, deviceName, - sizeof(deviceName), deviceUniqueName, - sizeof(deviceUniqueName)); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, devInfo->GetDeviceName(deviceIndex, + deviceName, + sizeof(deviceName), + deviceUniqueName, + sizeof(deviceUniqueName))); ViETest::Log("Found capture device %s\nUnique name %s", deviceName, deviceUniqueName); -// not supported on MAC (is part of capture capabilites +// not supported on MAC (is part of capture capabilities) #if !defined(WEBRTC_LINUX) && !defined(WEBRTC_MAC_INTEL) - error = ViE.capture->ShowCaptureSettingsDialogBox( - (char*) deviceUniqueName, - (unsigned int) (strlen((char*) deviceUniqueName)), - "WebRTCViECapture StandardTest"); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, + ViE.capture->ShowCaptureSettingsDialogBox( + (char*) deviceUniqueName, + (unsigned int) (strlen((char*) deviceUniqueName)), + "WebRTCViECapture StandardTest")); #endif -#if !defined(WEBRTC_MAC_INTEL) // these functions will return -1 - unsigned int numberOfCapabilities = +#if !defined(WEBRTC_MAC_INTEL) // these functions will return -1 + int numberOfCapabilities = devInfo->NumberOfCapabilities(deviceUniqueName); - numberOfErrors += ViETest::TestError(numberOfCapabilities > 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_GT(numberOfCapabilities, 0); - for (unsigned int capIndex = 0; - capIndex < numberOfCapabilities; - ++capIndex) + for (int capIndex = 0; capIndex < numberOfCapabilities; ++capIndex) { webrtc::VideoCaptureCapability capability; - error = devInfo->GetCapability(deviceUniqueName, capIndex, - capability); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, devInfo->GetCapability(deviceUniqueName, capIndex, + capability)); ViETest::Log("Capture capability %d (of %u)", capIndex + 1, numberOfCapabilities); ViETest::Log("witdh %d, height %d, frame rate %d", @@ -202,12 +176,11 @@ int ViEAutoTest::ViECaptureStandardTest() ViETest::Log("expected delay %d, color type %d, encoding %d", capability.expectedCaptureDelay, capability.rawType, capability.codecType); - numberOfErrors += ViETest::TestError( - capability.width > 0 - && capability.height > 0 - && capability.maxFPS >= 0 - && capability.expectedCaptureDelay > 0, - "ERROR: %s at line %d", __FUNCTION__, __LINE__); + + EXPECT_GT(capability.width, 0); + EXPECT_GT(capability.height, 0); + EXPECT_GT(capability.maxFPS, -1); // >= 0 + EXPECT_GT(capability.expectedCaptureDelay, 0); } #endif } @@ -222,39 +195,30 @@ int ViEAutoTest::ViECaptureStandardTest() WebRtc_UWord8 deviceName[128]; WebRtc_UWord8 deviceUniqueName[512]; - error = devInfo->GetDeviceName(deviceIndex, deviceName, - sizeof(deviceName), deviceUniqueName, - sizeof(deviceUniqueName)); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, devInfo->GetDeviceName(deviceIndex, + deviceName, + sizeof(deviceName), + deviceUniqueName, + sizeof(deviceUniqueName))); webrtc::VideoCaptureModule* vcpm = webrtc::VideoCaptureFactory::Create( deviceIndex, deviceUniqueName); + EXPECT_TRUE(vcpm != NULL); vcpm->AddRef(); - numberOfErrors += ViETest::TestError(vcpm != NULL, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); vcpms[deviceIndex] = vcpm; - error = ViE.capture->AllocateCaptureDevice( - *vcpm, captureDeviceId[deviceIndex]); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.capture->AllocateCaptureDevice( + *vcpm, captureDeviceId[deviceIndex])); webrtc::VideoCaptureCapability capability; - error = devInfo->GetCapability(deviceUniqueName, 0, capability); + EXPECT_EQ(0, devInfo->GetCapability(deviceUniqueName, 0, capability)); // Test that the camera select the closest capability to the selected // width and height. - CaptureEffectFilter filter(capability.width, capability.height, - numberOfErrors); - error = ViE.image_process->RegisterCaptureEffectFilter( - captureDeviceId[deviceIndex], filter); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + CaptureEffectFilter filter(capability.width, capability.height); + EXPECT_EQ(0, ViE.image_process->RegisterCaptureEffectFilter( + captureDeviceId[deviceIndex], filter)); ViETest::Log("Testing Device %s capability width %d height %d", deviceUniqueName, capability.width, capability.height); @@ -273,31 +237,26 @@ int ViEAutoTest::ViECaptureStandardTest() vieCapability.maxFPS = capability.maxFPS; vieCapability.rawType = capability.rawType; - error = ViE.capture->StartCapture(captureDeviceId[deviceIndex], - vieCapability); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.capture->StartCapture(captureDeviceId[deviceIndex], + vieCapability)); webrtc::TickTime startTime = webrtc::TickTime::Now(); - while (filter._numberOfCapturedFrames < 10 + while (filter.number_of_captured_frames_ < 10 && (webrtc::TickTime::Now() - startTime).Milliseconds() < 10000) { AutoTestSleep(100); } - numberOfErrors += ViETest::TestError(filter._numberOfCapturedFrames - >= 10, "ERROR: %s at line %d", __FUNCTION__, __LINE__); - error = ViE.image_process->DeregisterCaptureEffectFilter( - captureDeviceId[deviceIndex]); -#ifdef WEBRTC_ANDROID // Can only allocate one camera at the time on Android - error = ViE.capture->StopCapture(captureDeviceId[deviceIndex]); - numberOfErrors += ViETest::TestError(error==0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_GT(filter.number_of_captured_frames_, 9) << + "Should capture at least some frames"; - error = ViE.capture->ReleaseCaptureDevice( - captureDeviceId[deviceIndex]); - numberOfErrors += ViETest::TestError(error==0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.image_process->DeregisterCaptureEffectFilter( + captureDeviceId[deviceIndex])); + +#ifdef WEBRTC_ANDROID // Can only allocate one camera at the time on Android. + EXPECT_EQ(0, ViE.capture->StopCapture(captureDeviceId[deviceIndex])); + EXPECT_EQ(0, ViE.capture->ReleaseCaptureDevice( + captureDeviceId[deviceIndex])); #endif } @@ -306,84 +265,38 @@ int ViEAutoTest::ViECaptureStandardTest() //*************************************************************** - // stop all started capture devices - for (int deviceIndex = 0; deviceIndex < numberOfCaptureDevices; ++deviceIndex) - { - error = ViE.capture->StopCapture(captureDeviceId[deviceIndex]); -#ifdef WEBRTC_ANDROID - // Camera already stoped on Android since we can only allocate one - // camera at the time. - numberOfErrors += ViETest::TestError(error==-1, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); -#else - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); -#endif - - error = ViE.capture->ReleaseCaptureDevice( - captureDeviceId[deviceIndex]); -#ifdef WEBRTC_ANDROID - // Camera already stoped on Android since we can only allocate one - // camera at the time - numberOfErrors += ViETest::TestError(error==-1, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); -#else - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); -#endif - vcpms[deviceIndex]->Release(); + // Stop all started capture devices. + for (int deviceIndex = 0; + deviceIndex < numberOfCaptureDevices; + ++deviceIndex) { +#if !defined(WEBRTC_ANDROID) + // Don't stop on Android since we can only allocate one camera. + EXPECT_EQ(0, ViE.capture->StopCapture( + captureDeviceId[deviceIndex])); + EXPECT_EQ(0, ViE.capture->ReleaseCaptureDevice( + captureDeviceId[deviceIndex])); +#endif // !WEBRTC_ANDROID + vcpms[deviceIndex]->Release(); } -#endif - if (numberOfErrors > 0) - { - // Test failed - ViETest::Log(" "); - ViETest::Log(" ERROR ViECapture Standard Test FAILED!"); - ViETest::Log(" Number of errors: %d", numberOfErrors); - ViETest::Log("========================================"); - ViETest::Log(" "); - return numberOfErrors; - } - delete devInfo; - - ViETest::Log(" "); - ViETest::Log(" ViECapture Standard Test PASSED!"); - ViETest::Log("========================================"); - ViETest::Log(" "); - - return 0; +#endif // !WEBRTC_MAC_INTEL } -int ViEAutoTest::ViECaptureExtendedTest() -{ - - // Test - int numberOfErrors = 0; - numberOfErrors += ViECaptureStandardTest(); - numberOfErrors += ViECaptureAPITest(); - numberOfErrors += ViECaptureExternalCaptureTest(); - - return 0; +void ViEAutoTest::ViECaptureExtendedTest() { + ViECaptureStandardTest(); + ViECaptureAPITest(); + ViECaptureExternalCaptureTest(); } -int ViEAutoTest::ViECaptureAPITest() +void ViEAutoTest::ViECaptureAPITest() { - int numberOfErrors = 0; - ViETest::Log(" "); - ViETest::Log("========================================"); - ViETest::Log(" ViECapture API Test\n"); - //*************************************************************** // Begin create/initialize WebRTC Video Engine for testing //*************************************************************** - //*************************************************************** // Engine ready. Begin testing class //*************************************************************** - - int error = 0; - TbInterfaces ViE("ViECaptureAPITest", numberOfErrors); + TbInterfaces ViE("ViECaptureAPITest"); ViE.capture->NumberOfCaptureDevices(); @@ -393,292 +306,165 @@ int ViEAutoTest::ViECaptureAPITest() webrtc::VideoCaptureModule::DeviceInfo* devInfo = webrtc::VideoCaptureFactory::CreateDeviceInfo(0); - numberOfErrors += ViETest::TestError(devInfo != NULL, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); + EXPECT_TRUE(devInfo != NULL); // Get the first capture device - error = devInfo->GetDeviceName(0, deviceName, sizeof(deviceName), - deviceUniqueName, sizeof(deviceUniqueName)); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, devInfo->GetDeviceName(0, deviceName, + sizeof(deviceName), + deviceUniqueName, + sizeof(deviceUniqueName))); webrtc::VideoCaptureModule* vcpm = - webrtc::VideoCaptureFactory::Create( - 0, deviceUniqueName); + webrtc::VideoCaptureFactory::Create(0, deviceUniqueName); vcpm->AddRef(); - numberOfErrors += ViETest::TestError(vcpm != NULL, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_TRUE(vcpm != NULL); - // Allocate capture device - error = ViE.capture->AllocateCaptureDevice(*vcpm, captureId); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + // Allocate capture device. + EXPECT_EQ(0, ViE.capture->AllocateCaptureDevice(*vcpm, captureId)); - // Start the capture device - error = ViE.capture->StartCapture(captureId); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + // Start the capture device. + EXPECT_EQ(0, ViE.capture->StartCapture(captureId)); - // Start again. Should fail - error = ViE.capture->StartCapture(captureId); - numberOfErrors += ViETest::TestError(error == -1, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError(ViE.LastError() - == kViECaptureDeviceAlreadyStarted, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + // Start again. Should fail. + EXPECT_NE(0, ViE.capture->StartCapture(captureId)); + EXPECT_EQ(kViECaptureDeviceAlreadyStarted, ViE.LastError()); - // Start invalid capture device - error = ViE.capture->StartCapture(captureId + 1); - numberOfErrors += ViETest::TestError(error == -1, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError(ViE.LastError() - == kViECaptureDeviceDoesnNotExist, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + // Start invalid capture device. + EXPECT_NE(0, ViE.capture->StartCapture(captureId + 1)); + EXPECT_EQ(kViECaptureDeviceDoesNotExist, ViE.LastError()); - // Stop invalide capture device - error = ViE.capture->StopCapture(captureId + 1); - numberOfErrors += ViETest::TestError(error == -1, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError(ViE.LastError() - == kViECaptureDeviceDoesnNotExist, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + // Stop invalid capture device. + EXPECT_NE(0, ViE.capture->StopCapture(captureId + 1)); + EXPECT_EQ(kViECaptureDeviceDoesNotExist, ViE.LastError()); - // Stop the capture device - error = ViE.capture->StopCapture(captureId); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + // Stop the capture device. + EXPECT_EQ(0, ViE.capture->StopCapture(captureId)); - // Stop the capture device again - error = ViE.capture->StopCapture(captureId); - numberOfErrors += ViETest::TestError(error == -1, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError(ViE.LastError() - == kViECaptureDeviceNotStarted, "ERROR: %s at line %d", __FUNCTION__, - __LINE__); + // Stop the capture device again. + EXPECT_NE(0, ViE.capture->StopCapture(captureId)); + EXPECT_EQ(kViECaptureDeviceNotStarted, ViE.LastError()); - // Connect to invalid channel - error = ViE.capture->ConnectCaptureDevice(captureId, 0); - numberOfErrors += ViETest::TestError(error == -1, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError(ViE.LastError() - == kViECaptureDeviceInvalidChannelId, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + // Connect to invalid channel. + EXPECT_NE(0, ViE.capture->ConnectCaptureDevice(captureId, 0)); + EXPECT_EQ(kViECaptureDeviceInvalidChannelId, ViE.LastError()); - tbVideoChannel channel(ViE, numberOfErrors); + TbVideoChannel channel(ViE); - // Connect invalid captureId - error = ViE.capture->ConnectCaptureDevice(captureId + 1, - channel.videoChannel); - numberOfErrors += ViETest::TestError(error == -1, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError(ViE.LastError() - == kViECaptureDeviceDoesnNotExist, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); + // Connect invalid captureId. + EXPECT_NE(0, ViE.capture->ConnectCaptureDevice(captureId + 1, + channel.videoChannel)); + EXPECT_EQ(kViECaptureDeviceDoesNotExist, ViE.LastError()); - // Connect the capture device to the channel - error = ViE.capture->ConnectCaptureDevice(captureId, - channel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + // Connect the capture device to the channel. + EXPECT_EQ(0, ViE.capture->ConnectCaptureDevice(captureId, + channel.videoChannel)); - // Connect the channel again - error = ViE.capture->ConnectCaptureDevice(captureId, - channel.videoChannel); - numberOfErrors += ViETest::TestError(error == -1, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError(ViE.LastError() - == kViECaptureDeviceAlreadyConnected, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + // Connect the channel again. + EXPECT_NE(0, ViE.capture->ConnectCaptureDevice(captureId, + channel.videoChannel)); + EXPECT_EQ(kViECaptureDeviceAlreadyConnected, ViE.LastError()); - // Start the capture device - error = ViE.capture->StartCapture(captureId); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + // Start the capture device. + EXPECT_EQ(0, ViE.capture->StartCapture(captureId)); // Release invalid capture device. - error = ViE.capture->ReleaseCaptureDevice(captureId + 1); - numberOfErrors += ViETest::TestError(error == -1, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError(ViE.LastError() - == kViECaptureDeviceDoesnNotExist, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_NE(0, ViE.capture->ReleaseCaptureDevice(captureId + 1)); + EXPECT_EQ(kViECaptureDeviceDoesNotExist, ViE.LastError()); - // Release the capture device - error = ViE.capture->ReleaseCaptureDevice(captureId); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + // Release the capture device. + EXPECT_EQ(0, ViE.capture->ReleaseCaptureDevice(captureId)); - // Release the capture device again - error = ViE.capture->ReleaseCaptureDevice(captureId); - numberOfErrors += ViETest::TestError(error == -1, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError(ViE.LastError() - == kViECaptureDeviceDoesnNotExist, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + // Release the capture device again. + EXPECT_NE(0, ViE.capture->ReleaseCaptureDevice(captureId)); + EXPECT_EQ(kViECaptureDeviceDoesNotExist, ViE.LastError()); - // Test GetOrientation + // Test GetOrientation. webrtc::VideoCaptureRotation orientation; WebRtc_UWord8 dummy_name[5]; - error = devInfo->GetOrientation(dummy_name, orientation); - numberOfErrors += ViETest::TestError(error == -1, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_NE(0, devInfo->GetOrientation(dummy_name, orientation)); - //Test SetRotation - error = ViE.capture->SetRotateCapturedFrames( - captureId, webrtc::RotateCapturedFrame_90); - numberOfErrors += ViETest::TestError(error == -1, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError( - ViE.LastError() == kViECaptureDeviceDoesnNotExist, - "ERROR: %s at line %d", __FUNCTION__, __LINE__); + // Test SetRotation. + EXPECT_NE(0, ViE.capture->SetRotateCapturedFrames( + captureId, webrtc::RotateCapturedFrame_90)); + EXPECT_EQ(kViECaptureDeviceDoesNotExist, ViE.LastError()); - // Allocate capture device - error = ViE.capture->AllocateCaptureDevice(*vcpm, captureId); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + // Allocate capture device. + EXPECT_EQ(0, ViE.capture->AllocateCaptureDevice(*vcpm, captureId)); - error = ViE.capture->SetRotateCapturedFrames( - captureId, webrtc::RotateCapturedFrame_0); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ViE.capture->SetRotateCapturedFrames( - captureId, webrtc::RotateCapturedFrame_90); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ViE.capture->SetRotateCapturedFrames( - captureId, webrtc::RotateCapturedFrame_180); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ViE.capture->SetRotateCapturedFrames( - captureId, webrtc::RotateCapturedFrame_270); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.capture->SetRotateCapturedFrames( + captureId, webrtc::RotateCapturedFrame_0)); + EXPECT_EQ(0, ViE.capture->SetRotateCapturedFrames( + captureId, webrtc::RotateCapturedFrame_90)); + EXPECT_EQ(0, ViE.capture->SetRotateCapturedFrames( + captureId, webrtc::RotateCapturedFrame_180)); + EXPECT_EQ(0, ViE.capture->SetRotateCapturedFrames( + captureId, webrtc::RotateCapturedFrame_270)); // Release the capture device - error = ViE.capture->ReleaseCaptureDevice(captureId); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - delete devInfo; - vcpm->Release(); + EXPECT_EQ(0, ViE.capture->ReleaseCaptureDevice(captureId)); //*************************************************************** // Testing finished. Tear down Video Engine //*************************************************************** - - - if (numberOfErrors > 0) - { - // Test failed - ViETest::Log(" "); - ViETest::Log(" ERROR WebRTCViECapture API Test FAILED!"); - ViETest::Log(" Number of errors: %d", numberOfErrors); - ViETest::Log("========================================"); - ViETest::Log(" "); - return numberOfErrors; - } - - ViETest::Log(" "); - ViETest::Log(" WebRTCViECapture API Test PASSED!"); - ViETest::Log("========================================"); - ViETest::Log(" "); - - return numberOfErrors; + delete devInfo; + vcpm->Release(); } -int ViEAutoTest::ViECaptureExternalCaptureTest() +void ViEAutoTest::ViECaptureExternalCaptureTest() { - int numberOfErrors = 0; - ViETest::Log(" "); - ViETest::Log("========================================"); - ViETest::Log(" WebRTCViECapture External Capture Test\n"); - //*************************************************************** // Begin create/initialize WebRTC Video Engine for testing //*************************************************************** - - int error = 0; - TbInterfaces ViE("ViECaptureExternalCaptureTest", numberOfErrors); - tbVideoChannel channel(ViE, numberOfErrors); + TbInterfaces ViE("ViECaptureExternalCaptureTest"); + TbVideoChannel channel(ViE); channel.StartReceive(); channel.StartSend(); webrtc::VideoCaptureExternal* externalCapture; int captureId = 0; - // Allocate the external capture device - webrtc::VideoCaptureModule* vcpm = - webrtc::VideoCaptureFactory::Create( - 0, externalCapture); + // Allocate the external capture device. + webrtc::VideoCaptureModule* vcpm = webrtc::VideoCaptureFactory::Create( + 0, externalCapture); + EXPECT_TRUE(vcpm != NULL); + EXPECT_TRUE(externalCapture != NULL); vcpm->AddRef(); - numberOfErrors += ViETest::TestError(vcpm != NULL, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.capture->AllocateCaptureDevice(*vcpm, captureId); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError(externalCapture != 0, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); + EXPECT_EQ(0, ViE.capture->AllocateCaptureDevice(*vcpm, captureId)); - // Connect the capture device to the channel - error = ViE.capture->ConnectCaptureDevice(captureId, - channel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + // Connect the capture device to the channel. + EXPECT_EQ(0, ViE.capture->ConnectCaptureDevice(captureId, + channel.videoChannel)); - // Render the local capture - error = ViE.render->AddRenderer(captureId, _window1, 1, 0.0, 0.0, - 1.0, 1.0); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + // Render the local capture. + EXPECT_EQ(0, ViE.render->AddRenderer(captureId, _window1, 1, 0.0, 0.0, + 1.0, 1.0)); - // Render the remote capture - error = ViE.render->AddRenderer(channel.videoChannel, _window2, 1, - 0.0, 0.0, 1.0, 1.0); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + // Render the remote capture. + EXPECT_EQ(0, ViE.render->AddRenderer(channel.videoChannel, _window2, 1, + 0.0, 0.0, 1.0, 1.0)); + EXPECT_EQ(0, ViE.render->StartRender(captureId)); + EXPECT_EQ(0, ViE.render->StartRender(channel.videoChannel)); - error = ViE.render->StartRender(captureId); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ViE.render->StartRender(channel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - // Register observer + // Register observer. CaptureObserver observer; - error = ViE.capture->RegisterObserver(captureId, observer); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.capture->RegisterObserver(captureId, observer)); - // Enable brighness alarm - error = ViE.capture->EnableBrightnessAlarm(captureId, true); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + // Enable brightness alarm. + EXPECT_EQ(0, ViE.capture->EnableBrightnessAlarm(captureId, true)); - CaptureEffectFilter effectFilter(176, 144, numberOfErrors); - error = ViE.image_process->RegisterCaptureEffectFilter(captureId, - effectFilter); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - // Call started + CaptureEffectFilter effectFilter(176, 144); + EXPECT_EQ(0, ViE.image_process->RegisterCaptureEffectFilter(captureId, + effectFilter)); + // Call started. ViETest::Log("You should see local preview from external capture\n" "in window 1 and the remote video in window 2.\n"); //*************************************************************** // Engine ready. Begin testing class //*************************************************************** - const unsigned int videoFrameLength = (176 * 144 * 3) / 2; unsigned char* videoFrame = new unsigned char[videoFrameLength]; memset(videoFrame, 128, 176 * 144); @@ -701,21 +487,17 @@ int ViEAutoTest::ViECaptureExternalCaptureTest() // while (fread(videoFrame, videoFrameLength, 1, foreman) == 1) while (frameCount < 120) { - externalCapture->IncomingFrame( videoFrame, videoFrameLength, capability, webrtc::TickTime::Now().MillisecondTimestamp()); AutoTestSleep(33); - if (effectFilter._numberOfCapturedFrames > 2) + if (effectFilter.number_of_captured_frames_ > 2) { - // make sure brigthness or no picture alarm has not been triggered - numberOfErrors += ViETest::TestError( - observer._brightness == webrtc::Normal, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError( - observer._alarm == webrtc::AlarmCleared, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(webrtc::Normal, observer._brightness) << + "Brightness or picture alarm should not have been called yet."; + EXPECT_EQ(webrtc::AlarmCleared, observer._alarm) << + "Brightness or picture alarm should not have been called yet."; } frameCount++; } @@ -737,9 +519,8 @@ int ViEAutoTest::ViECaptureExternalCaptureTest() webrtc::TickTime::Now().MillisecondTimestamp()); AutoTestSleep(33); } - numberOfErrors += ViETest::TestError(observer._brightness == webrtc::Bright, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); + EXPECT_EQ(webrtc::Bright, observer._brightness) << + "Should be bright at this point since we are using a bright image."; // Test Dark image for (int i = 0; i < 176 * 144; ++i) @@ -753,27 +534,22 @@ int ViEAutoTest::ViECaptureExternalCaptureTest() webrtc::TickTime::Now().MillisecondTimestamp()); AutoTestSleep(33); } - numberOfErrors += ViETest::TestError(observer._brightness == webrtc::Dark, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); + EXPECT_EQ(webrtc::Dark, observer._brightness) << + "Should be dark at this point since we are using a dark image."; + EXPECT_GT(effectFilter.number_of_captured_frames_, 150) << + "Frames should have been played."; - // Test that frames were played - numberOfErrors += ViETest::TestError( - effectFilter._numberOfCapturedFrames > 150, - "ERROR: %s at line %d", __FUNCTION__, __LINE__); - - // Test frame rate callback - numberOfErrors += ViETest::TestError(observer._frameRate >= 29 - && observer._frameRate <= 30, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); + EXPECT_GE(observer._frameRate, 29) << + "Frame rate callback should be approximately correct."; + EXPECT_LE(observer._frameRate, 30) << + "Frame rate callback should be approximately correct."; // Test no picture alarm ViETest::Log("Testing NoPictureAlarm."); AutoTestSleep(1050); - numberOfErrors += ViETest::TestError(observer._alarm == webrtc::AlarmRaised, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); + + EXPECT_EQ(webrtc::AlarmRaised, observer._alarm) << + "No picture alarm should be raised."; for (int frame = 0; frame < 10; ++frame) { externalCapture->IncomingFrame( @@ -781,45 +557,20 @@ int ViEAutoTest::ViECaptureExternalCaptureTest() webrtc::TickTime::Now().MillisecondTimestamp()); AutoTestSleep(33); } - numberOfErrors += ViETest::TestError( - observer._alarm == webrtc::AlarmCleared, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(webrtc::AlarmCleared, observer._alarm) << + "Alarm should be cleared since ge just got some data."; delete videoFrame; // Release the capture device - error = ViE.capture->ReleaseCaptureDevice(captureId); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.capture->ReleaseCaptureDevice(captureId)); // Release the capture device again - error = ViE.capture->ReleaseCaptureDevice(captureId); - numberOfErrors += ViETest::TestError(error == -1, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError( - ViE.LastError() == kViECaptureDeviceDoesnNotExist, - "ERROR: %s at line %d", __FUNCTION__, __LINE__); + EXPECT_NE(0, ViE.capture->ReleaseCaptureDevice(captureId)); + EXPECT_EQ(kViECaptureDeviceDoesNotExist, ViE.LastError()); vcpm->Release(); //*************************************************************** // Testing finished. Tear down Video Engine //*************************************************************** - - if (numberOfErrors > 0) - { - // Test failed - ViETest::Log(" "); - ViETest::Log(" ERROR WebRTCViECapture External Capture Test FAILED!"); - ViETest::Log(" Number of errors: %d", numberOfErrors); - ViETest::Log("========================================"); - ViETest::Log(" "); - return numberOfErrors; - } - - ViETest::Log(" "); - ViETest::Log(" WebRTCViECapture External Capture Test PASSED!"); - ViETest::Log("========================================"); - ViETest::Log(" "); - - return numberOfErrors; } diff --git a/src/video_engine/test/auto_test/source/vie_autotest_codec.cc b/src/video_engine/test/auto_test/source/vie_autotest_codec.cc index d3881e9d1..ad32761e1 100644 --- a/src/video_engine/test/auto_test/source/vie_autotest_codec.cc +++ b/src/video_engine/test/auto_test/source/vie_autotest_codec.cc @@ -19,76 +19,35 @@ #include "tb_video_channel.h" #include "vie_autotest_defines.h" -int ViEAutoTest::ViECodecStandardTest() +void ViEAutoTest::ViECodecStandardTest() { - ViETest::Log(" "); - ViETest::Log("========================================"); - ViETest::Log(" ViECodec Standard Test\n"); - - int number_of_errors = 0; - - TbInterfaces interfaces = TbInterfaces("ViECodecStandardTest", - number_of_errors); - - TbCaptureDevice capture_device = - TbCaptureDevice(interfaces, number_of_errors); + TbInterfaces interfaces = TbInterfaces("ViECodecStandardTest"); + TbCaptureDevice capture_device = TbCaptureDevice(interfaces); int video_channel = -1; - int error = interfaces.base->CreateChannel(video_channel); - ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = interfaces.capture->ConnectCaptureDevice(capture_device.captureId, - video_channel); - ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, interfaces.base->CreateChannel(video_channel)); + EXPECT_EQ(0, interfaces.capture->ConnectCaptureDevice( + capture_device.captureId, video_channel)); ConfigureRtpRtcp(interfaces.rtp_rtcp, - &number_of_errors, video_channel); - RenderInWindow(interfaces.render, &number_of_errors, - capture_device.captureId, _window1, 0); - RenderInWindow(interfaces.render, &number_of_errors, - video_channel, _window2, 1); + RenderInWindow(interfaces.render, capture_device.captureId, _window1, 0); + RenderInWindow(interfaces.render, video_channel, _window2, 1); - TestCodecs(interfaces, number_of_errors, capture_device.captureId, - video_channel, kDoNotForceResolution, kDoNotForceResolution); - - if (number_of_errors > 0) - { - // Test failed - ViETest::Log(" "); - ViETest::Log(" ERROR ViECodec Standard Test FAILED!"); - ViETest::Log(" Number of errors: %d", number_of_errors); - ViETest::Log("========================================"); - ViETest::Log(" "); - return number_of_errors; - } - - ViETest::Log(" "); - ViETest::Log(" ViECodec Standard Test PASSED!"); - ViETest::Log("========================================"); - ViETest::Log(" "); - return 0; + TestCodecs(interfaces, capture_device.captureId, video_channel, + kDoNotForceResolution, kDoNotForceResolution); } -int ViEAutoTest::ViECodecExtendedTest() +void ViEAutoTest::ViECodecExtendedTest() { - int error = 0; - int numberOfErrors = 0; - { - ViETest::Log(" "); - ViETest::Log("========================================"); - ViETest::Log(" ViECodec Extended Test\n"); + ViECodecAPITest(); + ViECodecStandardTest(); + ViECodecExternalCodecTest(); - numberOfErrors = ViECodecAPITest(); - numberOfErrors += ViECodecStandardTest(); - numberOfErrors += ViECodecExternalCodecTest(); - - TbInterfaces interfaces = TbInterfaces("ViECodecExtendedTest", - numberOfErrors); + TbInterfaces interfaces = TbInterfaces("ViECodecExtendedTest"); webrtc::ViEBase* ptrViEBase = interfaces.base; webrtc::ViECapture* ptrViECapture = interfaces.capture; webrtc::ViERender* ptrViERender = interfaces.render; @@ -96,60 +55,31 @@ int ViEAutoTest::ViECodecExtendedTest() webrtc::ViERTP_RTCP* ptrViERtpRtcp = interfaces.rtp_rtcp; webrtc::ViENetwork* ptrViENetwork = interfaces.network; - TbCaptureDevice captureDevice = TbCaptureDevice(interfaces, - numberOfErrors); + TbCaptureDevice captureDevice = TbCaptureDevice(interfaces); int captureId = captureDevice.captureId; int videoChannel = -1; - error = ptrViEBase->CreateChannel(videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ptrViEBase->CreateChannel(videoChannel)); + EXPECT_EQ(0, ptrViECapture->ConnectCaptureDevice( + captureId, videoChannel)); - error = ptrViECapture->ConnectCaptureDevice(captureId, videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ptrViERtpRtcp->SetRTCPStatus(videoChannel, - webrtc::kRtcpCompound_RFC4585); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ptrViERtpRtcp->SetKeyFrameRequestMethod( - videoChannel, webrtc::kViEKeyFrameRequestPliRtcp); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ptrViERtpRtcp->SetTMMBRStatus(videoChannel, true); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ptrViERender->AddRenderer(captureId, _window1, 0, 0.0, 0.0, - 1.0, 1.0); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ptrViERender->AddRenderer(videoChannel, _window2, 1, 0.0, 0.0, - 1.0, 1.0); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ptrViERender->StartRender(captureId); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ptrViERender->StartRender(videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ptrViERtpRtcp->SetRTCPStatus( + videoChannel, webrtc::kRtcpCompound_RFC4585)); + EXPECT_EQ(0, ptrViERtpRtcp->SetKeyFrameRequestMethod( + videoChannel, webrtc::kViEKeyFrameRequestPliRtcp)); + EXPECT_EQ(0, ptrViERtpRtcp->SetTMMBRStatus(videoChannel, true)); + EXPECT_EQ(0, ptrViERender->AddRenderer( + captureId, _window1, 0, 0.0, 0.0, 1.0, 1.0)); + EXPECT_EQ(0, ptrViERender->AddRenderer( + videoChannel, _window2, 1, 0.0, 0.0, 1.0, 1.0)); + EXPECT_EQ(0, ptrViERender->StartRender(captureId)); + EXPECT_EQ(0, ptrViERender->StartRender(videoChannel)); webrtc::VideoCodec videoCodec; memset(&videoCodec, 0, sizeof(webrtc::VideoCodec)); for (int idx = 0; idx < ptrViECodec->NumberOfCodecs(); idx++) { - error = ptrViECodec->GetCodec(idx, videoCodec); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ptrViECodec->GetCodec(idx, videoCodec)); if (videoCodec.codecType != webrtc::kVideoCodecH263 && videoCodec.codecType != webrtc::kVideoCodecI420) @@ -157,81 +87,37 @@ int ViEAutoTest::ViECodecExtendedTest() videoCodec.width = 640; videoCodec.height = 480; } - error = ptrViECodec->SetReceiveCodec(videoChannel, videoCodec); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ptrViECodec->SetReceiveCodec( + videoChannel, videoCodec)); } const char* ipAddress = "127.0.0.1"; const unsigned short rtpPort = 6000; - error = ptrViENetwork->SetLocalReceiver(videoChannel, rtpPort); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ptrViEBase->StartReceive(videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ptrViENetwork->SetSendDestination(videoChannel, ipAddress, - rtpPort); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ptrViEBase->StartSend(videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ptrViENetwork->SetLocalReceiver(videoChannel, rtpPort)); + EXPECT_EQ(0, ptrViEBase->StartReceive(videoChannel)); + EXPECT_EQ(0, ptrViENetwork->SetSendDestination( + videoChannel, ipAddress, rtpPort)); + EXPECT_EQ(0, ptrViEBase->StartSend(videoChannel)); // // Codec specific tests // memset(&videoCodec, 0, sizeof(webrtc::VideoCodec)); - error = ptrViEBase->StopSend(videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - + EXPECT_EQ(0, ptrViEBase->StopSend(videoChannel)); ViEAutotestCodecObserver codecObserver; - error = ptrViECodec->RegisterEncoderObserver(videoChannel, - codecObserver); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ptrViECodec->RegisterDecoderObserver(videoChannel, - codecObserver); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ptrViECodec->RegisterEncoderObserver( + videoChannel, codecObserver)); + EXPECT_EQ(0, ptrViECodec->RegisterDecoderObserver( + videoChannel, codecObserver)); - //*************************************************************** - // Testing finished. Tear down Video Engine - //*************************************************************** + EXPECT_EQ(0, ptrViEBase->StopReceive(videoChannel)); + EXPECT_NE(0, ptrViEBase->StopSend(videoChannel)); // Already stopped - error = ptrViEBase->StopReceive(videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ptrViEBase->StopSend(videoChannel); // Already stopped - numberOfErrors += ViETest::TestError(error == -1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ptrViERender->StopRender(videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ptrViERender->RemoveRenderer(captureId); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ptrViERender->RemoveRenderer(videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ptrViECapture->DisconnectCaptureDevice(videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ptrViEBase->DeleteChannel(videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ptrViERender->StopRender(videoChannel)); + EXPECT_EQ(0, ptrViERender->RemoveRenderer(captureId)); + EXPECT_EQ(0, ptrViERender->RemoveRenderer(videoChannel)); + EXPECT_EQ(0, ptrViECapture->DisconnectCaptureDevice(videoChannel)); + EXPECT_EQ(0, ptrViEBase->DeleteChannel(videoChannel)); } // @@ -239,50 +125,32 @@ int ViEAutoTest::ViECodecExtendedTest() // { // Create VIE - TbInterfaces ViE("ViECodecExtendedTest2", numberOfErrors); + TbInterfaces ViE("ViECodecExtendedTest2"); // Create a capture device - TbCaptureDevice tbCapture(ViE, numberOfErrors); + TbCaptureDevice tbCapture(ViE); // Create channel 1 int videoChannel1 = -1; - error = ViE.base->CreateChannel(videoChannel1); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.base->CreateChannel(videoChannel1)); unsigned short rtpPort1 = 12000; - error = ViE.network->SetLocalReceiver(videoChannel1, - rtpPort1); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.network->SetSendDestination(videoChannel1, - "127.0.0.1", rtpPort1); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - + EXPECT_EQ(0, ViE.network->SetLocalReceiver( + videoChannel1, rtpPort1)); + EXPECT_EQ(0, ViE.network->SetSendDestination( + videoChannel1, "127.0.0.1", rtpPort1)); tbCapture.ConnectTo(videoChannel1); - error = ViE.rtp_rtcp->SetKeyFrameRequestMethod( - videoChannel1, webrtc::kViEKeyFrameRequestPliRtcp); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ViE.render->AddRenderer(videoChannel1, _window1, - 0, 0.0, 0.0, 1.0, 1.0); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.render->StartRender(videoChannel1); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.rtp_rtcp->SetKeyFrameRequestMethod( + videoChannel1, webrtc::kViEKeyFrameRequestPliRtcp)); + EXPECT_EQ(0, ViE.render->AddRenderer( + videoChannel1, _window1, 0, 0.0, 0.0, 1.0, 1.0)); + EXPECT_EQ(0, ViE.render->StartRender(videoChannel1)); ViEAutotestCodecObserver codecObserver1; - error = ViE.codec->RegisterEncoderObserver(videoChannel1, - codecObserver1); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.codec->RegisterDecoderObserver(videoChannel1, - codecObserver1); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.codec->RegisterEncoderObserver( + videoChannel1, codecObserver1)); + EXPECT_EQ(0, ViE.codec->RegisterDecoderObserver( + videoChannel1, codecObserver1)); // Set Send codec unsigned short codecWidth = 176; @@ -291,95 +159,55 @@ int ViEAutoTest::ViECodecExtendedTest() webrtc::VideoCodec videoCodec; for (int idx = 0; idx < ViE.codec->NumberOfCodecs(); idx++) { - error = ViE.codec->GetCodec(idx, videoCodec); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.codec->SetReceiveCodec(videoChannel1, videoCodec); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.codec->GetCodec(idx, videoCodec)); + EXPECT_EQ(0, ViE.codec->SetReceiveCodec(videoChannel1, videoCodec)); if (videoCodec.codecType == webrtc::kVideoCodecVP8) { videoCodec.width = codecWidth; videoCodec.height = codecHeight; videoCodec.startBitrate = 200; videoCodec.maxBitrate = 300; - error = ViE.codec->SetSendCodec(videoChannel1, videoCodec); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.codec->SetSendCodec( + videoChannel1, videoCodec)); codecSet = true; break; } } - numberOfErrors += ViETest::TestError(codecSet, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_TRUE(codecSet); - error = ViE.base->StartSend(videoChannel1); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.base->StartReceive(videoChannel1); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.base->StartSend(videoChannel1)); + EXPECT_EQ(0, ViE.base->StartReceive(videoChannel1)); // Create channel 2, based on channel 1 int videoChannel2 = -1; - error = ViE.base->CreateChannel(videoChannel2, videoChannel1); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError(videoChannel1 != videoChannel2, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.base->CreateChannel(videoChannel2, videoChannel1)); + EXPECT_NE(videoChannel1, videoChannel2) << + "Channel 2 should be seop"; - error = ViE.rtp_rtcp->SetKeyFrameRequestMethod( - videoChannel2, webrtc::kViEKeyFrameRequestPliRtcp); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.rtp_rtcp->SetKeyFrameRequestMethod( + videoChannel2, webrtc::kViEKeyFrameRequestPliRtcp)); // Prepare receive codecs for (int idx = 0; idx < ViE.codec->NumberOfCodecs(); idx++) { - error = ViE.codec->GetCodec(idx, videoCodec); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.codec->SetReceiveCodec(videoChannel2, videoCodec); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.codec->GetCodec(idx, videoCodec)); + EXPECT_EQ(0, ViE.codec->SetReceiveCodec(videoChannel2, videoCodec)); } ViEAutotestCodecObserver codecObserver2; - error = ViE.codec->RegisterDecoderObserver(videoChannel2, - codecObserver2); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ViE.render->AddRenderer(videoChannel2, _window2, - 0, 0.0, 0.0, 1.0, 1.0); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.render->StartRender(videoChannel2); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.codec->RegisterDecoderObserver( + videoChannel2, codecObserver2)); + EXPECT_EQ(0, ViE.render->AddRenderer( + videoChannel2, _window2, 0, 0.0, 0.0, 1.0, 1.0)); + EXPECT_EQ(0, ViE.render->StartRender(videoChannel2)); unsigned short rtpPort2 = 13000; - error = ViE.network->SetLocalReceiver(videoChannel2, - rtpPort2); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.network->SetSendDestination(videoChannel2, - "127.0.0.1", rtpPort2); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.network->SetLocalReceiver(videoChannel2, rtpPort2)); + EXPECT_EQ(0, ViE.network->SetSendDestination( + videoChannel2, "127.0.0.1", rtpPort2)); - error = ViE.base->StartReceive(videoChannel2); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.base->StartSend(videoChannel2); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.base->StartReceive(videoChannel2)); + EXPECT_EQ(0, ViE.base->StartSend(videoChannel2)); ViETest::Log("\nTest using one encoder on several channels"); ViETest::Log("Channel 1 is rendered in Window1, channel 2 in Window 2." @@ -388,162 +216,82 @@ int ViEAutoTest::ViECodecExtendedTest() AutoTestSleep(KAutoTestSleepTimeMs); // Check that we received H.263 on both channels - numberOfErrors += ViETest::TestError( - codecObserver1.incomingCodec.codecType == webrtc::kVideoCodecVP8 - && codecObserver1.incomingCodec.width == 176, - "ERROR: %s at line %d", __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError( - codecObserver2.incomingCodec.codecType == - webrtc::kVideoCodecVP8 - && codecObserver2.incomingCodec.width == 176, - "ERROR: %s at line %d", __FUNCTION__, __LINE__); + EXPECT_EQ(webrtc::kVideoCodecVP8, + codecObserver1.incomingCodec.codecType); + EXPECT_EQ(176, codecObserver1.incomingCodec.width); + EXPECT_EQ(webrtc::kVideoCodecVP8, + codecObserver2.incomingCodec.codecType); + EXPECT_EQ(176, codecObserver2.incomingCodec.width); // Delete the first channel and keep the second - error = ViE.base->DeleteChannel(videoChannel1); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - ViETest::Log("Channel 1 deleted, you should only see video in Window " - "2"); + EXPECT_EQ(0, ViE.base->DeleteChannel(videoChannel1)); + ViETest::Log("Channel 1 deleted, " + "you should only see video in Window 2"); AutoTestSleep(KAutoTestSleepTimeMs); // Create another channel int videoChannel3 = -1; - error = ViE.base->CreateChannel(videoChannel3, videoChannel2); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError(videoChannel3 != videoChannel2, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.base->CreateChannel(videoChannel3, videoChannel2)); + EXPECT_NE(videoChannel3, videoChannel2); - error = ViE.rtp_rtcp->SetKeyFrameRequestMethod( - videoChannel3, webrtc::kViEKeyFrameRequestPliRtcp); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.rtp_rtcp->SetKeyFrameRequestMethod( + videoChannel3, webrtc::kViEKeyFrameRequestPliRtcp)); // Prepare receive codecs for (int idx = 0; idx < ViE.codec->NumberOfCodecs(); idx++) { - error = ViE.codec->GetCodec(idx, videoCodec); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.codec->SetReceiveCodec(videoChannel3, - videoCodec); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.codec->GetCodec(idx, videoCodec)); + EXPECT_EQ(0, ViE.codec->SetReceiveCodec( + videoChannel3, videoCodec)); } ViEAutotestCodecObserver codecObserver3; - error = ViE.codec->RegisterDecoderObserver(videoChannel3, - codecObserver3); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.codec->RegisterDecoderObserver( + videoChannel3, codecObserver3)); - error = ViE.render->AddRenderer(videoChannel3, _window1, 0, 0.0, - 0.0, 1.0, 1.0); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.render->StartRender(videoChannel3); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.render->AddRenderer( + videoChannel3, _window1, 0, 0.0, 0.0, 1.0, 1.0)); + EXPECT_EQ(0, ViE.render->StartRender(videoChannel3)); unsigned short rtpPort3 = 14000; - error = ViE.network->SetLocalReceiver(videoChannel3, rtpPort3); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.network->SetSendDestination(videoChannel3, - "127.0.0.1", rtpPort3); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.network->SetLocalReceiver(videoChannel3, rtpPort3)); + EXPECT_EQ(0, ViE.network->SetSendDestination( + videoChannel3, "127.0.0.1", rtpPort3)); - error = ViE.base->StartReceive(videoChannel3); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.base->StartSend(videoChannel3); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.base->StartReceive(videoChannel3)); + EXPECT_EQ(0, ViE.base->StartSend(videoChannel3)); - error = ViE.base->DeleteChannel(videoChannel2); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.base->DeleteChannel(videoChannel2)); ViETest::Log("A third channel created and rendered in Window 1,\n" "channel 2 is deleted and you should only see video in Window 1"); AutoTestSleep(KAutoTestSleepTimeMs); - error = ViE.base->DeleteChannel(videoChannel3); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.base->DeleteChannel(videoChannel3)); } - - // SetKeyFrameRequestCallbackStatus - // Check callback - - // SetPacketLossBitrateAdaptationStatus - // Check bitrate changes/doesn't change - - // GetAvailableBandwidth - - // SendKeyFrame - - if (numberOfErrors > 0) - { - // Test failed - ViETest::Log(" "); - ViETest::Log(" ERROR ViECodec Extended Test FAILED!"); - ViETest::Log(" Number of errors: %d", numberOfErrors); - ViETest::Log("========================================"); - ViETest::Log(" "); - return numberOfErrors; - } - - ViETest::Log(" "); - ViETest::Log(" ViECodec Extended Test PASSED!"); - ViETest::Log("========================================"); - ViETest::Log(" "); - return 0; } -int ViEAutoTest::ViECodecAPITest() +void ViEAutoTest::ViECodecAPITest() { - ViETest::Log(" "); - ViETest::Log("========================================"); - ViETest::Log(" ViECodec API Test\n"); - // *************************************************************** // Begin create/initialize WebRTC Video Engine for testing // *************************************************************** - - int error = 0; - int numberOfErrors = 0; - webrtc::VideoEngine* ptrViE = NULL; ptrViE = webrtc::VideoEngine::Create(); - numberOfErrors += ViETest::TestError(ptrViE != NULL, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_TRUE(ptrViE != NULL); webrtc::ViEBase* ptrViEBase = webrtc::ViEBase::GetInterface(ptrViE); - numberOfErrors += ViETest::TestError(ptrViEBase != NULL, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); + EXPECT_TRUE(ptrViEBase != NULL); - error = ptrViEBase->Init(); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ptrViEBase->Init()); int videoChannel = -1; - error = ptrViEBase->CreateChannel(videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ptrViEBase->CreateChannel(videoChannel)); webrtc::ViECodec* ptrViECodec = webrtc::ViECodec::GetInterface(ptrViE); - numberOfErrors += ViETest::TestError(ptrViECodec != NULL, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); + EXPECT_TRUE(ptrViECodec != NULL); //*************************************************************** // Engine ready. Begin testing class @@ -556,74 +304,37 @@ int ViEAutoTest::ViECodecAPITest() memset(&videoCodec, 0, sizeof(webrtc::VideoCodec)); const int numberOfCodecs = ptrViECodec->NumberOfCodecs(); - numberOfErrors += ViETest::TestError(numberOfCodecs > 0, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); + EXPECT_GT(numberOfCodecs, 0); SetSendCodec(webrtc::kVideoCodecVP8, ptrViECodec, videoChannel, - &numberOfErrors, kDoNotForceResolution, kDoNotForceResolution); + kDoNotForceResolution, kDoNotForceResolution); memset(&videoCodec, 0, sizeof(videoCodec)); - error = ptrViECodec->GetSendCodec(videoChannel, videoCodec); - assert(videoCodec.codecType == webrtc::kVideoCodecVP8); + EXPECT_EQ(0, ptrViECodec->GetSendCodec(videoChannel, videoCodec)); + EXPECT_EQ(webrtc::kVideoCodecVP8, videoCodec.codecType); SetSendCodec(webrtc::kVideoCodecI420, ptrViECodec, videoChannel, - &numberOfErrors, kDoNotForceResolution, kDoNotForceResolution); + kDoNotForceResolution, kDoNotForceResolution); memset(&videoCodec, 0, sizeof(videoCodec)); - error = ptrViECodec->GetSendCodec(videoChannel, videoCodec); - assert(videoCodec.codecType == webrtc::kVideoCodecI420); + EXPECT_EQ(0, ptrViECodec->GetSendCodec(videoChannel, videoCodec)); + EXPECT_EQ(webrtc::kVideoCodecI420, videoCodec.codecType); //*************************************************************** // Testing finished. Tear down Video Engine //*************************************************************** - error = ptrViEBase->DeleteChannel(videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ptrViEBase->DeleteChannel(videoChannel)); - int remainingInterfaces = 0; - remainingInterfaces = ptrViECodec->Release(); - numberOfErrors += ViETest::TestError(remainingInterfaces == 0, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); - - remainingInterfaces = ptrViEBase->Release(); - numberOfErrors += ViETest::TestError(remainingInterfaces == 0, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); - - bool deleted = webrtc::VideoEngine::Delete(ptrViE); - numberOfErrors += ViETest::TestError(deleted == true, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); - - if (numberOfErrors > 0) - { - // Test failed - ViETest::Log(" "); - ViETest::Log(" ERROR ViECodec API Test FAILED!"); - ViETest::Log(" Number of errors: %d", numberOfErrors); - ViETest::Log("========================================"); - ViETest::Log(" "); - return numberOfErrors; - } - - ViETest::Log(" "); - ViETest::Log(" ViECodec API Test PASSED!"); - ViETest::Log("========================================"); - ViETest::Log(" "); - return 0; + EXPECT_EQ(0, ptrViECodec->Release()); + EXPECT_EQ(0, ptrViEBase->Release()); + EXPECT_TRUE(webrtc::VideoEngine::Delete(ptrViE)); } #ifdef WEBRTC_VIDEO_ENGINE_EXTERNAL_CODEC_API #include "vie_external_codec.h" #endif -int ViEAutoTest::ViECodecExternalCodecTest() +void ViEAutoTest::ViECodecExternalCodecTest() { - ViETest::Log(" "); - ViETest::Log("========================================"); - ViETest::Log(" ViEExternalCodec Test\n"); - // *************************************************************** // Begin create/initialize WebRTC Video Engine for testing // *************************************************************** @@ -634,23 +345,17 @@ int ViEAutoTest::ViECodecExternalCodecTest() // *************************************************************** #ifdef WEBRTC_VIDEO_ENGINE_EXTERNAL_CODEC_API - int numberOfErrors=0; { - int error=0; - TbInterfaces ViE("ViEExternalCodec", numberOfErrors); - TbCaptureDevice captureDevice(ViE, numberOfErrors); - tbVideoChannel channel(ViE, numberOfErrors, webrtc::kVideoCodecI420, - 352,288,30,(352*288*3*8*30)/(2*1000)); + TbInterfaces ViE("ViEExternalCodec"); + TbCaptureDevice captureDevice(ViE); + TbVideoChannel channel( + ViE, webrtc::kVideoCodecI420, 352,288,30,(352*288*3*8*30)/(2*1000)); captureDevice.ConnectTo(channel.videoChannel); - error = ViE.render->AddRenderer(channel.videoChannel, _window1, 0, - 0.0, 0.0, 1.0, 1.0); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.render->StartRender(channel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.render->AddRenderer( + channel.videoChannel, _window1, 0, 0.0, 0.0, 1.0, 1.0)); + EXPECT_EQ(0, ViE.render->StartRender(channel.videoChannel)); channel.StartReceive(); channel.StartSend(); @@ -658,156 +363,89 @@ int ViEAutoTest::ViECodecExternalCodecTest() ViETest::Log("Using internal I420 codec"); AutoTestSleep(KAutoTestSleepTimeMs/2); - ViEExternalCodec* ptrViEExtCodec = - ViEExternalCodec::GetInterface(ViE.video_engine); - numberOfErrors += ViETest::TestError(ptrViEExtCodec != NULL, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + webrtc::ViEExternalCodec* ptrViEExtCodec = + webrtc::ViEExternalCodec::GetInterface(ViE.video_engine); + EXPECT_TRUE(ptrViEExtCodec != NULL); webrtc::VideoCodec codecStruct; - error=ViE.codec->GetSendCodec(channel.videoChannel,codecStruct); - numberOfErrors += ViETest::TestError(ptrViEExtCodec != NULL, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.codec->GetSendCodec( + channel.videoChannel, codecStruct)); // Use external encoder instead { - tbI420Encoder extEncoder; + TbI420Encoder extEncoder; // Test to register on wrong channel - error = ptrViEExtCodec->RegisterExternalSendCodec( - channel.videoChannel+5,codecStruct.plType,&extEncoder); - numberOfErrors += ViETest::TestError(error == -1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError( - ViE.LastError() == kViECodecInvalidArgument, - "ERROR: %s at line %d", __FUNCTION__, __LINE__); + EXPECT_NE(0, ptrViEExtCodec->RegisterExternalSendCodec( + channel.videoChannel+5,codecStruct.plType,&extEncoder)); + EXPECT_EQ(kViECodecInvalidArgument, ViE.LastError()); - error = ptrViEExtCodec->RegisterExternalSendCodec( - channel.videoChannel,codecStruct.plType,&extEncoder); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ptrViEExtCodec->RegisterExternalSendCodec( + channel.videoChannel,codecStruct.plType,&extEncoder)); // Use new external encoder - error = ViE.codec->SetSendCodec(channel.videoChannel, - codecStruct); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.codec->SetSendCodec( + channel.videoChannel, codecStruct)); - tbI420Decoder extDecoder; - error = ptrViEExtCodec->RegisterExternalReceiveCodec( - channel.videoChannel,codecStruct.plType,&extDecoder); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + TbI420Decoder extDecoder; + EXPECT_EQ(0, ptrViEExtCodec->RegisterExternalReceiveCodec( + channel.videoChannel,codecStruct.plType,&extDecoder)); - error = ViE.codec->SetReceiveCodec(channel.videoChannel, - codecStruct); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.codec->SetReceiveCodec( + channel.videoChannel, codecStruct)); ViETest::Log("Using external I420 codec"); AutoTestSleep(KAutoTestSleepTimeMs); // Test to deregister on wrong channel - error = ptrViEExtCodec->DeRegisterExternalSendCodec( - channel.videoChannel+5,codecStruct.plType); - numberOfErrors += ViETest::TestError(error == -1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError( - ViE.LastError() == kViECodecInvalidArgument, - "ERROR: %s at line %d", __FUNCTION__, __LINE__); + EXPECT_NE(0, ptrViEExtCodec->DeRegisterExternalSendCodec( + channel.videoChannel+5,codecStruct.plType)); + EXPECT_EQ(kViECodecInvalidArgument, ViE.LastError()); // Test to deregister wrong payload type. - error = ptrViEExtCodec->DeRegisterExternalSendCodec( - channel.videoChannel,codecStruct.plType-1); - numberOfErrors += ViETest::TestError(error == -1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_NE(0, ptrViEExtCodec->DeRegisterExternalSendCodec( + channel.videoChannel,codecStruct.plType-1)); // Deregister external send codec - error = ptrViEExtCodec->DeRegisterExternalSendCodec( - channel.videoChannel,codecStruct.plType); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ptrViEExtCodec->DeRegisterExternalSendCodec( + channel.videoChannel,codecStruct.plType)); - error = ptrViEExtCodec->DeRegisterExternalReceiveCodec( - channel.videoChannel,codecStruct.plType); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ptrViEExtCodec->DeRegisterExternalReceiveCodec( + channel.videoChannel,codecStruct.plType)); // Verify that the encoder and decoder has been used - tbI420Encoder::FunctionCalls encodeCalls = + TbI420Encoder::FunctionCalls encodeCalls = extEncoder.GetFunctionCalls(); - numberOfErrors += ViETest::TestError(encodeCalls.InitEncode == 1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError(encodeCalls.Release == 1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError(encodeCalls.Encode > 30, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError( - encodeCalls.RegisterEncodeCompleteCallback ==1, - "ERROR: %s at line %d", __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError(encodeCalls.SetRates > 1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError(encodeCalls.SetPacketLoss > 1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(1, encodeCalls.InitEncode); + EXPECT_EQ(1, encodeCalls.Release); + EXPECT_EQ(1, encodeCalls.RegisterEncodeCompleteCallback); + EXPECT_GT(encodeCalls.Encode, 30); + EXPECT_GT(encodeCalls.SetRates, 1); + EXPECT_GT(encodeCalls.SetPacketLoss, 1); - tbI420Decoder::FunctionCalls decodeCalls = + TbI420Decoder::FunctionCalls decodeCalls = extDecoder.GetFunctionCalls(); - numberOfErrors += ViETest::TestError(decodeCalls.InitDecode == 1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError(decodeCalls.Release == 1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError(decodeCalls.Decode > 30, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError( - decodeCalls.RegisterDecodeCompleteCallback ==1, - "ERROR: %s at line %d", __FUNCTION__, __LINE__); + EXPECT_EQ(1, decodeCalls.InitDecode); + EXPECT_EQ(1, decodeCalls.Release); + EXPECT_EQ(1, decodeCalls.RegisterDecodeCompleteCallback); + EXPECT_GT(decodeCalls.Decode, 30); ViETest::Log("Changing payload type Using external I420 codec"); - codecStruct.plType=codecStruct.plType-1; - error = ptrViEExtCodec->RegisterExternalReceiveCodec( - channel.videoChannel, codecStruct.plType, &extDecoder); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + codecStruct.plType = codecStruct.plType - 1; + EXPECT_EQ(0, ptrViEExtCodec->RegisterExternalReceiveCodec( + channel.videoChannel, codecStruct.plType, &extDecoder)); - error = ViE.codec->SetReceiveCodec(channel.videoChannel, - codecStruct); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.codec->SetReceiveCodec( + channel.videoChannel, codecStruct)); - error = ptrViEExtCodec->RegisterExternalSendCodec( - channel.videoChannel, codecStruct.plType, &extEncoder); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ptrViEExtCodec->RegisterExternalSendCodec( + channel.videoChannel, codecStruct.plType, &extEncoder)); // Use new external encoder - error = ViE.codec->SetSendCodec(channel.videoChannel, - codecStruct); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.codec->SetSendCodec( + channel.videoChannel, codecStruct)); AutoTestSleep(KAutoTestSleepTimeMs/2); @@ -815,82 +453,36 @@ int ViEAutoTest::ViECodecExternalCodecTest() // Testing finished. Tear down Video Engine //*************************************************************** - - error = ptrViEExtCodec->DeRegisterExternalSendCodec( - channel.videoChannel,codecStruct.plType); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ptrViEExtCodec->DeRegisterExternalReceiveCodec( - channel.videoChannel,codecStruct.plType); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ptrViEExtCodec->DeRegisterExternalSendCodec( + channel.videoChannel,codecStruct.plType)); + EXPECT_EQ(0, ptrViEExtCodec->DeRegisterExternalReceiveCodec( + channel.videoChannel,codecStruct.plType)); // Verify that the encoder and decoder has been used encodeCalls = extEncoder.GetFunctionCalls(); - numberOfErrors += ViETest::TestError(encodeCalls.InitEncode == 2, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError(encodeCalls.Release == 2, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError(encodeCalls.Encode > 30, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError( - encodeCalls.RegisterEncodeCompleteCallback == 2, - "ERROR: %s at line %d", __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError(encodeCalls.SetRates > 1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError(encodeCalls.SetPacketLoss > 1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(2, encodeCalls.InitEncode); + EXPECT_EQ(2, encodeCalls.Release); + EXPECT_EQ(2, encodeCalls.RegisterEncodeCompleteCallback); + EXPECT_GT(encodeCalls.Encode, 30); + EXPECT_GT(encodeCalls.SetRates, 1); + EXPECT_GT(encodeCalls.SetPacketLoss, 1); decodeCalls = extDecoder.GetFunctionCalls(); - numberOfErrors += ViETest::TestError(decodeCalls.InitDecode == 2, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError(decodeCalls.Release == 2, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError(decodeCalls.Decode > 30, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError( - decodeCalls.RegisterDecodeCompleteCallback == 2, - "ERROR: %s at line %d", __FUNCTION__, __LINE__); - int remainingInterfaces = ptrViEExtCodec->Release(); - numberOfErrors += ViETest::TestError(remainingInterfaces == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - } // tbI420Encoder and extDecoder goes out of scope + EXPECT_EQ(2, decodeCalls.InitDecode); + EXPECT_EQ(2, decodeCalls.Release); + EXPECT_EQ(2, decodeCalls.RegisterDecodeCompleteCallback); + EXPECT_GT(decodeCalls.Decode, 30); + + EXPECT_EQ(0, ptrViEExtCodec->Release()); + } // tbI420Encoder and extDecoder goes out of scope ViETest::Log("Using internal I420 codec"); AutoTestSleep(KAutoTestSleepTimeMs/2); } - if (numberOfErrors > 0) - { - // Test failed - ViETest::Log(" "); - ViETest::Log(" ERROR ViEExternalCodec Test FAILED!"); - ViETest::Log(" Number of errors: %d", numberOfErrors); - ViETest::Log("========================================"); - ViETest::Log(" "); - return numberOfErrors; - } - - ViETest::Log(" "); - ViETest::Log(" ViEExternalCodec Test PASSED!"); - ViETest::Log("========================================"); - ViETest::Log(" "); - return 0; #else ViETest::Log(" ViEExternalCodec not enabled\n"); - return 0; #endif } diff --git a/src/video_engine/test/auto_test/source/vie_autotest_custom_call.cc b/src/video_engine/test/auto_test/source/vie_autotest_custom_call.cc index d82fb3360..1179dad8f 100644 --- a/src/video_engine/test/auto_test/source/vie_autotest_custom_call.cc +++ b/src/video_engine/test/auto_test/source/vie_autotest_custom_call.cc @@ -167,7 +167,7 @@ int ViEAutoTest::ViECustomCall() "ERROR: %s at line %d", __FUNCTION__, __LINE__); - webrtc::VoEHardware* ptrVEHardware = + webrtc::VoEHardware* ptrVEHardware = webrtc::VoEHardware::GetInterface(ptrVE); numberOfErrors += ViETest::TestError(ptrVEHardware != NULL, "ERROR: %s at line %d", __FUNCTION__, @@ -194,7 +194,7 @@ int ViEAutoTest::ViECustomCall() numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", __FUNCTION__, __LINE__); - webrtc::ViECapture* ptrViECapture = + webrtc::ViECapture* ptrViECapture = webrtc::ViECapture::GetInterface(ptrViE); numberOfErrors += ViETest::TestError(ptrViECapture != NULL, "ERROR: %s at line %d", __FUNCTION__, @@ -240,7 +240,7 @@ int ViEAutoTest::ViECustomCall() webrtc::CodecInst audioCodec; int audioChannel = -1; int protectionMethod = 0; - // TODO (amyfong): Change the observers to pointers, use NULL checks to + // TODO (amyfong): Change the observers to pointers, use NULL checks to // toggle between registered or deregistered bool isEncoderObserverRegistered = false; bool isDecoderObserverRegistered = false; @@ -434,8 +434,8 @@ int ViEAutoTest::ViECustomCall() __FUNCTION__, __LINE__); // Set all video protection to false initially // shouldn't be nessecary as ViE protection modes are all off - // initially. - // TODO(amyfong): Remove the set to false and use + // initially. + // TODO(amyfong): Remove the set to false and use // SetVideoProtection instead. error = ptrViERtpRtcp->SetHybridNACKFECStatus(videoChannel, false, VCM_RED_PAYLOAD_TYPE, @@ -454,11 +454,11 @@ int ViEAutoTest::ViECustomCall() "ERROR: %s at line %d", __FUNCTION__, __LINE__); // Set video protection for FEC, NACK or Hybrid. - // TODO(amyfong): Use SetVideoProtection instead, need to + // TODO(amyfong): Use SetVideoProtection instead, need to // move the set protection method after the first SetReceiveCodec // also should change and use videoSendCodec & videoReceiveCodec // instead of just videoCodec. Helps check what exactly the call - // setup is onces the call is up and running. + // setup is onces the call is up and running. switch (protectionMethod) { case 0: // None // No protection selected, all protection already at false @@ -525,7 +525,7 @@ int ViEAutoTest::ViECustomCall() __FUNCTION__, __LINE__); // Set receive codecs for FEC and hybrid NACK/FEC. - // TODO(amyfong): Use SetVideoProtection instead, need to + // TODO(amyfong): Use SetVideoProtection instead, need to // move the set protection method after the first SetReceiveCodec // also should change and use videoSendCodec & videoReceiveCodec // instead of just videoCodec. Helps check what exactly the call @@ -638,14 +638,14 @@ int ViEAutoTest::ViECustomCall() std::cout << " 5. Record Incoming Call" << std::endl; std::cout << " 6. Record Outgoing Call" << std::endl; std::cout << " 7. Play File on Video Channel" - << "(Assumes you recorded incoming & outgoing call)" + << "(Assumes you recorded incoming & outgoing call)" << std::endl; std::cout << " 8. Change Video Protection Method" << std::endl; std::cout << " 9. Toggle Encoder Observer" << std::endl; std::cout << " 10. Toggle Decoder Observer" << std::endl; std::cout << " 11. Print Call Information" << std::endl; std::cout << " 12. Print Call Statistics" << std::endl; - std::cout << " 13. Toggle Image Scaling " + std::cout << " 13. Toggle Image Scaling " << "(Warning high CPU usage when enabled)" << std::endl; std::cout << "What do you want to do? "; @@ -664,7 +664,7 @@ int ViEAutoTest::ViECustomCall() modify_call = false; break; case 1: - // Change video Codec + // Change video Codec SetVideoCodecType(ptrViECodec, videoCodec); SetVideoCodecSize(ptrViECodec, videoCodec); SetVideoCodecBitrate(ptrViECodec, videoCodec); @@ -778,7 +778,7 @@ int ViEAutoTest::ViECustomCall() break; case 5: // Record the incoming call - std::cout << "Start Recording Incoming Video " + std::cout << "Start Recording Incoming Video " << DEFAULT_INCOMING_FILE_NAME << std::endl; error = ptrViEFile->StartRecordIncomingVideo( videoChannel, DEFAULT_INCOMING_FILE_NAME, @@ -794,7 +794,7 @@ int ViEAutoTest::ViECustomCall() break; case 6: // Record the outgoing call - std::cout << "Start Recording Outgoing Video " + std::cout << "Start Recording Outgoing Video " << DEFAULT_OUTGOING_FILE_NAME << std::endl; error = ptrViEFile->StartRecordOutgoingVideo( videoChannel, DEFAULT_OUTGOING_FILE_NAME, @@ -814,7 +814,7 @@ int ViEAutoTest::ViECustomCall() std::cout << "Available files to play" << std::endl; std::cout << " 0. " << DEFAULT_INCOMING_FILE_NAME << std::endl; std::cout << " 1. " << DEFAULT_OUTGOING_FILE_NAME << std::endl; - std::cout << "Press enter for default (" + std::cout << "Press enter for default (" << DEFAULT_INCOMING_FILE_NAME << "): "; std::getline(std::cin, str); file_selection = atoi(str.c_str()); @@ -824,7 +824,7 @@ int ViEAutoTest::ViECustomCall() "ERROR:%d %s at line %d", ptrViEBase->LastError(), __FUNCTION__, __LINE__); - if (file_selection == 1) + if (file_selection == 1) error = ptrViEFile->StartPlayFile(DEFAULT_OUTGOING_FILE_NAME, fileId, true); else @@ -841,7 +841,7 @@ int ViEAutoTest::ViECustomCall() ptrViEBase->LastError(), __FUNCTION__, __LINE__); std::cout << std::endl; - std::cout << "Start sending the file that is played in a loop " + std::cout << "Start sending the file that is played in a loop " << std::endl; error = ptrViEFile->SendFileOnChannel(fileId, videoChannel); numberOfErrors += ViETest::TestError(error == 0, @@ -887,7 +887,7 @@ int ViEAutoTest::ViECustomCall() audioCodec, audioTxPort, audioRxPort); modify_call = true; - break; + break; case 9: // Toggle Encoder Observer if (!isEncoderObserverRegistered) { @@ -936,7 +936,7 @@ int ViEAutoTest::ViECustomCall() audioCodec, audioTxPort, audioRxPort); PrintVideoStreamInformation(ptrViECodec, - videoChannel); + videoChannel); modify_call = true; break; case 12: @@ -965,7 +965,7 @@ int ViEAutoTest::ViECustomCall() modify_call = true; break; default: - // invalid selection, shows options menu again + // invalid selection, shows options menu again std::cout << "Invalid selection. Select Again." << std::endl; break; } @@ -1505,7 +1505,7 @@ bool GetAudioCodec(webrtc::VoECodec* ptrVeCodec, std::cout << "ERROR: Code = " << error << " Invalid selection" << std::endl; continue; - } + } return true; } } @@ -1579,7 +1579,7 @@ bool SetVideoCodecType(webrtc::ViECodec* ptrViECodec, if (strcmp(videoCodec.plName, DEFAULT_VIDEO_CODEC) == 0) { defaultCodecIdx = codecIdx; } - std::cout << " " << codecIdx+1 << ". " << videoCodec.plName + std::cout << " " << codecIdx+1 << ". " << videoCodec.plName << std::endl; } std::cout << std::endl; @@ -1638,7 +1638,7 @@ bool SetVideoCodecResolution(webrtc::ViECodec* ptrViECodec, std::getline(std::cin, str); sizeOption = atoi(str.c_str()); - + switch (sizeOption) { case 1: videoCodec.width = 128; diff --git a/src/video_engine/test/auto_test/source/vie_autotest_encryption.cc b/src/video_engine/test/auto_test/source/vie_autotest_encryption.cc index 59c90ee9a..420d46512 100644 --- a/src/video_engine/test/auto_test/source/vie_autotest_encryption.cc +++ b/src/video_engine/test/auto_test/source/vie_autotest_encryption.cc @@ -74,53 +74,37 @@ public: } }; -int ViEAutoTest::ViEEncryptionStandardTest() +void ViEAutoTest::ViEEncryptionStandardTest() { - ViETest::Log(" "); - ViETest::Log("========================================"); - ViETest::Log(" ViEEncryption Standard Test\n"); - //*************************************************************** // Begin create/initialize WebRTC Video Engine for testing //*************************************************************** - int error = 0; - int numberOfErrors = 0; - // Create VIE - TbInterfaces ViE("ViEEncryptionStandardTest", numberOfErrors); + TbInterfaces ViE("ViEEncryptionStandardTest"); // Create a video channel - tbVideoChannel tbChannel(ViE, numberOfErrors, webrtc::kVideoCodecVP8); + TbVideoChannel tbChannel(ViE, webrtc::kVideoCodecVP8); // Create a capture device - TbCaptureDevice tbCapture(ViE, numberOfErrors); + TbCaptureDevice tbCapture(ViE); tbCapture.ConnectTo(tbChannel.videoChannel); tbChannel.StartReceive(); tbChannel.StartSend(); - error = ViE.render->AddRenderer(tbCapture.captureId, _window1, 0, - 0.0, 0.0, 1.0, 1.0); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.render->StartRender(tbCapture.captureId); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.render->AddRenderer(tbChannel.videoChannel, _window2, 1, - 0.0, 0.0, 1.0, 1.0); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.render->StartRender(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.render->AddRenderer( + tbCapture.captureId, _window1, 0, 0.0, 0.0, 1.0, 1.0)); + EXPECT_EQ(0, ViE.render->StartRender(tbCapture.captureId)); + EXPECT_EQ(0, ViE.render->AddRenderer( + tbChannel.videoChannel, _window2, 1, 0.0, 0.0, 1.0, 1.0)); + EXPECT_EQ(0, ViE.render->StartRender(tbChannel.videoChannel)); #ifdef WEBRTC_SRTP //*************************************************************** // Engine ready. Begin testing class //*************************************************************** - // // SRTP // @@ -129,150 +113,89 @@ int ViEAutoTest::ViEEncryptionStandardTest() 4, 5, 6, 7, 8, 9}; // Encryption only - error = ViE.encryption->EnableSRTPReceive( + EXPECT_EQ(0, ViE.encryption->EnableSRTPReceive( tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30, - webrtc::kAuthNull, 0, 0, webrtc::kEncryption, srtpKey1); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.encryption->EnableSRTPSend( + webrtc::kAuthNull, 0, 0, webrtc::kEncryption, srtpKey1)); + EXPECT_EQ(0, ViE.encryption->EnableSRTPSend( tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30, - webrtc::kAuthNull, 0, 0, webrtc::kEncryption, srtpKey1); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + webrtc::kAuthNull, 0, 0, webrtc::kEncryption, srtpKey1)); ViETest::Log("SRTP encryption only"); AutoTestSleep(KAutoTestSleepTimeMs); - error = ViE.encryption->DisableSRTPReceive(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.encryption->DisableSRTPSend(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.encryption->DisableSRTPReceive(tbChannel.videoChannel)); + EXPECT_EQ(0, ViE.encryption->DisableSRTPSend(tbChannel.videoChannel)); // Authentication only - error = ViE.encryption->EnableSRTPReceive(tbChannel.videoChannel, - webrtc::kCipherNull, 0, - webrtc::kAuthHmacSha1, 20, - 4, webrtc::kAuthentication, - srtpKey1); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.encryption->EnableSRTPSend(tbChannel.videoChannel, - webrtc::kCipherNull, 0, - webrtc::kAuthHmacSha1, 20, 4, - webrtc::kAuthentication, - srtpKey1); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.encryption->EnableSRTPReceive( + tbChannel.videoChannel, webrtc::kCipherNull, 0, webrtc::kAuthHmacSha1, + 20, 4, webrtc::kAuthentication, srtpKey1)); + EXPECT_EQ(0, ViE.encryption->EnableSRTPSend( + tbChannel.videoChannel, webrtc::kCipherNull, 0, webrtc::kAuthHmacSha1, + 20, 4, webrtc::kAuthentication, srtpKey1)); + ViETest::Log("SRTP authentication only"); AutoTestSleep(KAutoTestSleepTimeMs); - error = ViE.encryption->DisableSRTPReceive(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.encryption->DisableSRTPSend(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.encryption->DisableSRTPReceive(tbChannel.videoChannel)); + EXPECT_EQ(0, ViE.encryption->DisableSRTPSend(tbChannel.videoChannel)); // Full protection - error = ViE.encryption->EnableSRTPReceive( + EXPECT_EQ(0, ViE.encryption->EnableSRTPReceive( tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30, webrtc::kAuthHmacSha1, 20, 4, webrtc::kEncryptionAndAuthentication, - srtpKey1); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.encryption->EnableSRTPSend( + srtpKey1)); + EXPECT_EQ(0, ViE.encryption->EnableSRTPSend( tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30, webrtc::kAuthHmacSha1, 20, 4, webrtc::kEncryptionAndAuthentication, - srtpKey1); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + srtpKey1)); + ViETest::Log("SRTP full protection"); AutoTestSleep(KAutoTestSleepTimeMs); - error = ViE.encryption->DisableSRTPReceive(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.encryption->DisableSRTPSend(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", + EXPECT_EQ(0, ViE.encryption->DisableSRTPReceive(tbChannel.videoChannel)); + EXPECT_EQ(0, ViE.encryption->DisableSRTPSend(tbChannel.videoChannel)); #endif // WEBRTC_SRTP + // // External encryption // ViEAutotestEncryption testEncryption; - error = ViE.base->StartSend(tbChannel.videoChannel); - error = ViE.encryption->RegisterExternalEncryption( - tbChannel.videoChannel, testEncryption); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + // Note(qhogpat): StartSend fails, not sure if this is intentional. + EXPECT_NE(0, ViE.base->StartSend(tbChannel.videoChannel)); + EXPECT_EQ(0, ViE.encryption->RegisterExternalEncryption( + tbChannel.videoChannel, testEncryption)); ViETest::Log( "External encryption/decryption added, you should still see video"); AutoTestSleep(KAutoTestSleepTimeMs); - error = ViE.encryption->DeregisterExternalEncryption( - tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.encryption->DeregisterExternalEncryption( + tbChannel.videoChannel)); //*************************************************************** // Testing finished. Tear down Video Engine //*************************************************************** - - - if (numberOfErrors > 0) - { - // Test failed - ViETest::Log(" "); - ViETest::Log(" ERROR ViEEncryption Standard Test FAILED!"); - ViETest::Log(" Number of errors: %d", numberOfErrors); - ViETest::Log("========================================"); - ViETest::Log(" "); - return numberOfErrors; - } - - ViETest::Log(" "); - ViETest::Log(" ViEEncryption Standard Test PASSED!"); - ViETest::Log("========================================"); - ViETest::Log(" "); - return 0; - } -int ViEAutoTest::ViEEncryptionExtendedTest() +void ViEAutoTest::ViEEncryptionExtendedTest() { - ViETest::Log(" "); - ViETest::Log("========================================"); - ViETest::Log(" ViEEncryption Extended Test\n"); - //*************************************************************** // Begin create/initialize WebRTC Video Engine for testing //*************************************************************** - int error = 0; - int numberOfErrors = 0; - // Create VIE - TbInterfaces ViE("ViEEncryptionExtendedTest", numberOfErrors); + TbInterfaces ViE("ViEEncryptionExtendedTest"); // Create a video channel - tbVideoChannel tbChannel(ViE, numberOfErrors, webrtc::kVideoCodecVP8); + TbVideoChannel tbChannel(ViE, webrtc::kVideoCodecVP8); // Create a capture device - TbCaptureDevice tbCapture(ViE, numberOfErrors); + TbCaptureDevice tbCapture(ViE); tbCapture.ConnectTo(tbChannel.videoChannel); tbChannel.StartReceive(); tbChannel.StartSend(); - error = ViE.render->AddRenderer(tbCapture.captureId, _window1, 0, - 0.0, 0.0, 1.0, 1.0); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.render->StartRender(tbCapture.captureId); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.render->AddRenderer(tbChannel.videoChannel, _window2, 1, - 0.0, 0.0, 1.0, 1.0); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.render->StartRender(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.render->AddRenderer( + tbCapture.captureId, _window1, 0, 0.0, 0.0, 1.0, 1.0)); + EXPECT_EQ(0, ViE.render->StartRender(tbCapture.captureId)); + EXPECT_EQ(0, ViE.render->AddRenderer( + tbChannel.videoChannel, _window2, 1, 0.0, 0.0, 1.0, 1.0)); + EXPECT_EQ(0, ViE.render->StartRender(tbChannel.videoChannel)); //*************************************************************** // Engine ready. Begin testing class @@ -290,201 +213,126 @@ int ViEAutoTest::ViEEncryptionExtendedTest() { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0}; // NULL - error = ViE.encryption->EnableSRTPReceive(tbChannel.videoChannel, - webrtc::kCipherNull, 0, - webrtc::kAuthNull, 0, 0, - webrtc::kNoProtection, - srtpKey1); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.encryption->EnableSRTPSend(tbChannel.videoChannel, - webrtc::kCipherNull, 0, - webrtc::kAuthNull, 0, 0, - webrtc::kNoProtection, - srtpKey1); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.encryption->EnableSRTPReceive( + tbChannel.videoChannel, webrtc::kCipherNull, 0, webrtc::kAuthNull, 0, 0, + webrtc::kNoProtection, srtpKey1)); + EXPECT_EQ(0, ViE.encryption->EnableSRTPSend( + tbChannel.videoChannel, webrtc::kCipherNull, 0, webrtc::kAuthNull, 0, 0, + webrtc::kNoProtection, srtpKey1)); + ViETest::Log("SRTP NULL encryption/authentication"); AutoTestSleep(KAutoTestSleepTimeMs); - error = ViE.encryption->DisableSRTPReceive(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.encryption->DisableSRTPSend(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.encryption->DisableSRTPReceive(tbChannel.videoChannel)); + EXPECT_EQ(0, ViE.encryption->DisableSRTPSend(tbChannel.videoChannel)); // Encryption only - error = ViE.encryption->EnableSRTPReceive( + EXPECT_EQ(0, ViE.encryption->EnableSRTPReceive( tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30, - webrtc::kAuthNull, 0, 0, webrtc::kEncryption, srtpKey1); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.encryption->EnableSRTPSend( + webrtc::kAuthNull, 0, 0, webrtc::kEncryption, srtpKey1)); + EXPECT_EQ(0, ViE.encryption->EnableSRTPSend( tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30, - webrtc::kAuthNull, 0, 0, webrtc::kEncryption, srtpKey1); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + webrtc::kAuthNull, 0, 0, webrtc::kEncryption, srtpKey1)); + ViETest::Log("SRTP encryption only"); AutoTestSleep(KAutoTestSleepTimeMs); - error = ViE.encryption->DisableSRTPReceive(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.encryption->DisableSRTPSend(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.encryption->DisableSRTPReceive(tbChannel.videoChannel)); + EXPECT_EQ(0, ViE.encryption->DisableSRTPSend(tbChannel.videoChannel)); // Authentication only - error = ViE.encryption->EnableSRTPReceive(tbChannel.videoChannel, - webrtc::kCipherNull, 0, - webrtc::kAuthHmacSha1, 20, - 4, webrtc::kAuthentication, - srtpKey1); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.encryption->EnableSRTPSend(tbChannel.videoChannel, - webrtc::kCipherNull, 0, - webrtc::kAuthHmacSha1, 20, 4, - webrtc::kAuthentication, - srtpKey1); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.encryption->EnableSRTPReceive( + tbChannel.videoChannel, webrtc::kCipherNull, 0, webrtc::kAuthHmacSha1, + 20, 4, webrtc::kAuthentication, srtpKey1)); + EXPECT_EQ(0, ViE.encryption->EnableSRTPSend( + tbChannel.videoChannel, webrtc::kCipherNull, 0, webrtc::kAuthHmacSha1, + 20, 4, webrtc::kAuthentication, srtpKey1)); + ViETest::Log("SRTP authentication only"); AutoTestSleep(KAutoTestSleepTimeMs); - error = ViE.encryption->DisableSRTPReceive(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.encryption->DisableSRTPSend(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.encryption->DisableSRTPReceive(tbChannel.videoChannel)); + EXPECT_EQ(0, ViE.encryption->DisableSRTPSend(tbChannel.videoChannel)); // Full protection - error = ViE.encryption->EnableSRTPReceive( + EXPECT_EQ(0, ViE.encryption->EnableSRTPReceive( tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30, webrtc::kAuthHmacSha1, 20, 4, webrtc::kEncryptionAndAuthentication, - srtpKey1); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.encryption->EnableSRTPSend( + srtpKey1)); + EXPECT_EQ(0, ViE.encryption->EnableSRTPSend( tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30, webrtc::kAuthHmacSha1, 20, 4, webrtc::kEncryptionAndAuthentication, - srtpKey1); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + srtpKey1)); + ViETest::Log("SRTP full protection"); AutoTestSleep(KAutoTestSleepTimeMs); - error = ViE.encryption->DisableSRTPReceive(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.encryption->DisableSRTPSend(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.encryption->DisableSRTPReceive(tbChannel.videoChannel)); + EXPECT_EQ(0, ViE.encryption->DisableSRTPSend(tbChannel.videoChannel)); // Change receive key, but not send key... - error = ViE.encryption->EnableSRTPReceive( + EXPECT_EQ(0, ViE.encryption->EnableSRTPReceive( tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30, webrtc::kAuthHmacSha1, 20, 4, webrtc::kEncryptionAndAuthentication, - srtpKey2); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.encryption->EnableSRTPSend( + srtpKey2)); + + EXPECT_EQ(0, ViE.encryption->EnableSRTPSend( tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30, webrtc::kAuthHmacSha1, 20, 4, webrtc::kEncryptionAndAuthentication, - srtpKey1); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + srtpKey1)); + ViETest::Log( "\nSRTP receive key changed, you should not see any remote images"); AutoTestSleep(KAutoTestSleepTimeMs); // Change send key too - error = ViE.encryption->DisableSRTPSend(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.encryption->EnableSRTPSend( + EXPECT_EQ(0, ViE.encryption->DisableSRTPSend(tbChannel.videoChannel)); + EXPECT_EQ(0, ViE.encryption->EnableSRTPSend( tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30, webrtc::kAuthHmacSha1, 20, 4, webrtc::kEncryptionAndAuthentication, - srtpKey2); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + srtpKey2)); + ViETest::Log("\nSRTP send key changed too, you should see remote video " "again with some decoding artefacts at start"); AutoTestSleep(KAutoTestSleepTimeMs); - error = ViE.encryption->DisableSRTPReceive(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.encryption->DisableSRTPReceive(tbChannel.videoChannel)); // Disable receive, keep send ViETest::Log("SRTP receive disabled , you shouldn't see any video"); AutoTestSleep(KAutoTestSleepTimeMs); - error = ViE.encryption->DisableSRTPSend(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.encryption->DisableSRTPSend(tbChannel.videoChannel)); #endif //WEBRTC_SRTP // // External encryption // ViEAutotestEncryption testEncryption; - error = ViE.encryption->RegisterExternalEncryption(tbChannel.videoChannel, - testEncryption); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.encryption->RegisterExternalEncryption( + tbChannel.videoChannel, testEncryption)); ViETest::Log( "External encryption/decryption added, you should still see video"); AutoTestSleep(KAutoTestSleepTimeMs); - error = ViE.encryption->DeregisterExternalEncryption( - tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.encryption->DeregisterExternalEncryption( + tbChannel.videoChannel)); //*************************************************************** // Testing finished. Tear down Video Engine //*************************************************************** - - - if (numberOfErrors > 0) - { - // Test failed - ViETest::Log(" "); - ViETest::Log(" ERROR ViEEncryption Extended Test FAILED!"); - ViETest::Log(" Number of errors: %d", numberOfErrors); - ViETest::Log("========================================"); - ViETest::Log(" "); - return numberOfErrors; - } - - ViETest::Log(" "); - ViETest::Log(" ViEEncryption Extended Test PASSED!"); - ViETest::Log("========================================"); - ViETest::Log(" "); - return 0; } -int ViEAutoTest::ViEEncryptionAPITest() +void ViEAutoTest::ViEEncryptionAPITest() { - ViETest::Log(" "); - ViETest::Log("========================================"); - ViETest::Log(" ViEEncryption API Test\n"); - //*************************************************************** // Begin create/initialize WebRTC Video Engine for testing //*************************************************************** - - int error = 0; - int numberOfErrors = 0; - //*************************************************************** // Engine ready. Begin testing class //*************************************************************** // Create VIE - TbInterfaces ViE("ViEEncryptionAPITest", numberOfErrors); + TbInterfaces ViE("ViEEncryptionAPITest"); // Create a video channel - tbVideoChannel tbChannel(ViE, numberOfErrors, webrtc::kVideoCodecVP8); + TbVideoChannel tbChannel(ViE, webrtc::kVideoCodecVP8); // Create a capture device - TbCaptureDevice tbCapture(ViE, numberOfErrors); + TbCaptureDevice tbCapture(ViE); // Connect to channel tbCapture.ConnectTo(tbChannel.videoChannel); @@ -498,401 +346,232 @@ int ViEAutoTest::ViEEncryptionAPITest() // // Incorrect input argument, complete protection not enabled - error = ViE.encryption->EnableSRTPSend( + EXPECT_NE(0, ViE.encryption->EnableSRTPSend( tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30, - webrtc::kAuthHmacSha1, 20, 4, webrtc::kNoProtection, srtpKey); - numberOfErrors += ViETest::TestError(error != 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.encryption->EnableSRTPSend( + webrtc::kAuthHmacSha1, 20, 4, webrtc::kNoProtection, srtpKey)); + EXPECT_NE(0, ViE.encryption->EnableSRTPSend( tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30, - webrtc::kAuthHmacSha1, 20, 4, webrtc::kEncryption, srtpKey); - numberOfErrors += ViETest::TestError(error != 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.encryption->EnableSRTPSend( + webrtc::kAuthHmacSha1, 20, 4, webrtc::kEncryption, srtpKey)); + EXPECT_NE(0, ViE.encryption->EnableSRTPSend( tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30, - webrtc::kAuthHmacSha1, 20, 4, webrtc::kAuthentication, srtpKey); - numberOfErrors += ViETest::TestError(error != 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + webrtc::kAuthHmacSha1, 20, 4, webrtc::kAuthentication, srtpKey)); // Incorrect cipher key length - error = ViE.encryption->EnableSRTPSend( + EXPECT_NE(0, ViE.encryption->EnableSRTPSend( tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 15, webrtc::kAuthHmacSha1, 20, 4, webrtc::kEncryptionAndAuthentication, - srtpKey); - numberOfErrors += ViETest::TestError(error != 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.encryption->EnableSRTPSend( + srtpKey)); + EXPECT_NE(0, ViE.encryption->EnableSRTPSend( tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 257, webrtc::kAuthHmacSha1, 20, 4, webrtc::kEncryptionAndAuthentication, - srtpKey); - numberOfErrors += ViETest::TestError(error != 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.encryption->EnableSRTPSend( + srtpKey)); + EXPECT_NE(0, ViE.encryption->EnableSRTPSend( tbChannel.videoChannel, webrtc::kCipherNull, 15, webrtc::kAuthHmacSha1, - 20, 4, webrtc::kEncryptionAndAuthentication, srtpKey); - numberOfErrors += ViETest::TestError(error != 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.encryption->EnableSRTPSend( + 20, 4, webrtc::kEncryptionAndAuthentication, srtpKey)); + + EXPECT_NE(0, ViE.encryption->EnableSRTPSend( tbChannel.videoChannel, webrtc::kCipherNull, 257, webrtc::kAuthHmacSha1, - 20, 4, webrtc::kEncryptionAndAuthentication, srtpKey); - numberOfErrors += ViETest::TestError(error != 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + 20, 4, webrtc::kEncryptionAndAuthentication, srtpKey)); // Incorrect auth key length - error = ViE.encryption->EnableSRTPSend( + EXPECT_NE(0, ViE.encryption->EnableSRTPSend( tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30, webrtc::kAuthHmacSha1, 21, 4, webrtc::kEncryptionAndAuthentication, - srtpKey); - numberOfErrors += ViETest::TestError(error != 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.encryption->EnableSRTPSend( + srtpKey)); + EXPECT_NE(0, ViE.encryption->EnableSRTPSend( tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30, webrtc::kAuthNull, 257, 4, webrtc::kEncryptionAndAuthentication, - srtpKey); - numberOfErrors += ViETest::TestError(error != 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.encryption->EnableSRTPSend( + srtpKey)); + EXPECT_NE(0, ViE.encryption->EnableSRTPSend( tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30, webrtc::kAuthHmacSha1, 20, 21, webrtc::kEncryptionAndAuthentication, - srtpKey); - numberOfErrors += ViETest::TestError(error != 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.encryption->EnableSRTPSend( + srtpKey)); + EXPECT_NE(0, ViE.encryption->EnableSRTPSend( tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30, webrtc::kAuthNull, 20, 13, webrtc::kEncryptionAndAuthentication, - srtpKey); - numberOfErrors += ViETest::TestError(error != 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + srtpKey)); // NULL input - error = ViE.encryption->EnableSRTPSend( + EXPECT_NE(0, ViE.encryption->EnableSRTPSend( tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30, webrtc::kAuthHmacSha1, 20, 4, webrtc::kEncryptionAndAuthentication, - NULL); - numberOfErrors += ViETest::TestError(error != 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + NULL)); // Double enable and disable - error = ViE.encryption->EnableSRTPSend( + EXPECT_EQ(0, ViE.encryption->EnableSRTPSend( tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30, webrtc::kAuthHmacSha1, 20, 4, webrtc::kEncryptionAndAuthentication, - srtpKey); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.encryption->EnableSRTPSend( + srtpKey)); + EXPECT_NE(0, ViE.encryption->EnableSRTPSend( tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30, webrtc::kAuthHmacSha1, 20, 4, webrtc::kEncryptionAndAuthentication, - srtpKey); - numberOfErrors += ViETest::TestError(error == -1, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.encryption->DisableSRTPSend(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.encryption->DisableSRTPSend(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + srtpKey)); + + // Note(qhogpat): the second check is likely incorrect. + EXPECT_EQ(0, ViE.encryption->DisableSRTPSend(tbChannel.videoChannel)); + EXPECT_EQ(0, ViE.encryption->DisableSRTPSend(tbChannel.videoChannel)); // No protection - error = ViE.encryption->EnableSRTPSend(tbChannel.videoChannel, - webrtc::kCipherNull, 0, - webrtc::kAuthNull, 0, 0, - webrtc::kNoProtection, - srtpKey); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.encryption->DisableSRTPSend(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.encryption->EnableSRTPSend( + tbChannel.videoChannel, webrtc::kCipherNull, 0, webrtc::kAuthNull, 0, 0, + webrtc::kNoProtection, srtpKey)); + EXPECT_EQ(0, ViE.encryption->DisableSRTPSend(tbChannel.videoChannel)); // Authentication only - error = ViE.encryption->EnableSRTPSend(tbChannel.videoChannel, - webrtc::kCipherNull, 0, - webrtc::kAuthHmacSha1, 20, 4, - webrtc::kAuthentication, - srtpKey); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.encryption->DisableSRTPSend(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.encryption->EnableSRTPSend(tbChannel.videoChannel, - webrtc::kCipherNull, 0, - webrtc::kAuthHmacSha1, 1, 4, - webrtc::kAuthentication, - srtpKey); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.encryption->DisableSRTPSend(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.encryption->EnableSRTPSend(tbChannel.videoChannel, - webrtc::kCipherNull, 0, - webrtc::kAuthHmacSha1, 20, 20, - webrtc::kAuthentication, - srtpKey); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.encryption->DisableSRTPSend(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.encryption->EnableSRTPSend(tbChannel.videoChannel, - webrtc::kCipherNull, 0, - webrtc::kAuthHmacSha1, 1, 1, - webrtc::kAuthentication, - srtpKey); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.encryption->DisableSRTPSend(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.encryption->EnableSRTPSend( + tbChannel.videoChannel, webrtc::kCipherNull, 0, webrtc::kAuthHmacSha1, + 20, 4, webrtc::kAuthentication, srtpKey)); + EXPECT_EQ(0, ViE.encryption->DisableSRTPSend(tbChannel.videoChannel)); + EXPECT_EQ(0, ViE.encryption->EnableSRTPSend( + tbChannel.videoChannel, webrtc::kCipherNull, 0, webrtc::kAuthHmacSha1, + 1, 4, webrtc::kAuthentication, srtpKey)); + EXPECT_EQ(0, ViE.encryption->DisableSRTPSend(tbChannel.videoChannel)); + EXPECT_EQ(0, ViE.encryption->EnableSRTPSend( + tbChannel.videoChannel, webrtc::kCipherNull, 0, webrtc::kAuthHmacSha1, + 20, 20, webrtc::kAuthentication, srtpKey)); + EXPECT_EQ(0, ViE.encryption->DisableSRTPSend(tbChannel.videoChannel)); + EXPECT_EQ(0, ViE.encryption->EnableSRTPSend( + tbChannel.videoChannel, webrtc::kCipherNull, 0, webrtc::kAuthHmacSha1, + 1, 1, webrtc::kAuthentication, srtpKey)); + EXPECT_EQ(0, ViE.encryption->DisableSRTPSend(tbChannel.videoChannel)); // Encryption only - error = ViE.encryption->EnableSRTPSend( + EXPECT_EQ(0, ViE.encryption->EnableSRTPSend( tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30, - webrtc::kAuthNull, 0, 0, webrtc::kEncryption, srtpKey); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.encryption->DisableSRTPSend(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.encryption->EnableSRTPSend( + webrtc::kAuthNull, 0, 0, webrtc::kEncryption, srtpKey)); + EXPECT_EQ(0, ViE.encryption->DisableSRTPSend(tbChannel.videoChannel)); + EXPECT_EQ(0, ViE.encryption->EnableSRTPSend( tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 16, - webrtc::kAuthNull, 0, 0, webrtc::kEncryption, srtpKey); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.encryption->DisableSRTPSend(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + webrtc::kAuthNull, 0, 0, webrtc::kEncryption, srtpKey)); + EXPECT_EQ(0, ViE.encryption->DisableSRTPSend(tbChannel.videoChannel)); // Full protection - error = ViE.encryption->EnableSRTPSend( + EXPECT_EQ(0, ViE.encryption->EnableSRTPSend( tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30, webrtc::kAuthHmacSha1, 20, 4, webrtc::kEncryptionAndAuthentication, - srtpKey); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.encryption->DisableSRTPSend(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + srtpKey)); + EXPECT_EQ(0, ViE.encryption->DisableSRTPSend(tbChannel.videoChannel)); // // EnableSRTPReceive and DisableSRTPReceive // // Incorrect input argument, complete protection not enabled - error = ViE.encryption->EnableSRTPReceive( + EXPECT_NE(0, ViE.encryption->EnableSRTPReceive( tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30, - webrtc::kAuthHmacSha1, 20, 4, webrtc::kNoProtection, srtpKey); - numberOfErrors += ViETest::TestError(error != 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.encryption->EnableSRTPReceive( + webrtc::kAuthHmacSha1, 20, 4, webrtc::kNoProtection, srtpKey)); + EXPECT_NE(0, ViE.encryption->EnableSRTPReceive( tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30, - webrtc::kAuthHmacSha1, 20, 4, webrtc::kEncryption, srtpKey); - numberOfErrors += ViETest::TestError(error != 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.encryption->EnableSRTPReceive( + webrtc::kAuthHmacSha1, 20, 4, webrtc::kEncryption, srtpKey)); + EXPECT_NE(0, ViE.encryption->EnableSRTPReceive( tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30, - webrtc::kAuthHmacSha1, 20, 4, webrtc::kAuthentication, srtpKey); - numberOfErrors += ViETest::TestError(error != 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + webrtc::kAuthHmacSha1, 20, 4, webrtc::kAuthentication, srtpKey)); // Incorrect cipher key length - error = ViE.encryption->EnableSRTPReceive( + EXPECT_NE(0, ViE.encryption->EnableSRTPReceive( tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 15, webrtc::kAuthHmacSha1, 20, 4, webrtc::kEncryptionAndAuthentication, - srtpKey); - numberOfErrors += ViETest::TestError(error != 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.encryption->EnableSRTPReceive( + srtpKey)); + EXPECT_NE(0, ViE.encryption->EnableSRTPReceive( tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 257, webrtc::kAuthHmacSha1, 20, 4, webrtc::kEncryptionAndAuthentication, - srtpKey); - numberOfErrors += ViETest::TestError(error != 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.encryption->EnableSRTPReceive( + srtpKey)); + EXPECT_NE(0, ViE.encryption->EnableSRTPReceive( tbChannel.videoChannel, webrtc::kCipherNull, 15, webrtc::kAuthHmacSha1, - 20, 4, webrtc::kEncryptionAndAuthentication, srtpKey); - numberOfErrors += ViETest::TestError(error != 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.encryption->EnableSRTPReceive( + 20, 4, webrtc::kEncryptionAndAuthentication, srtpKey)); + EXPECT_NE(0, ViE.encryption->EnableSRTPReceive( tbChannel.videoChannel, webrtc::kCipherNull, 257, webrtc::kAuthHmacSha1, - 20, 4, webrtc::kEncryptionAndAuthentication, srtpKey); - numberOfErrors += ViETest::TestError(error != 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + 20, 4, webrtc::kEncryptionAndAuthentication, srtpKey)); // Incorrect auth key length - error = ViE.encryption->EnableSRTPReceive( + EXPECT_NE(0, ViE.encryption->EnableSRTPReceive( tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30, webrtc::kAuthHmacSha1, 21, 4, webrtc::kEncryptionAndAuthentication, - srtpKey); - numberOfErrors += ViETest::TestError(error != 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.encryption->EnableSRTPReceive( + srtpKey)); + EXPECT_NE(0, ViE.encryption->EnableSRTPReceive( tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30, webrtc::kAuthNull, 257, 4, webrtc::kEncryptionAndAuthentication, - srtpKey); - numberOfErrors += ViETest::TestError(error != 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.encryption->EnableSRTPReceive( + srtpKey)); + EXPECT_NE(0, ViE.encryption->EnableSRTPReceive( tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30, webrtc::kAuthHmacSha1, 20, 21, webrtc::kEncryptionAndAuthentication, - srtpKey); - numberOfErrors += ViETest::TestError(error != 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.encryption->EnableSRTPReceive( + srtpKey)); + EXPECT_NE(0, ViE.encryption->EnableSRTPReceive( tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30, webrtc::kAuthNull, 20, 13, webrtc::kEncryptionAndAuthentication, - srtpKey); - numberOfErrors += ViETest::TestError(error != 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + srtpKey)); // NULL input - error = ViE.encryption->EnableSRTPReceive( + EXPECT_NE(0, ViE.encryption->EnableSRTPReceive( tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30, webrtc::kAuthHmacSha1, 20, 4, webrtc::kEncryptionAndAuthentication, - NULL); - numberOfErrors += ViETest::TestError(error != 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + NULL)); // Double enable and disable - error = ViE.encryption->EnableSRTPSend( + EXPECT_EQ(0, ViE.encryption->EnableSRTPSend( tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30, webrtc::kAuthHmacSha1, 20, 4, webrtc::kEncryptionAndAuthentication, - srtpKey); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.encryption->EnableSRTPSend( + srtpKey)); + EXPECT_NE(0, ViE.encryption->EnableSRTPSend( tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30, webrtc::kAuthHmacSha1, 20, 4, webrtc::kEncryptionAndAuthentication, - srtpKey); - numberOfErrors += ViETest::TestError(error == -1, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.encryption->DisableSRTPSend(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.encryption->DisableSRTPSend(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + srtpKey)); + EXPECT_EQ(0, ViE.encryption->DisableSRTPSend(tbChannel.videoChannel)); + EXPECT_EQ(0, ViE.encryption->DisableSRTPSend(tbChannel.videoChannel)); // No protection - error = ViE.encryption->EnableSRTPReceive(tbChannel.videoChannel, - webrtc::kCipherNull, 0, - webrtc::kAuthNull, 0, 0, - webrtc::kNoProtection, - srtpKey); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.encryption->DisableSRTPReceive(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.encryption->EnableSRTPReceive( + tbChannel.videoChannel, webrtc::kCipherNull, 0, webrtc::kAuthNull, 0, 0, + webrtc::kNoProtection, srtpKey)); + EXPECT_EQ(0, ViE.encryption->DisableSRTPReceive(tbChannel.videoChannel)); // Authentication only - - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.encryption->DisableSRTPReceive(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.encryption->EnableSRTPReceive(tbChannel.videoChannel, - webrtc::kCipherNull, 0, - webrtc::kAuthHmacSha1, 1, 4, - webrtc::kAuthentication, - srtpKey); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.encryption->DisableSRTPReceive(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.encryption->EnableSRTPReceive(tbChannel.videoChannel, - webrtc::kCipherNull, 0, - webrtc::kAuthHmacSha1, 20, - 20, webrtc::kAuthentication, - srtpKey); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.encryption->DisableSRTPReceive(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.encryption->EnableSRTPReceive(tbChannel.videoChannel, - webrtc::kCipherNull, 0, - webrtc::kAuthHmacSha1, 1, 1, - webrtc::kAuthentication, - srtpKey); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.encryption->DisableSRTPReceive(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.encryption->DisableSRTPReceive(tbChannel.videoChannel)); + EXPECT_EQ(0, ViE.encryption->EnableSRTPReceive( + tbChannel.videoChannel, webrtc::kCipherNull, 0, webrtc::kAuthHmacSha1, + 1, 4, webrtc::kAuthentication, srtpKey)); + EXPECT_EQ(0, ViE.encryption->DisableSRTPReceive(tbChannel.videoChannel)); + EXPECT_EQ(0, ViE.encryption->EnableSRTPReceive( + tbChannel.videoChannel, webrtc::kCipherNull, 0, + webrtc::kAuthHmacSha1, 20, 20, webrtc::kAuthentication, srtpKey)); + EXPECT_EQ(0, ViE.encryption->DisableSRTPReceive(tbChannel.videoChannel)); + EXPECT_EQ(0, ViE.encryption->EnableSRTPReceive( + tbChannel.videoChannel, webrtc::kCipherNull, 0, webrtc::kAuthHmacSha1, + 1, 1, webrtc::kAuthentication, srtpKey)); + EXPECT_EQ(0, ViE.encryption->DisableSRTPReceive(tbChannel.videoChannel)); // Encryption only - error = ViE.encryption->EnableSRTPReceive( + EXPECT_EQ(0, ViE.encryption->EnableSRTPReceive( tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30, - webrtc::kAuthNull, 0, 0, webrtc::kEncryption, srtpKey); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.encryption->DisableSRTPReceive(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.encryption->EnableSRTPReceive( + webrtc::kAuthNull, 0, 0, webrtc::kEncryption, srtpKey)); + EXPECT_EQ(0, ViE.encryption->DisableSRTPReceive(tbChannel.videoChannel)); + EXPECT_EQ(0, ViE.encryption->EnableSRTPReceive( tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 16, - webrtc::kAuthNull, 0, 0, webrtc::kEncryption, srtpKey); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.encryption->DisableSRTPReceive(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + webrtc::kAuthNull, 0, 0, webrtc::kEncryption, srtpKey)); + EXPECT_EQ(0, ViE.encryption->DisableSRTPReceive(tbChannel.videoChannel)); // Full protection - error = ViE.encryption->EnableSRTPReceive( + EXPECT_EQ(0, ViE.encryption->EnableSRTPReceive( tbChannel.videoChannel, webrtc::kCipherAes128CounterMode, 30, webrtc::kAuthHmacSha1, 20, 4, webrtc::kEncryptionAndAuthentication, - srtpKey); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.encryption->DisableSRTPReceive(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + srtpKey)); + EXPECT_EQ(0, ViE.encryption->DisableSRTPReceive(tbChannel.videoChannel)); #endif //WEBRTC_SRTP // // External encryption // ViEAutotestEncryption testEncryption; - error = ViE.encryption->RegisterExternalEncryption( - tbChannel.videoChannel, testEncryption); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.encryption->RegisterExternalEncryption( - tbChannel.videoChannel, testEncryption); - numberOfErrors += ViETest::TestError(error == -1, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.encryption->DeregisterExternalEncryption( - tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.encryption->DeregisterExternalEncryption( - tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.encryption->RegisterExternalEncryption( + tbChannel.videoChannel, testEncryption)); + EXPECT_NE(0, ViE.encryption->RegisterExternalEncryption( + tbChannel.videoChannel, testEncryption)); + EXPECT_EQ(0, ViE.encryption->DeregisterExternalEncryption( + tbChannel.videoChannel)); + EXPECT_EQ(0, ViE.encryption->DeregisterExternalEncryption( + tbChannel.videoChannel)); //*************************************************************** // Testing finished. Tear down Video Engine //*************************************************************** - - if (numberOfErrors > 0) - { - // Test failed - ViETest::Log(" "); - ViETest::Log(" ERROR ViEEncryption API Test FAILED!"); - ViETest::Log(" Number of errors: %d", numberOfErrors); - ViETest::Log("========================================"); - ViETest::Log(" "); - return numberOfErrors; - } - - ViETest::Log(" "); - ViETest::Log(" ViEEncryption API Test PASSED!"); - ViETest::Log("========================================"); - ViETest::Log(" "); - return 0; } diff --git a/src/video_engine/test/auto_test/source/vie_autotest_file.cc b/src/video_engine/test/auto_test/source/vie_autotest_file.cc index b6fdd2609..afb73685f 100644 --- a/src/video_engine/test/auto_test/source/vie_autotest_file.cc +++ b/src/video_engine/test/auto_test/source/vie_autotest_file.cc @@ -33,26 +33,16 @@ public: } }; -int ViEAutoTest::ViEFileStandardTest() +void ViEAutoTest::ViEFileStandardTest() { - ViETest::Log(" "); - ViETest::Log("========================================"); - ViETest::Log(" ViEFile Standard Test\n"); - #ifdef WEBRTC_VIDEO_ENGINE_FILE_API //*************************************************************** // Begin create/initialize WebRTC Video Engine for testing //*************************************************************** - - - int error = 0; - int numberOfErrors = 0; - { ViETest::Log("Starting a loopback call..."); - TbInterfaces interfaces = TbInterfaces("ViEFileStandardTest", - numberOfErrors); + TbInterfaces interfaces = TbInterfaces("ViEFileStandardTest"); webrtc::VideoEngine* ptrViE = interfaces.video_engine; webrtc::ViEBase* ptrViEBase = interfaces.base; @@ -62,112 +52,50 @@ int ViEAutoTest::ViEFileStandardTest() webrtc::ViERTP_RTCP* ptrViERtpRtcp = interfaces.rtp_rtcp; webrtc::ViENetwork* ptrViENetwork = interfaces.network; - TbCaptureDevice captureDevice = TbCaptureDevice(interfaces, - numberOfErrors); + TbCaptureDevice captureDevice = TbCaptureDevice(interfaces); int captureId = captureDevice.captureId; int videoChannel = -1; - error = ptrViEBase->CreateChannel(videoChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ptrViEBase->CreateChannel(videoChannel)); + EXPECT_EQ(0, ptrViECapture->ConnectCaptureDevice( + captureId, videoChannel)); - error = ptrViECapture->ConnectCaptureDevice(captureId, videoChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ptrViERtpRtcp->SetRTCPStatus( + videoChannel, webrtc::kRtcpCompound_RFC4585)); + EXPECT_EQ(0, ptrViERtpRtcp->SetKeyFrameRequestMethod( + videoChannel, webrtc::kViEKeyFrameRequestPliRtcp)); + EXPECT_EQ(0, ptrViERtpRtcp->SetTMMBRStatus(videoChannel, true)); - error = ptrViERtpRtcp->SetRTCPStatus(videoChannel, - webrtc::kRtcpCompound_RFC4585); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); - - error = ptrViERtpRtcp->SetKeyFrameRequestMethod( - videoChannel, webrtc::kViEKeyFrameRequestPliRtcp); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); - - error = ptrViERtpRtcp->SetTMMBRStatus(videoChannel, true); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); - - error = ptrViERender->AddRenderer(captureId, _window1, 0, 0.0, 0.0, - 1.0, 1.0); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); - - error = ptrViERender->AddRenderer(videoChannel, _window2, 1, 0.0, 0.0, - 1.0, 1.0); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); - - error = ptrViERender->StartRender(captureId); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); - - error = ptrViERender->StartRender(videoChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ptrViERender->AddRenderer( + captureId, _window1, 0, 0.0, 0.0, 1.0, 1.0)); + EXPECT_EQ(0, ptrViERender->AddRenderer( + videoChannel, _window2, 1, 0.0, 0.0, 1.0, 1.0)); + EXPECT_EQ(0, ptrViERender->StartRender(captureId)); + EXPECT_EQ(0, ptrViERender->StartRender(videoChannel)); webrtc::VideoCodec videoCodec; memset(&videoCodec, 0, sizeof(webrtc::VideoCodec)); for (int idx = 0; idx < ptrViECodec->NumberOfCodecs(); idx++) { - error = ptrViECodec->GetCodec(idx, videoCodec); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); - - error = ptrViECodec->SetReceiveCodec(videoChannel, videoCodec); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ptrViECodec->GetCodec(idx, videoCodec)); + EXPECT_EQ(0, ptrViECodec->SetReceiveCodec(videoChannel, + videoCodec)); } // Find the codec used for encoding the channel for (int idx = 0; idx < ptrViECodec->NumberOfCodecs(); idx++) { - error = ptrViECodec->GetCodec(idx, videoCodec); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ptrViECodec->GetCodec(idx, videoCodec)); if (videoCodec.codecType == webrtc::kVideoCodecVP8) { - error = ptrViECodec->SetSendCodec(videoChannel, videoCodec); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ptrViECodec->SetSendCodec(videoChannel, videoCodec)); break; } } // Find the codec used for recording. for (int idx = 0; idx < ptrViECodec->NumberOfCodecs(); idx++) { - error = ptrViECodec->GetCodec(idx, videoCodec); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ptrViECodec->GetCodec(idx, videoCodec)); if (videoCodec.codecType == webrtc::kVideoCodecI420) { break; @@ -177,36 +105,13 @@ int ViEAutoTest::ViEFileStandardTest() const char* ipAddress = "127.0.0.1"; const unsigned short rtpPort = 6000; - error = ptrViENetwork->SetLocalReceiver(videoChannel, rtpPort); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); - - error = ptrViEBase->StartReceive(videoChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); - - error = ptrViENetwork->SetSendDestination(videoChannel, ipAddress, - rtpPort); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); - - error = ptrViEBase->StartSend(videoChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); - + EXPECT_EQ(0, ptrViENetwork->SetLocalReceiver(videoChannel, rtpPort)); + EXPECT_EQ(0, ptrViEBase->StartReceive(videoChannel)); + EXPECT_EQ(0, ptrViENetwork->SetSendDestination( + videoChannel, ipAddress, rtpPort)); + EXPECT_EQ(0, ptrViEBase->StartSend(videoChannel)); webrtc::ViEFile* ptrViEFile = webrtc::ViEFile::GetInterface(ptrViE); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); + EXPECT_TRUE(ptrViEFile != NULL); webrtc::VoiceEngine* ptrVEEngine = webrtc::VoiceEngine::Create(); webrtc::VoEBase* ptrVEBase = webrtc::VoEBase::GetInterface(ptrVEEngine); @@ -245,14 +150,20 @@ int ViEAutoTest::ViEFileStandardTest() const int VIDEO_LENGTH = 5000; - const char renderStartImage[1024] = VIE_TEST_FILES_ROOT "renderStartImage.jpg"; - const char captureDeviceImage[1024] = VIE_TEST_FILES_ROOT "captureDeviceImage.jpg"; - const char renderTimeoutFile[1024] = VIE_TEST_FILES_ROOT "renderTimeoutImage.jpg"; - const char snapshotCaptureDeviceFileName[256] = VIE_TEST_FILES_ROOT - "snapshotCaptureDevice.jpg"; - const char incomingVideo[1024] = VIE_TEST_FILES_ROOT "incomingVideo.avi"; - const char outgoingVideo[1024] = VIE_TEST_FILES_ROOT "outgoingVideo.avi"; - char snapshotRenderFileName[256] = VIE_TEST_FILES_ROOT "snapshotRenderer.jpg"; + const char renderStartImage[1024] = + VIE_TEST_FILES_ROOT "renderStartImage.jpg"; + const char captureDeviceImage[1024] = + VIE_TEST_FILES_ROOT "captureDeviceImage.jpg"; + const char renderTimeoutFile[1024] = + VIE_TEST_FILES_ROOT "renderTimeoutImage.jpg"; + const char snapshotCaptureDeviceFileName[256] = + VIE_TEST_FILES_ROOT "snapshotCaptureDevice.jpg"; + const char incomingVideo[1024] = + VIE_TEST_FILES_ROOT "incomingVideo.avi"; + const char outgoingVideo[1024] = + VIE_TEST_FILES_ROOT "outgoingVideo.avi"; + char snapshotRenderFileName[256] = + VIE_TEST_FILES_ROOT "snapshotRenderer.jpg"; webrtc::ViEPicture capturePicture; webrtc::ViEPicture renderPicture; @@ -268,24 +179,14 @@ int ViEAutoTest::ViEFileStandardTest() ViETest::Log("Recording incoming video (currently no audio) for %d " "seconds", VIDEO_LENGTH); - error = ptrViEFile->StartRecordIncomingVideo(videoChannel, - incomingVideo, - webrtc::NO_AUDIO, - audioCodec2, - videoCodec); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ptrViEFile->StartRecordIncomingVideo( + videoChannel, incomingVideo, webrtc::NO_AUDIO, + audioCodec2, videoCodec)); AutoTestSleep(VIDEO_LENGTH); ViETest::Log("Stop recording incoming video"); - error = ptrViEFile->StopRecordIncomingVideo(videoChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ptrViEFile->StopRecordIncomingVideo(videoChannel)); ViETest::Log("Done\n"); } @@ -297,13 +198,8 @@ int ViEAutoTest::ViEFileStandardTest() webrtc::CodecInst fileAudioCodec; ViETest::Log("Reading video file information"); - error = ptrViEFile->GetFileInformation(incomingVideo, - fileVideoCodec, - fileAudioCodec); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ptrViEFile->GetFileInformation( + incomingVideo, fileVideoCodec, fileAudioCodec)); PrintAudioCodec(fileAudioCodec); PrintVideoCodec(fileVideoCodec); } @@ -311,23 +207,10 @@ int ViEAutoTest::ViEFileStandardTest() // testing StartPlayFile and RegisterObserver { ViETest::Log("Start playing file: %s with observer", incomingVideo); - error = ptrViEFile->StartPlayFile(incomingVideo, fileId); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ptrViEFile->StartPlayFile(incomingVideo, fileId)); ViETest::Log("Registering file observer"); - error = ptrViEFile->RegisterObserver(fileId, fileObserver); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); - + EXPECT_EQ(0, ptrViEFile->RegisterObserver(fileId, fileObserver)); ViETest::Log("Done\n"); } @@ -335,33 +218,17 @@ int ViEAutoTest::ViEFileStandardTest() { ViETest::Log("Sending video on channel"); // should fail since we are sending the capture device. - error = ptrViEFile->SendFileOnChannel(fileId, videoChannel); - numberOfErrors += ViETest::TestError(error == -1, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); + EXPECT_NE(0, ptrViEFile->SendFileOnChannel(fileId, videoChannel)); // Disconnect the camera - error = ptrViECapture->DisconnectCaptureDevice(videoChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ptrViECapture->DisconnectCaptureDevice(videoChannel)); // And try playing the file again. - error = ptrViEFile->SendFileOnChannel(fileId, videoChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ptrViEFile->SendFileOnChannel(fileId, videoChannel)); AutoTestSleep(VIDEO_LENGTH); ViETest::Log("Stopped sending video on channel"); - error = ptrViEFile->StopSendFileOnChannel(videoChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ptrViEFile->StopSendFileOnChannel(videoChannel)); ViETest::Log("Done\n"); } @@ -370,54 +237,32 @@ int ViEAutoTest::ViEFileStandardTest() // stop playing the file { ViETest::Log("Stop playing the file."); - error = ptrViEFile->StopPlayFile(fileId); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ptrViEFile->StopPlayFile(fileId)); ViETest::Log("Done\n"); } // testing StartRecordOutgoingVideo and StopRecordOutgoingVideo { // connect the camera to the output. - error = ptrViECapture->ConnectCaptureDevice(captureId, - videoChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ptrViECapture->ConnectCaptureDevice( + captureId, videoChannel)); ViETest::Log("Recording outgoing video (currently no audio) for %d " "seconds", VIDEO_LENGTH); - error = ptrViEFile->StartRecordOutgoingVideo(videoChannel, - outgoingVideo, - webrtc::NO_AUDIO, - audioCodec2, - videoCodec); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ptrViEFile->StartRecordOutgoingVideo( + videoChannel, outgoingVideo, webrtc::NO_AUDIO, + audioCodec2, videoCodec)); AutoTestSleep(VIDEO_LENGTH); ViETest::Log("Stop recording outgoing video"); - error = ptrViEFile->StopRecordOutgoingVideo(videoChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ptrViEFile->StopRecordOutgoingVideo(videoChannel)); ViETest::Log("Done\n"); } // again testing GetFileInformation { - error = ptrViEFile->GetFileInformation(incomingVideo, videoCodec, - audioCodec2); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ptrViEFile->GetFileInformation( + incomingVideo, videoCodec, audioCodec2)); PrintAudioCodec(audioCodec2); PrintVideoCodec(videoCodec); } @@ -438,13 +283,9 @@ int ViEAutoTest::ViEFileStandardTest() ViETest::Log("...1"); AutoTestSleep(1000); ViETest::Log("...Taking picture!"); - error = ptrViEFile->GetCaptureDeviceSnapshot(captureId, - capturePicture); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); - ViETest::Log("Remove paper. Picture has been taken"); + EXPECT_EQ(0, ptrViEFile->GetCaptureDeviceSnapshot( + captureId, capturePicture)); + ViETest::Log("Picture has been taken."); AutoTestSleep(TEST_SPACING); ViETest::Log("Done\n"); @@ -457,13 +298,9 @@ int ViEAutoTest::ViEFileStandardTest() ViETest::Log("Testing GetRenderSnapshot(int, char*)"); ViETest::Log("Taking snapshot of videoChannel %d", captureId); - error = ptrViEFile->GetRenderSnapshot(captureId, - snapshotRenderFileName); + EXPECT_EQ(0, ptrViEFile->GetRenderSnapshot( + captureId, snapshotRenderFileName)); ViETest::Log("Wrote image to file %s", snapshotRenderFileName); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); ViETest::Log("Done\n"); AutoTestSleep(TEST_SPACING); } @@ -471,11 +308,8 @@ int ViEAutoTest::ViEFileStandardTest() // GetRenderSnapshot { ViETest::Log("Testing GetRenderSnapshot(int, ViEPicture)"); - error = ptrViEFile->GetRenderSnapshot(captureId, renderPicture); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ptrViEFile->GetRenderSnapshot( + captureId, renderPicture)); ViETest::Log("Done\n"); } @@ -485,14 +319,10 @@ int ViEAutoTest::ViEFileStandardTest() { ViETest::Log("Testing GetCaptureDeviceSnapshot(int, char*)"); ViETest::Log("Taking snapshot from capture device %d", captureId); - error = ptrViEFile->GetCaptureDeviceSnapshot( - captureId, snapshotCaptureDeviceFileName); + EXPECT_EQ(0, ptrViEFile->GetCaptureDeviceSnapshot( + captureId, snapshotCaptureDeviceFileName)); ViETest::Log("Wrote image to file %s", snapshotCaptureDeviceFileName); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); ViETest::Log("Done\n"); } @@ -501,26 +331,13 @@ int ViEAutoTest::ViEFileStandardTest() // Testing: SetCaptureDeviceImage { ViETest::Log("Testing SetCaptureDeviceImage(int, char*)"); - error = ptrViECapture->StopCapture(captureId); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); - - error = ptrViEFile->SetCaptureDeviceImage(captureId, - captureDeviceImage); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ptrViECapture->StopCapture(captureId)); + EXPECT_EQ(0, ptrViEFile->SetCaptureDeviceImage( + captureId, captureDeviceImage)); ViETest::Log("you should see the capture device image now"); AutoTestSleep(2 * RENDER_TIMEOUT); - error = ptrViECapture->StartCapture(captureId); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ptrViECapture->StartCapture(captureId)); ViETest::Log("Done\n"); } @@ -529,26 +346,13 @@ int ViEAutoTest::ViEFileStandardTest() // Testing: SetCaptureDeviceImage { ViETest::Log("Testing SetCaptureDeviceImage(int, ViEPicture)"); - error = ptrViECapture->StopCapture(captureId); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); - - error - = ptrViEFile->SetCaptureDeviceImage(captureId, capturePicture); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ptrViECapture->StopCapture(captureId)); + EXPECT_EQ(0, ptrViEFile->SetCaptureDeviceImage( + captureId, capturePicture)); ViETest::Log("you should see the capture device image now"); AutoTestSleep(2 * RENDER_TIMEOUT); - error = ptrViECapture->StartCapture(captureId); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ptrViECapture->StartCapture(captureId)); ViETest::Log("Done\n"); } @@ -560,38 +364,17 @@ int ViEAutoTest::ViEFileStandardTest() // set render image, then stop capture and stop render to display it ViETest::Log("Stoping renderer, setting start image, then " "restarting"); - error = ptrViEFile->SetRenderStartImage(videoChannel, - renderStartImage); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); - error = ptrViECapture->StopCapture(captureId); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); - error = ptrViERender->StopRender(videoChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ptrViEFile->SetRenderStartImage( + videoChannel, renderStartImage)); + EXPECT_EQ(0, ptrViECapture->StopCapture(captureId)); + EXPECT_EQ(0, ptrViERender->StopRender(videoChannel)); ViETest::Log("Render start image should be displayed."); AutoTestSleep(RENDER_TIMEOUT); // restarting capture and render - error = ptrViECapture->StartCapture(captureId); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); - - error = ptrViERender->StartRender(videoChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ptrViECapture->StartCapture(captureId)); + EXPECT_EQ(0, ptrViERender->StartRender(videoChannel)); ViETest::Log("Done\n"); } @@ -603,37 +386,17 @@ int ViEAutoTest::ViEFileStandardTest() // set render image, then stop capture and stop render to display it ViETest::Log("Stoping renderer, setting start image, then " "restarting"); - error = ptrViEFile->SetRenderStartImage(videoChannel, - capturePicture); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); - error = ptrViECapture->StopCapture(captureId); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); - error = ptrViERender->StopRender(videoChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ptrViEFile->SetRenderStartImage( + videoChannel, capturePicture)); + EXPECT_EQ(0, ptrViECapture->StopCapture(captureId)); + EXPECT_EQ(0, ptrViERender->StopRender(videoChannel)); ViETest::Log("Render start image should be displayed."); AutoTestSleep(RENDER_TIMEOUT); // restarting capture and render - error = ptrViECapture->StartCapture(captureId); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); - error = ptrViERender->StartRender(videoChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ptrViECapture->StartCapture(captureId)); + EXPECT_EQ(0, ptrViERender->StartRender(videoChannel)); ViETest::Log("Done\n"); } @@ -645,32 +408,19 @@ int ViEAutoTest::ViEFileStandardTest() ViETest::Log("Testing SetRenderTimeoutImage(int, char*)"); ViETest::Log("Stopping capture device to induce timeout of %d ms", RENDER_TIMEOUT); - error = ptrViEFile->SetRenderTimeoutImage(videoChannel, - renderTimeoutFile, - RENDER_TIMEOUT); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ptrViEFile->SetRenderTimeoutImage( + videoChannel, renderTimeoutFile, RENDER_TIMEOUT)); // now stop sending frames to the remote renderer and wait for // timeout - error = ptrViECapture->StopCapture(captureId); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ptrViECapture->StopCapture(captureId)); AutoTestSleep(RENDER_TIMEOUT); ViETest::Log("Timeout image should be displayed now for %d ms", RENDER_TIMEOUT * 2); AutoTestSleep(RENDER_TIMEOUT * 2); // restart the capture device to undo the timeout - error = ptrViECapture->StartCapture(captureId); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ptrViECapture->StartCapture(captureId)); ViETest::Log("Restarting capture device"); AutoTestSleep(RENDER_TIMEOUT); ViETest::Log("Done\n"); @@ -685,32 +435,19 @@ int ViEAutoTest::ViEFileStandardTest() ViETest::Log("Testing SetRenderTimeoutImage(int, ViEPicture)"); ViETest::Log("Stopping capture device to induce timeout of %d", RENDER_TIMEOUT); - error = ptrViEFile->SetRenderTimeoutImage(videoChannel, - capturePicture, - RENDER_TIMEOUT); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ptrViEFile->SetRenderTimeoutImage( + videoChannel, capturePicture, RENDER_TIMEOUT)); // now stop sending frames to the remote renderer and wait for // timeout - error = ptrViECapture->StopCapture(captureId); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ptrViECapture->StopCapture(captureId)); AutoTestSleep(RENDER_TIMEOUT); ViETest::Log("Timeout image should be displayed now for %d", RENDER_TIMEOUT * 2); AutoTestSleep(RENDER_TIMEOUT * 2); // restart the capture device to undo the timeout - error = ptrViECapture->StartCapture(captureId); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ptrViECapture->StartCapture(captureId)); ViETest::Log("Restarting capture device"); ViETest::Log("Done\n"); } @@ -719,11 +456,7 @@ int ViEAutoTest::ViEFileStandardTest() { ViETest::Log("Deregistering file observer"); // Should fail since we don't observe this file. - error = ptrViEFile->DeregisterObserver(fileId, fileObserver); - numberOfErrors += ViETest::TestError(error == -1, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); + EXPECT_NE(0, ptrViEFile->DeregisterObserver(fileId, fileObserver)); } //*************************************************************** @@ -731,126 +464,26 @@ int ViEAutoTest::ViEFileStandardTest() //*************************************************************** - error = ptrViEBase->StopReceive(videoChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ptrViEBase->StopReceive(videoChannel)); + EXPECT_EQ(0, ptrViEBase->StopSend(videoChannel)); + EXPECT_EQ(0, ptrViERender->StopRender(videoChannel)); + EXPECT_EQ(0, ptrViERender->RemoveRenderer(captureId)); + EXPECT_EQ(0, ptrViERender->RemoveRenderer(videoChannel)); + EXPECT_EQ(0, ptrViECapture->DisconnectCaptureDevice(videoChannel)); + EXPECT_EQ(0, ptrViEFile->FreePicture(capturePicture)); + EXPECT_EQ(0, ptrViEFile->FreePicture(renderPicture)); + EXPECT_EQ(0, ptrViEFile->FreePicture(renderTimeoutPicture)); + EXPECT_EQ(0, ptrViEBase->DeleteChannel(videoChannel)); - error = ptrViEBase->StopSend(videoChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); - - error = ptrViERender->StopRender(videoChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); - - error = ptrViERender->RemoveRenderer(captureId); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); - - error = ptrViERender->RemoveRenderer(videoChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); - - error = ptrViECapture->DisconnectCaptureDevice(videoChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); - - error = ptrViEFile->FreePicture(capturePicture); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); - - error = ptrViEFile->FreePicture(renderPicture); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); - - error = ptrViEFile->FreePicture(renderTimeoutPicture); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); - - error = ptrViEBase->DeleteChannel(videoChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); - - int remainingInterfaces = 0; - - remainingInterfaces = ptrViEFile->Release(); - numberOfErrors += ViETest::TestError(remainingInterfaces == 0, - "ERROR:%d %s at line %d", - ptrViEBase->LastError(), - __FUNCTION__, __LINE__); - - } - if (numberOfErrors > 0) - { - // Test failed - ViETest::Log(" "); - ViETest::Log(" ERROR ViEFile API Test FAILED!"); - ViETest::Log(" Number of errors: %d", numberOfErrors); - ViETest::Log("========================================"); - ViETest::Log(" "); - return numberOfErrors; + EXPECT_EQ(0, ptrViEFile->Release()); } #endif - - ViETest::Log(" "); - ViETest::Log(" ViEFile Standard Test PASSED!"); - ViETest::Log("========================================"); - ViETest::Log(" "); - - return 0; } -int ViEAutoTest::ViEFileExtendedTest() +void ViEAutoTest::ViEFileExtendedTest() { - - ViETest::Log(" "); - ViETest::Log("========================================"); - ViETest::Log(" ViEFile Extended Test\n"); - - ViETest::Log(" "); - ViETest::Log(" ViEFile Extended Test PASSED!"); - ViETest::Log("========================================"); - ViETest::Log(" "); - return 0; } -int ViEAutoTest::ViEFileAPITest() +void ViEAutoTest::ViEFileAPITest() { - - ViETest::Log(" "); - ViETest::Log("========================================"); - ViETest::Log(" ViEFile API Test- nothing tested. Only tested in Standard test.\n"); - - //*************************************************************** - // Begin create/initialize WebRTC Video Engine for testing - //*************************************************************** - - - - - ViETest::Log(" "); - ViETest::Log(" ViEFile API Test PASSED!"); - ViETest::Log("========================================"); - ViETest::Log(" "); - return 0; } diff --git a/src/video_engine/test/auto_test/source/vie_autotest_image_process.cc b/src/video_engine/test/auto_test/source/vie_autotest_image_process.cc index 3cd49fa7f..36b38b01d 100644 --- a/src/video_engine/test/auto_test/source/vie_autotest_image_process.cc +++ b/src/video_engine/test/auto_test/source/vie_autotest_image_process.cc @@ -38,27 +38,18 @@ public: } }; -int ViEAutoTest::ViEImageProcessStandardTest() +void ViEAutoTest::ViEImageProcessStandardTest() { - ViETest::Log(" "); - ViETest::Log("========================================"); - ViETest::Log(" ViEImageProcess Standard Test\n"); - //*************************************************************** // Begin create/initialize WebRTC Video Engine for testing //*************************************************************** - - - int error = 0; - int numberOfErrors = 0; - int rtpPort = 6000; // Create VIE - TbInterfaces ViE("ViEImageProcessAPITest", numberOfErrors); + TbInterfaces ViE("ViEImageProcessAPITest"); // Create a video channel - tbVideoChannel tbChannel(ViE, numberOfErrors, webrtc::kVideoCodecVP8); + TbVideoChannel tbChannel(ViE, webrtc::kVideoCodecVP8); // Create a capture device - TbCaptureDevice tbCapture(ViE, numberOfErrors); + TbCaptureDevice tbCapture(ViE); tbCapture.ConnectTo(tbChannel.videoChannel); tbChannel.StartReceive(rtpPort); @@ -66,23 +57,12 @@ int ViEAutoTest::ViEImageProcessStandardTest() MyEffectFilter effectFilter; - error = ViE.render->AddRenderer(tbCapture.captureId, _window1, 0, - 0.0, 0.0, 1.0, 1.0); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ViE.render->StartRender(tbCapture.captureId); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ViE.render->AddRenderer(tbChannel.videoChannel, _window2, 1, - 0.0, 0.0, 1.0, 1.0); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ViE.render->StartRender(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.render->AddRenderer( + tbCapture.captureId, _window1, 0, 0.0, 0.0, 1.0, 1.0)); + EXPECT_EQ(0, ViE.render->StartRender(tbCapture.captureId)); + EXPECT_EQ(0, ViE.render->AddRenderer( + tbChannel.videoChannel, _window2, 1, 0.0, 0.0, 1.0, 1.0)); + EXPECT_EQ(0, ViE.render->StartRender(tbChannel.videoChannel)); ViETest::Log("Capture device is renderered in Window 1"); ViETest::Log("Remote stream is renderered in Window 2"); @@ -93,154 +73,80 @@ int ViEAutoTest::ViEImageProcessStandardTest() //*************************************************************** - error = ViE.image_process->RegisterCaptureEffectFilter(tbCapture.captureId, - effectFilter); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.image_process->RegisterCaptureEffectFilter( + tbCapture.captureId, effectFilter)); ViETest::Log("Black and white filter registered for capture device, " "affects both windows"); AutoTestSleep(KAutoTestSleepTimeMs); - error = ViE.image_process->DeregisterCaptureEffectFilter( - tbCapture.captureId); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.image_process->DeregisterCaptureEffectFilter( + tbCapture.captureId)); - error = ViE.image_process->RegisterRenderEffectFilter( - tbChannel.videoChannel, effectFilter); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.image_process->RegisterRenderEffectFilter( + tbChannel.videoChannel, effectFilter)); ViETest::Log("Remove capture effect filter, adding filter for incoming " "stream"); ViETest::Log("Only Window 2 should be black and white"); AutoTestSleep(KAutoTestSleepTimeMs); - error = ViE.render->StopRender(tbCapture.captureId); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ViE.render->RemoveRenderer(tbCapture.captureId); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.render->StopRender(tbCapture.captureId)); + EXPECT_EQ(0, ViE.render->RemoveRenderer(tbCapture.captureId)); int rtpPort2 = rtpPort + 100; // Create a video channel - tbVideoChannel tbChannel2(ViE, numberOfErrors, webrtc::kVideoCodecVP8); + TbVideoChannel tbChannel2(ViE, webrtc::kVideoCodecVP8); tbCapture.ConnectTo(tbChannel2.videoChannel); tbChannel2.StartReceive(rtpPort2); tbChannel2.StartSend(rtpPort2); - error = ViE.render->AddRenderer(tbChannel2.videoChannel, _window1, 1, - 0.0, 0.0, 1.0, 1.0); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ViE.render->StartRender(tbChannel2.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ViE.image_process->DeregisterRenderEffectFilter( - tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.render->AddRenderer( + tbChannel2.videoChannel, _window1, 1, 0.0, 0.0, 1.0, 1.0)); + EXPECT_EQ(0, ViE.render->StartRender(tbChannel2.videoChannel)); + EXPECT_EQ(0, ViE.image_process->DeregisterRenderEffectFilter( + tbChannel.videoChannel)); ViETest::Log("Local renderer removed, added new channel and rendering in " "Window1."); - error = ViE.image_process->RegisterCaptureEffectFilter( - tbCapture.captureId, effectFilter); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.image_process->RegisterCaptureEffectFilter( + tbCapture.captureId, effectFilter)); ViETest::Log("Black and white filter registered for capture device, " "affects both windows"); AutoTestSleep(KAutoTestSleepTimeMs); - error = ViE.image_process->DeregisterCaptureEffectFilter( - tbCapture.captureId); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.image_process->DeregisterCaptureEffectFilter( + tbCapture.captureId)); - error = ViE.image_process->RegisterSendEffectFilter( - tbChannel.videoChannel, effectFilter); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.image_process->RegisterSendEffectFilter( + tbChannel.videoChannel, effectFilter)); ViETest::Log("Capture filter removed."); ViETest::Log("Black and white filter registered for one channel, Window2 " "should be black and white"); AutoTestSleep(KAutoTestSleepTimeMs); - error = ViE.image_process->DeregisterSendEffectFilter( - tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.image_process->DeregisterSendEffectFilter( + tbChannel.videoChannel)); //*************************************************************** // Testing finished. Tear down Video Engine //*************************************************************** - - if (numberOfErrors > 0) - { - // Test failed - ViETest::Log(" "); - ViETest::Log(" ERROR ViEImageProcess Standard Test FAILED!"); - ViETest::Log(" Number of errors: %d", numberOfErrors); - ViETest::Log("========================================"); - ViETest::Log(" "); - return numberOfErrors; - } - - ViETest::Log(" "); - ViETest::Log(" ViEImageProcess Standard Test PASSED!"); - ViETest::Log("========================================"); - ViETest::Log(" "); - return 0; } -int ViEAutoTest::ViEImageProcessExtendedTest() +void ViEAutoTest::ViEImageProcessExtendedTest() { - ViETest::Log(" "); - ViETest::Log("========================================"); - ViETest::Log(" ViEImageProcess Extended Test\n"); - - int numberOfErrors = 0; - - numberOfErrors = ViEImageProcessStandardTest(); - - if (numberOfErrors > 0) - { - // Test failed - ViETest::Log(" "); - ViETest::Log(" ERROR ViEImageProcess Extended Test FAILED!"); - ViETest::Log(" Number of errors: %d", numberOfErrors); - ViETest::Log("========================================"); - ViETest::Log(" "); - return numberOfErrors; - } - - ViETest::Log(" "); - ViETest::Log(" ViEImageProcess Extended Test PASSED!"); - ViETest::Log("========================================"); - ViETest::Log(" "); - return 0; + ViEImageProcessStandardTest(); } -int ViEAutoTest::ViEImageProcessAPITest() +void ViEAutoTest::ViEImageProcessAPITest() { - ViETest::Log(" "); - ViETest::Log("========================================"); - ViETest::Log(" ViEImageProcess API Test\n"); - - int error = 0; - int numberOfErrors = 0; - - TbInterfaces ViE("ViEImageProcessAPITest", numberOfErrors); - tbVideoChannel tbChannel(ViE, numberOfErrors, webrtc::kVideoCodecVP8); - TbCaptureDevice tbCapture(ViE, numberOfErrors); + TbInterfaces ViE("ViEImageProcessAPITest"); + TbVideoChannel tbChannel(ViE, webrtc::kVideoCodecVP8); + TbCaptureDevice tbCapture(ViE); tbCapture.ConnectTo(tbChannel.videoChannel); @@ -250,165 +156,90 @@ int ViEAutoTest::ViEImageProcessAPITest() // Capture effect filter // // Add effect filter - error = ViE.image_process->RegisterCaptureEffectFilter( - tbCapture.captureId, effectFilter); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.image_process->RegisterCaptureEffectFilter( + tbCapture.captureId, effectFilter)); // Add again -> error - error = ViE.image_process->RegisterCaptureEffectFilter( - tbCapture.captureId, effectFilter); - numberOfErrors += ViETest::TestError(error != 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.image_process->DeregisterCaptureEffectFilter( - tbCapture.captureId); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_NE(0, ViE.image_process->RegisterCaptureEffectFilter( + tbCapture.captureId, effectFilter)); + EXPECT_EQ(0, ViE.image_process->DeregisterCaptureEffectFilter( + tbCapture.captureId)); + // Double deregister - error = ViE.image_process->DeregisterCaptureEffectFilter( - tbCapture.captureId); - numberOfErrors += ViETest::TestError(error != 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_NE(0, ViE.image_process->DeregisterCaptureEffectFilter( + tbCapture.captureId)); // Non-existing capture device - error = ViE.image_process->RegisterCaptureEffectFilter( - tbChannel.videoChannel, effectFilter); - numberOfErrors += ViETest::TestError(error != 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_NE(0, ViE.image_process->RegisterCaptureEffectFilter( + tbChannel.videoChannel, effectFilter)); // // Render effect filter // - error = ViE.image_process->RegisterRenderEffectFilter( - tbChannel.videoChannel, effectFilter); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.image_process->RegisterRenderEffectFilter( - tbChannel.videoChannel, effectFilter); - numberOfErrors += ViETest::TestError(error != 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.image_process->DeregisterRenderEffectFilter( - tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.image_process->DeregisterRenderEffectFilter( - tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error != 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.image_process->RegisterRenderEffectFilter( + tbChannel.videoChannel, effectFilter)); + EXPECT_NE(0, ViE.image_process->RegisterRenderEffectFilter( + tbChannel.videoChannel, effectFilter)); + EXPECT_EQ(0, ViE.image_process->DeregisterRenderEffectFilter( + tbChannel.videoChannel)); + EXPECT_NE(0, ViE.image_process->DeregisterRenderEffectFilter( + tbChannel.videoChannel)); + // Non-existing channel id - error = ViE.image_process->RegisterRenderEffectFilter( - tbCapture.captureId, effectFilter); - numberOfErrors += ViETest::TestError(error != 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_NE(0, ViE.image_process->RegisterRenderEffectFilter( + tbCapture.captureId, effectFilter)); // // Send effect filter // - error = ViE.image_process->RegisterSendEffectFilter( - tbChannel.videoChannel, effectFilter); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.image_process->RegisterSendEffectFilter( - tbChannel.videoChannel, effectFilter); - numberOfErrors += ViETest::TestError(error != 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.image_process->DeregisterSendEffectFilter( - tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.image_process->DeregisterSendEffectFilter( - tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error != 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.image_process->RegisterSendEffectFilter( - tbCapture.captureId, effectFilter); - numberOfErrors += ViETest::TestError(error != 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.image_process->RegisterSendEffectFilter( + tbChannel.videoChannel, effectFilter)); + EXPECT_NE(0, ViE.image_process->RegisterSendEffectFilter( + tbChannel.videoChannel, effectFilter)); + EXPECT_EQ(0, ViE.image_process->DeregisterSendEffectFilter( + tbChannel.videoChannel)); + EXPECT_NE(0, ViE.image_process->DeregisterSendEffectFilter( + tbChannel.videoChannel)); + EXPECT_NE(0, ViE.image_process->RegisterSendEffectFilter( + tbCapture.captureId, effectFilter)); // // Denoising // - error = ViE.image_process->EnableDenoising(tbCapture.captureId, true); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.image_process->EnableDenoising(tbCapture.captureId, true); - numberOfErrors += ViETest::TestError(error != 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.image_process->EnableDenoising(tbCapture.captureId, false); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.image_process->EnableDenoising(tbCapture.captureId, false); - numberOfErrors += ViETest::TestError(error != 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.image_process->EnableDenoising(tbChannel.videoChannel, - true); - numberOfErrors += ViETest::TestError(error != 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.image_process->EnableDenoising(tbCapture.captureId, true)); + EXPECT_NE(0, ViE.image_process->EnableDenoising(tbCapture.captureId, true)); + EXPECT_EQ(0, ViE.image_process->EnableDenoising( + tbCapture.captureId, false)); + EXPECT_NE(0, ViE.image_process->EnableDenoising( + tbCapture.captureId, false)); + EXPECT_NE(0, ViE.image_process->EnableDenoising( + tbChannel.videoChannel, true)); // // Deflickering // - error = ViE.image_process->EnableDeflickering(tbCapture.captureId, - true); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.image_process->EnableDeflickering(tbCapture.captureId, - true); - numberOfErrors += ViETest::TestError(error != 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.image_process->EnableDeflickering(tbCapture.captureId, - false); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.image_process->EnableDeflickering(tbCapture.captureId, - false); - numberOfErrors += ViETest::TestError(error != 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.image_process->EnableDeflickering(tbChannel.videoChannel, - true); - numberOfErrors += ViETest::TestError(error != 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.image_process->EnableDeflickering( + tbCapture.captureId, true)); + EXPECT_NE(0, ViE.image_process->EnableDeflickering( + tbCapture.captureId, true)); + EXPECT_EQ(0, ViE.image_process->EnableDeflickering( + tbCapture.captureId, false)); + EXPECT_NE(0, ViE.image_process->EnableDeflickering( + tbCapture.captureId, false)); + EXPECT_NE(0, ViE.image_process->EnableDeflickering( + tbChannel.videoChannel, true)); // // Color enhancement // - error = ViE.image_process->EnableColorEnhancement( - tbChannel.videoChannel, false); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.image_process->EnableColorEnhancement( - tbChannel.videoChannel, true); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.image_process->EnableColorEnhancement( - tbChannel.videoChannel, true); - numberOfErrors += ViETest::TestError(error != 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.image_process->EnableColorEnhancement( - tbChannel.videoChannel, false); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.image_process->EnableColorEnhancement( - tbChannel.videoChannel, false); - numberOfErrors += ViETest::TestError(error != 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.image_process->EnableColorEnhancement(tbCapture.captureId, - true); - numberOfErrors += ViETest::TestError(error != 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - if (numberOfErrors > 0) - { - // Test failed - ViETest::Log(" "); - ViETest::Log(" ERROR ViEImageProcess Extended Test FAILED!"); - ViETest::Log(" Number of errors: %d", numberOfErrors); - ViETest::Log("========================================"); - ViETest::Log(" "); - return numberOfErrors; - } - - ViETest::Log(" "); - ViETest::Log(" ViEImageProcess Extended Test PASSED!"); - ViETest::Log("========================================"); - ViETest::Log(" "); - return 0; + EXPECT_EQ(0, ViE.image_process->EnableColorEnhancement( + tbChannel.videoChannel, false)); + EXPECT_EQ(0, ViE.image_process->EnableColorEnhancement( + tbChannel.videoChannel, true)); + EXPECT_NE(0, ViE.image_process->EnableColorEnhancement( + tbChannel.videoChannel, true)); + EXPECT_EQ(0, ViE.image_process->EnableColorEnhancement( + tbChannel.videoChannel, false)); + EXPECT_NE(0, ViE.image_process->EnableColorEnhancement( + tbChannel.videoChannel, false)); + EXPECT_NE(0, ViE.image_process->EnableColorEnhancement( + tbCapture.captureId, true)); } diff --git a/src/video_engine/test/auto_test/source/vie_autotest_linux.cc b/src/video_engine/test/auto_test/source/vie_autotest_linux.cc index 7670694a7..d7db3637a 100644 --- a/src/video_engine/test/auto_test/source/vie_autotest_linux.cc +++ b/src/video_engine/test/auto_test/source/vie_autotest_linux.cc @@ -23,6 +23,8 @@ #include "critical_section_wrapper.h" #include "thread_wrapper.h" +DEFINE_bool(automated, false, "Run Video engine tests in noninteractive mode."); + ViEAutoTestWindowManager::ViEAutoTestWindowManager() : _hdsp1(NULL), _hdsp2(NULL) { @@ -136,24 +138,24 @@ bool ViEAutoTestWindowManager::SetTopmostWindow() { } int main(int argc, char** argv) { - // This command-line flag is a transitory solution until we - // manage to rewrite all tests to GUnit tests. This flag is - // currently only supported in Linux. - if (argc > 1 && std::string(argv[1]) == "--automated") { - // Let GTest and GFlags handle flags from now on - argc -= 1; - argv += 1; + // Initialize logging + ViETest::Init(); + // Initialize the testing framework + testing::InitGoogleTest(&argc, argv); + // Parse remaining flags: + google::ParseCommandLineFlags(&argc, &argv, true); - // Initialize the testing framework - testing::InitGoogleTest(&argc, argv); - // Parse remaining flags: - google::ParseCommandLineFlags(&argc, &argv, true); - // Run tests - return RUN_ALL_TESTS(); + int result; + if (FLAGS_automated) { + // Run in automated mode + result = RUN_ALL_TESTS(); + } else { + // Run in interactive mode + ViEAutoTestMain autoTest; + autoTest.UseAnswerFile("answers.txt"); + result = autoTest.BeginOSIndependentTesting(); } - // Default: run in classic interactive mode. - ViEAutoTestMain autoTest; - autoTest.UseAnswerFile("answers.txt"); - return autoTest.BeginOSIndependentTesting(); + ViETest::Terminate(); + return result; } diff --git a/src/video_engine/test/auto_test/source/vie_autotest_main.cc b/src/video_engine/test/auto_test/source/vie_autotest_main.cc index 631f8297b..31973996b 100644 --- a/src/video_engine/test/auto_test/source/vie_autotest_main.cc +++ b/src/video_engine/test/auto_test/source/vie_autotest_main.cc @@ -10,338 +10,209 @@ #include "vie_autotest_main.h" +#include "gtest/gtest.h" #include "vie_autotest_window_manager_interface.h" #include "vie_window_creator.h" #include "vie_autotest.h" +static const std::string kStandardTest = "ViEStandardIntegrationTest"; +static const std::string kExtendedTest = "ViEExtendedIntegrationTest"; +static const std::string kApiTest = "ViEApiIntegrationTest"; + ViEAutoTestMain::ViEAutoTestMain() - : _answers(), - _answersCount(0), - _useAnswerFile() { +: answers_(), + answers_count_(0), + use_answer_file_() { + + index_to_test_method_map_[1] = "RunsBaseTestWithoutErrors"; + index_to_test_method_map_[2] = "RunsCaptureTestWithoutErrors"; + index_to_test_method_map_[3] = "RunsCodecTestWithoutErrors"; + index_to_test_method_map_[4] = "RunsEncryptionTestWithoutErrors"; + index_to_test_method_map_[5] = "RunsFileTestWithoutErrors"; + index_to_test_method_map_[6] = "RunsImageProcessTestWithoutErrors"; + index_to_test_method_map_[7] = "RunsNetworkTestWithoutErrors"; + index_to_test_method_map_[8] = "RunsRenderTestWithoutErrors"; + index_to_test_method_map_[9] = "RunsRtpRtcpTestWithoutErrors"; +} + +int ViEAutoTestMain::AskUserForTestCase() { + int choice; + std::string answer; + + do { + ViETest::Log("\nSpecific tests:"); + ViETest::Log("\t 0. Go back to previous menu."); + + // Print all test method choices. Assumes that map sorts on its key. + int last_valid_choice; + std::map::const_iterator iterator; + for (iterator = index_to_test_method_map_.begin(); + iterator != index_to_test_method_map_.end(); + ++iterator) { + ViETest::Log("\t %d. %s", iterator->first, iterator->second.c_str()); + last_valid_choice = iterator->first; + } + + ViETest::Log("Choose specific test:"); + choice = AskUserForNumber(0, last_valid_choice); + } while (choice == kInvalidChoice); + + return choice; +} + +int ViEAutoTestMain::AskUserForNumber(int min_allowed, int max_allowed) { + int result; + if (use_answer_file_) { + assert(0 && "Answer files are not implemented"); + return kInvalidChoice; + } + + if (scanf("%d", &result) <= 0) { + ViETest::Log("\nPlease enter a number instead, then hit enter."); + getchar(); + return kInvalidChoice; + } + getchar(); // Consume enter key. + + if (result < min_allowed || result > max_allowed) { + ViETest::Log("%d-%d are valid choices. Please try again.", min_allowed, + max_allowed); + return kInvalidChoice; + } + + return result; +} + +int ViEAutoTestMain::RunTestMatching(const std::string test_case, + const std::string test_method) { + testing::FLAGS_gtest_filter = test_case + "." + test_method; + return RUN_ALL_TESTS(); +} + +int ViEAutoTestMain::RunSpecificTestCaseIn(const std::string test_case_name) +{ + // If user says 0, it means don't run anything. + int specific_choice = AskUserForTestCase(); + if (specific_choice != 0){ + return RunTestMatching(test_case_name, + index_to_test_method_map_[specific_choice]); + } + return 0; +} + +int ViEAutoTestMain::RunSpecialTestCase(int choice) { + // 7-9 don't run in GTest and need to initialize by themselves. + assert(choice >= 7 && choice <= 9); + + // Create the windows + ViEWindowCreator windowCreator; + ViEAutoTestWindowManagerInterface* windowManager = + windowCreator.CreateTwoWindows(); + + // Create the test cases + ViEAutoTest vieAutoTest(windowManager->GetWindow1(), + windowManager->GetWindow2()); + + int errors; + switch (choice) { + case 7: errors = vieAutoTest.ViELoopbackCall(); break; + case 8: errors = vieAutoTest.ViECustomCall(); break; + case 9: errors = vieAutoTest.ViESimulcastCall(); break; + } + + windowCreator.TerminateWindows(); + return errors; } bool ViEAutoTestMain::BeginOSIndependentTesting() { - // Create the windows - ViEWindowCreator windowCreator; - ViEAutoTestWindowManagerInterface* windowManager = - windowCreator.CreateTwoWindows(); - // Create the test cases - ViEAutoTest - vieAutoTest(windowManager->GetWindow1(), - windowManager->GetWindow2(), - ViETest::kUseAssertsForTestErrors); + ViETest::Log(" ============================== "); + ViETest::Log(" WebRTC ViE 3.x Autotest "); + ViETest::Log(" ============================== \n"); - ViETest::Log(" ============================== "); - ViETest::Log(" WebRTC ViE 3.x Autotest "); - ViETest::Log(" ============================== \n"); + int choice = 0; + int errors = 0; + do { + ViETest::Log("Test types: "); + ViETest::Log("\t 0. Quit"); + ViETest::Log("\t 1. All standard tests (delivery test)"); + ViETest::Log("\t 2. All API tests"); + ViETest::Log("\t 3. All extended test"); + ViETest::Log("\t 4. Specific standard test"); + ViETest::Log("\t 5. Specific API test"); + ViETest::Log("\t 6. Specific extended test"); + ViETest::Log("\t 7. Simple loopback call"); + ViETest::Log("\t 8. Custom configure a call"); + ViETest::Log("\t 9. Simulcast in loopback"); + ViETest::Log("Select type of test:"); - int testType = 0; - int testErrors = 0; - do { - ViETest::Log("Test types: "); - ViETest::Log("\t 0. Quit"); - ViETest::Log("\t 1. All standard tests (delivery test)"); - ViETest::Log("\t 2. All API tests"); - ViETest::Log("\t 3. All extended test"); - ViETest::Log("\t 4. Specific standard test"); - ViETest::Log("\t 5. Specific API test"); - ViETest::Log("\t 6. Specific extended test"); - ViETest::Log("\t 7. Simple loopback call"); - ViETest::Log("\t 8. Custom configure a call"); - ViETest::Log("\t 9. Simulcast in loopback"); - ViETest::Log("Select type of test: "); - - if (_useAnswerFile) { - // GetNextAnswer(str); - } else { - if (scanf("%d", &testType) <= 0) { - ViETest::Log("ERROR: unable to read selection. Try again\n"); - testType = -1; - getchar(); - continue; - } - getchar(); - } - ViETest::Log(""); - - if (testType < 0 || testType > 8) { - ViETest::Log("ERROR: Invalid selection. Try again\n"); - continue; - } - - switch (testType) { - case 0: - break; - - case 1: - { - int deliveryErrors = testErrors; - testErrors += vieAutoTest.ViEStandardTest(); - if (testErrors == deliveryErrors) { - // No errors found in delivery test, create delivery - ViETest::Log("Standard/delivery passed."); - } else { - // Didn't pass, don't create delivery files - ViETest::Log("\nStandard/delivery test failed!\n"); - } - break; - } - case 2: - testErrors += vieAutoTest.ViEAPITest(); - break; - - case 3: - testErrors += vieAutoTest.ViEExtendedTest(); - break; - - case 4: // Specific Standard - testType = GetClassTestSelection(); - - switch (testType) { - case 1: // base - testErrors += vieAutoTest.ViEBaseStandardTest(); - break; - - case 2: // capture - testErrors += vieAutoTest.ViECaptureStandardTest(); - break; - - case 3: // codec - testErrors += vieAutoTest.ViECodecStandardTest(); - break; - - case 5: // encryption - testErrors += vieAutoTest.ViEEncryptionStandardTest(); - break; - - case 6: // file - testErrors += vieAutoTest.ViEFileStandardTest(); - break; - - case 7: // image process - testErrors += vieAutoTest.ViEImageProcessStandardTest(); - break; - - case 8: // network - testErrors += vieAutoTest.ViENetworkStandardTest(); - break; - - case 9: // Render - testErrors += vieAutoTest.ViERenderStandardTest(); - break; - - case 10: // RTP/RTCP - testErrors += vieAutoTest.ViERtpRtcpStandardTest(); - break; - case 11: - break; - - default: - break; - } - break; - - case 5: // specific API - testType = GetClassTestSelection(); - - switch (testType) { - case 1: // base - testErrors += vieAutoTest.ViEBaseAPITest(); - break; - - case 2: // capture - testErrors += vieAutoTest.ViECaptureAPITest(); - break; - - case 3: // codec - testErrors += vieAutoTest.ViECodecAPITest(); - break; - - case 5: // encryption - testErrors += vieAutoTest.ViEEncryptionAPITest(); - break; - - case 6: // file - testErrors += vieAutoTest.ViEFileAPITest(); - break; - - case 7: // image process - testErrors += vieAutoTest.ViEImageProcessAPITest(); - break; - - case 8: // network - testErrors += vieAutoTest.ViENetworkAPITest(); - break; - - case 9: // Render - testErrors += vieAutoTest.ViERenderAPITest(); - break; - - case 10: // RTP/RTCP - testErrors += vieAutoTest.ViERtpRtcpAPITest(); - break; - case 11: - break; - default: - break; - } - break; - case 6: // specific extended - testType = GetClassTestSelection(); - - switch (testType) { - case 1: // base - testErrors += vieAutoTest.ViEBaseExtendedTest(); - break; - - case 2: // capture - testErrors += vieAutoTest.ViECaptureExtendedTest(); - break; - - case 3: // codec - testErrors += vieAutoTest.ViECodecExtendedTest(); - break; - - case 5: // encryption - testErrors += vieAutoTest.ViEEncryptionExtendedTest(); - break; - - case 6: // file - testErrors += vieAutoTest.ViEFileExtendedTest(); - break; - - case 7: // image process - testErrors += vieAutoTest.ViEImageProcessExtendedTest(); - break; - - case 8: // network - testErrors += vieAutoTest.ViENetworkExtendedTest(); - break; - - case 9: // Render - testErrors += vieAutoTest.ViERenderExtendedTest(); - break; - - case 10: // RTP/RTCP - testErrors += vieAutoTest.ViERtpRtcpExtendedTest(); - break; - case 11: - break; - - default: - break; - } - break; - case 7: - testErrors += vieAutoTest.ViELoopbackCall(); - break; - case 8: - testErrors += vieAutoTest.ViECustomCall(); - break; - case 9: - testErrors += vieAutoTest.ViESimulcastCall(); - break; - default: - ViETest::Log("ERROR: Invalid selection. Try again\n"); - continue; - } - } while (testType != 0); - - windowCreator.TerminateWindows(); - - if (testErrors) { - ViETest::Log("Test done with errors, see ViEAutotestLog.txt for test " - "result.\n"); - } else { - ViETest::Log("Test done without errors, see ViEAutotestLog.txt for " - "test result.\n"); + choice = AskUserForNumber(0, 9); + if (choice == kInvalidChoice) { + continue; } - printf("Press enter to quit..."); - char c; - while ((c = getchar()) != '\n' && c != EOF) { - /* discard */ + switch (choice) { + case 0: break; + case 1: errors = RunTestMatching(kStandardTest, "*"); break; + case 2: errors = RunTestMatching(kApiTest, "*"); break; + case 3: errors = RunTestMatching(kExtendedTest, "*"); break; + case 4: errors = RunSpecificTestCaseIn(kStandardTest); break; + case 5: errors = RunSpecificTestCaseIn(kApiTest); break; + case 6: errors = RunSpecificTestCaseIn(kExtendedTest); break; + default: errors = RunSpecialTestCase(choice); break; } + } while (choice != 0); - return true; -} - -int ViEAutoTestMain::GetClassTestSelection() { - int testType = 0; - std::string answer; - - while (1) { - ViETest::Log("Choose specific test: "); - ViETest::Log("\t 1. Base "); - ViETest::Log("\t 2. Capture"); - ViETest::Log("\t 3. Codec"); - ViETest::Log("\t 5. Encryption"); - ViETest::Log("\t 6. File"); - ViETest::Log("\t 7. Image Process"); - ViETest::Log("\t 8. Network"); - ViETest::Log("\t 9. Render"); - ViETest::Log("\t 10. RTP/RTCP"); - ViETest::Log("\t 11. Go back to previous menu"); - ViETest::Log("Select type of test: "); - - int items_read = 0; - if (_useAnswerFile) { - // GetNextAnswer(answer); - } else { - items_read = scanf("%d", &testType); - getchar(); - } - ViETest::Log("\n"); - if (items_read == 1 && testType >= 1 && testType <= 13) { - return testType; - } - ViETest::Log("ERROR: Invalid selection. Try again"); - } - - return -1; + if (errors) { + ViETest::Log("Test done with errors, see ViEAutotestLog.txt for test " + "result.\n"); + } else { + ViETest::Log("Test done without errors, see ViEAutotestLog.txt for " + "test result.\n"); + } + return true; } bool ViEAutoTestMain::GetAnswer(int index, std::string* answer) { - if (!_useAnswerFile || index > _answersCount) { - return false; - } - *answer = _answers[index]; - return true; + if (!use_answer_file_ || index > answers_count_) { + return false; + } + *answer = answers_[index]; + return true; } bool ViEAutoTestMain::IsUsingAnswerFile() { - return _useAnswerFile; + return use_answer_file_; } -// TODO(unknown): write without stl +// TODO(unknown): implement? bool ViEAutoTestMain::UseAnswerFile(const char* fileName) { - return false; - /* - _useAnswerFile = false; + return false; +/* + use_answer_file_ = false; ViETest::Log("Opening answer file: %s...", fileName); ifstream answerFile(fileName); if(!answerFile) { - ViETest::Log("failed! X(\n"); - return false; + ViETest::Log("failed! X(\n"); + return false; } - _answersCount = 1; - _answersIndex = 1; + answers_count_ = 1; + answers_index_ = 1; char lineContent[128] = ""; while(!answerFile.eof()) { - answerFile.getline(lineContent, 128); - _answers[_answersCount++] = string(lineContent); + answerFile.getline(lineContent, 128); + answers_[answers_Count++] = string(lineContent); } answerFile.close(); cout << "Success :)" << endl << endl; - _useAnswerFile = true; + use_answer_file_ = true; - return _useAnswerFile; - */ + return use_answer_file_; +*/ } diff --git a/src/video_engine/test/auto_test/source/vie_autotest_network.cc b/src/video_engine/test/auto_test/source/vie_autotest_network.cc index 8e78f9f23..e5582234c 100644 --- a/src/video_engine/test/auto_test/source/vie_autotest_network.cc +++ b/src/video_engine/test/auto_test/source/vie_autotest_network.cc @@ -33,7 +33,7 @@ public: ViEAutoTestNetworkObserver() { } - ~ViEAutoTestNetworkObserver() + virtual ~ViEAutoTestNetworkObserver() { } virtual void OnPeriodicDeadOrAlive(const int videoChannel, const bool alive) @@ -45,208 +45,112 @@ public: } }; -int ViEAutoTest::ViENetworkStandardTest() +void ViEAutoTest::ViENetworkStandardTest() { - int error = 0; - int numberOfErrors = 0; - - TbInterfaces ViE("ViENetworkStandardTest", numberOfErrors); // Create VIE - TbCaptureDevice tbCapture(ViE, numberOfErrors); - error = ViE.render->AddRenderer(tbCapture.captureId, _window1, 0, - 0.0, 0.0, 1.0, 1.0); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.render->StartRender(tbCapture.captureId); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + TbInterfaces ViE("ViENetworkStandardTest"); // Create VIE + TbCaptureDevice tbCapture(ViE); + EXPECT_EQ(0, ViE.render->AddRenderer( + tbCapture.captureId, _window1, 0, 0.0, 0.0, 1.0, 1.0)); + EXPECT_EQ(0, ViE.render->StartRender(tbCapture.captureId)); { // Create a video channel - tbVideoChannel tbChannel(ViE, numberOfErrors, webrtc::kVideoCodecVP8); + TbVideoChannel tbChannel(ViE, webrtc::kVideoCodecVP8); tbCapture.ConnectTo(tbChannel.videoChannel); - error = ViE.render->AddRenderer(tbChannel.videoChannel, _window2, - 1, 0.0, 0.0, 1.0, 1.0); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.render->StartRender(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - //*************************************************************** - // Engine ready. Begin testing class - //*************************************************************** + EXPECT_EQ(0, ViE.render->AddRenderer( + tbChannel.videoChannel, _window2, 1, 0.0, 0.0, 1.0, 1.0)); + EXPECT_EQ(0, ViE.render->StartRender(tbChannel.videoChannel)); + // *************************************************************** + // Engine ready. Begin testing class + // *************************************************************** // // Transport // TbExternalTransport testTransport(*ViE.network); - error = ViE.network->RegisterSendTransport(tbChannel.videoChannel, - testTransport); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ViE.base->StartReceive(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.base->StartSend(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error= ViE.rtp_rtcp->SetKeyFrameRequestMethod( - tbChannel.videoChannel, webrtc::kViEKeyFrameRequestPliRtcp); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.network->RegisterSendTransport( + tbChannel.videoChannel, testTransport)); + EXPECT_EQ(0, ViE.base->StartReceive(tbChannel.videoChannel)); + EXPECT_EQ(0, ViE.base->StartSend(tbChannel.videoChannel)); + EXPECT_EQ(0, ViE.rtp_rtcp->SetKeyFrameRequestMethod( + tbChannel.videoChannel, webrtc::kViEKeyFrameRequestPliRtcp)); ViETest::Log("Call started using external transport, video should " "see video in both windows\n"); AutoTestSleep(KAutoTestSleepTimeMs); - error = ViE.base->StopReceive(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.base->StopSend(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.network->DeregisterSendTransport( - tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.base->StopReceive(tbChannel.videoChannel)); + EXPECT_EQ(0, ViE.base->StopSend(tbChannel.videoChannel)); + EXPECT_EQ(0, ViE.network->DeregisterSendTransport( + tbChannel.videoChannel)); char myIpAddress[64]; memset(myIpAddress, 0, 64); unsigned short rtpPort = 1234; memcpy(myIpAddress, "127.0.0.1", sizeof("127.0.0.1")); - error = ViE.network->SetLocalReceiver(tbChannel.videoChannel, - rtpPort, rtpPort + 1, - myIpAddress); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.network->SetSendDestination(tbChannel.videoChannel, - myIpAddress, rtpPort, - rtpPort + 1, rtpPort); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.base->StartReceive(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.base->StartSend(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.network->SetLocalReceiver( + tbChannel.videoChannel, rtpPort, rtpPort + 1, myIpAddress)); + EXPECT_EQ(0, ViE.network->SetSendDestination( + tbChannel.videoChannel, myIpAddress, rtpPort, + rtpPort + 1, rtpPort)); + EXPECT_EQ(0, ViE.base->StartReceive(tbChannel.videoChannel)); + EXPECT_EQ(0, ViE.base->StartSend(tbChannel.videoChannel)); ViETest::Log("Changed to WebRTC SocketTransport, you should still see " "video in both windows\n"); AutoTestSleep(KAutoTestSleepTimeMs); - error = ViE.network->SetSourceFilter(tbChannel.videoChannel, - rtpPort + 10, rtpPort + 11, - myIpAddress); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.network->SetSourceFilter( + tbChannel.videoChannel, rtpPort + 10, rtpPort + 11, myIpAddress)); ViETest::Log("Added UDP port filter for incorrect ports, you should " "not see video in Window2"); AutoTestSleep(2000); - error = ViE.network->SetSourceFilter(tbChannel.videoChannel, - rtpPort, rtpPort + 1, - "123.1.1.0"); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.network->SetSourceFilter( + tbChannel.videoChannel, rtpPort, rtpPort + 1, "123.1.1.0")); ViETest::Log("Added IP filter for incorrect IP address, you should not " "see video in Window2"); AutoTestSleep(2000); - error = ViE.network->SetSourceFilter(tbChannel.videoChannel, - rtpPort, rtpPort + 1, - myIpAddress); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.network->SetSourceFilter( + tbChannel.videoChannel, rtpPort, rtpPort + 1, myIpAddress)); ViETest::Log("Added IP filter for this computer, you should see video " "in Window2 again\n"); AutoTestSleep(KAutoTestSleepTimeMs); tbCapture.Disconnect(tbChannel.videoChannel); } - - if (numberOfErrors > 0) - { - // Test failed - ViETest::Log(" "); - ViETest::Log(" ERROR ViENetwork Standard Test FAILED!"); - ViETest::Log(" Number of errors: %d", numberOfErrors); - ViETest::Log("========================================"); - ViETest::Log(" "); - return numberOfErrors; - } - - ViETest::Log(" "); - ViETest::Log(" ViENetwork Standard Test PASSED!"); - ViETest::Log("========================================"); - ViETest::Log(" "); - return 0; } -int ViEAutoTest::ViENetworkExtendedTest() +void ViEAutoTest::ViENetworkExtendedTest() { - ViETest::Log(" "); - ViETest::Log("========================================"); - ViETest::Log(" ViENetwork Extended Test\n"); - //*************************************************************** // Begin create/initialize WebRTC Video Engine for testing //*************************************************************** - int numberOfErrors = ViENetworkStandardTest(); - - int error = 0; - - TbInterfaces ViE("ViENetworkExtendedTest", numberOfErrors); // Create VIE - TbCaptureDevice tbCapture(ViE, numberOfErrors); - error = ViE.render->AddRenderer(tbCapture.captureId, _window1, 0, - 0.0, 0.0, 1.0, 1.0); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.render->StartRender(tbCapture.captureId); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + TbInterfaces ViE("ViENetworkExtendedTest"); // Create VIE + TbCaptureDevice tbCapture(ViE); + EXPECT_EQ(0, ViE.render->AddRenderer( + tbCapture.captureId, _window1, 0, 0.0, 0.0, 1.0, 1.0)); + EXPECT_EQ(0, ViE.render->StartRender(tbCapture.captureId)); { // // ToS // // Create a video channel - tbVideoChannel tbChannel(ViE, numberOfErrors, webrtc::kVideoCodecVP8); + TbVideoChannel tbChannel(ViE, webrtc::kVideoCodecVP8); tbCapture.ConnectTo(tbChannel.videoChannel); const char* remoteIp = "192.168.200.1"; int DSCP = 0; bool useSetSockOpt = false; webrtc::VideoCodec videoCodec; - error = ViE.codec->GetSendCodec(tbChannel.videoChannel, - videoCodec); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.codec->GetSendCodec( + tbChannel.videoChannel, videoCodec)); videoCodec.maxFramerate = 5; - error = ViE.codec->SetSendCodec(tbChannel.videoChannel, - videoCodec); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.codec->SetSendCodec( + tbChannel.videoChannel, videoCodec)); //*************************************************************** // Engine ready. Begin testing class @@ -255,26 +159,16 @@ int ViEAutoTest::ViENetworkExtendedTest() char myIpAddress[64]; memset(myIpAddress, 0, 64); unsigned short rtpPort = 9000; - error = ViE.network->GetLocalIP(myIpAddress, false); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.network->SetLocalReceiver(tbChannel.videoChannel, - rtpPort, rtpPort + 1, - myIpAddress); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.network->SetSendDestination(tbChannel.videoChannel, - remoteIp, rtpPort, - rtpPort + 1, rtpPort); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.network->GetLocalIP(myIpAddress, false)); + EXPECT_EQ(0, ViE.network->SetLocalReceiver( + tbChannel.videoChannel, rtpPort, rtpPort + 1, myIpAddress)); + EXPECT_EQ(0, ViE.network->SetSendDestination( + tbChannel.videoChannel, remoteIp, rtpPort, rtpPort + 1, rtpPort)); // ToS - error = ViE.network->SetSendToS(tbChannel.videoChannel, 2); - if (error != 0) + int tos_result = ViE.network->SetSendToS(tbChannel.videoChannel, 2); + EXPECT_EQ(0, tos_result); + if (tos_result != 0) { ViETest::Log("ViESetSendToS error!."); ViETest::Log("You must be admin to run these tests."); @@ -283,66 +177,33 @@ int ViEAutoTest::ViENetworkExtendedTest() ViETest::Log("\"Run as administrator\"\n"); getchar(); } - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.network->GetSendToS(tbChannel.videoChannel, DSCP, - useSetSockOpt); // No ToS set - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.network->GetSendToS( + tbChannel.videoChannel, DSCP, useSetSockOpt)); // No ToS set - error = ViE.base->StartReceive(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.base->StartSend(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.base->StartReceive(tbChannel.videoChannel)); + EXPECT_EQ(0, ViE.base->StartSend(tbChannel.videoChannel)); ViETest::Log("Use Wireshark to capture the outgoing video stream and " "verify ToS settings\n"); ViETest::Log(" DSCP set to 0x%x\n", DSCP); AutoTestSleep(1000); - error = ViE.network->SetSendToS(tbChannel.videoChannel, 63); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.network->GetSendToS(tbChannel.videoChannel, DSCP, - useSetSockOpt); // No ToS set - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.network->SetSendToS(tbChannel.videoChannel, 63)); + EXPECT_EQ(0, ViE.network->GetSendToS( + tbChannel.videoChannel, DSCP, useSetSockOpt)); // No ToS set ViETest::Log(" DSCP set to 0x%x\n", DSCP); AutoTestSleep(1000); - error = ViE.network->SetSendToS(tbChannel.videoChannel, 0); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.network->SetSendToS(tbChannel.videoChannel, 2, true); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.network->GetSendToS(tbChannel.videoChannel, DSCP, - useSetSockOpt); // No ToS set - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.network->SetSendToS(tbChannel.videoChannel, 0)); + EXPECT_EQ(0, ViE.network->SetSendToS(tbChannel.videoChannel, 2, true)); + EXPECT_EQ(0, ViE.network->GetSendToS( + tbChannel.videoChannel, DSCP, useSetSockOpt)); // No ToS set ViETest::Log(" DSCP set to 0x%x\n", DSCP); AutoTestSleep(1000); - error = ViE.network->SetSendToS(tbChannel.videoChannel, 63, true); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.network->GetSendToS(tbChannel.videoChannel, DSCP, - useSetSockOpt); // No ToS set - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.network->SetSendToS(tbChannel.videoChannel, 63, true)); + EXPECT_EQ(0, ViE.network->GetSendToS( + tbChannel.videoChannel, DSCP, useSetSockOpt)); // No ToS set ViETest::Log(" DSCP set to 0x%x\n", DSCP); AutoTestSleep(1000); @@ -352,43 +213,18 @@ int ViEAutoTest::ViENetworkExtendedTest() //*************************************************************** // Testing finished. Tear down Video Engine //*************************************************************** - - if (numberOfErrors > 0) - { - // Test failed - ViETest::Log(" "); - ViETest::Log(" ERROR ViENetwork Extended Test FAILED!"); - ViETest::Log(" Number of errors: %d", numberOfErrors); - ViETest::Log("========================================"); - ViETest::Log(" "); - return numberOfErrors; - } - - ViETest::Log(" "); - ViETest::Log(" ViENetwork Extended Test PASSED!"); - ViETest::Log("========================================"); - ViETest::Log(" "); - return 0; } -int ViEAutoTest::ViENetworkAPITest() +void ViEAutoTest::ViENetworkAPITest() { - ViETest::Log(" "); - ViETest::Log("========================================"); - ViETest::Log(" ViENetwork API Test\n"); - //*************************************************************** // Begin create/initialize WebRTC Video Engine for testing //*************************************************************** - - int error = 0; - int numberOfErrors = 0; - - TbInterfaces ViE("ViENetworkAPITest", numberOfErrors); // Create VIE + TbInterfaces ViE("ViENetworkAPITest"); // Create VIE { // Create a video channel - tbVideoChannel tbChannel(ViE, numberOfErrors, webrtc::kVideoCodecVP8); + TbVideoChannel tbChannel(ViE, webrtc::kVideoCodecVP8); //*************************************************************** // Engine ready. Begin testing class @@ -398,90 +234,40 @@ int ViEAutoTest::ViENetworkAPITest() // External transport // TbExternalTransport testTransport(*ViE.network); - error = ViE.network->RegisterSendTransport(tbChannel.videoChannel, - testTransport); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.network->RegisterSendTransport(tbChannel.videoChannel, - testTransport); - numberOfErrors += ViETest::TestError(error == -1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.network->RegisterSendTransport( + tbChannel.videoChannel, testTransport)); + EXPECT_NE(0, ViE.network->RegisterSendTransport( + tbChannel.videoChannel, testTransport)); + unsigned char packet[1500]; packet[0] = 0x80; // V=2, P=0, X=0, CC=0 packet[1] = 0x78; // M=0, PT = 120 (VP8) - error = ViE.network->ReceivedRTPPacket(tbChannel.videoChannel, - packet, 1500); - numberOfErrors += ViETest::TestError(error == -1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.network->ReceivedRTCPPacket(tbChannel.videoChannel, - packet, 1500); - numberOfErrors += ViETest::TestError(error == -1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.base->StartReceive(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.network->ReceivedRTPPacket(tbChannel.videoChannel, - packet, 1500); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.network->ReceivedRTCPPacket(tbChannel.videoChannel, - packet, 1500); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.network->ReceivedRTPPacket(tbChannel.videoChannel, - packet, 11); - numberOfErrors += ViETest::TestError(error == -1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.network->ReceivedRTPPacket(tbChannel.videoChannel, - packet, 11); - numberOfErrors += ViETest::TestError(error == -1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.network->ReceivedRTPPacket(tbChannel.videoChannel, - packet, 3000); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.network->ReceivedRTPPacket(tbChannel.videoChannel, - packet, 3000); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.base->StopReceive(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.base->StartSend(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.network->DeregisterSendTransport( - tbChannel.videoChannel); // Sending - numberOfErrors += ViETest::TestError(error == -1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.base->StopSend(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.network->DeregisterSendTransport( - tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.network->DeregisterSendTransport( - tbChannel.videoChannel); // Already deregistered - numberOfErrors += ViETest::TestError(error == -1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_NE(0, ViE.network->ReceivedRTPPacket( + tbChannel.videoChannel, packet, 1500)); + EXPECT_NE(0, ViE.network->ReceivedRTCPPacket( + tbChannel.videoChannel, packet, 1500)); + EXPECT_EQ(0, ViE.base->StartReceive(tbChannel.videoChannel)); + EXPECT_EQ(0, ViE.network->ReceivedRTPPacket( + tbChannel.videoChannel, packet, 1500)); + EXPECT_EQ(0, ViE.network->ReceivedRTCPPacket( + tbChannel.videoChannel, packet, 1500)); + EXPECT_NE(0, ViE.network->ReceivedRTPPacket( + tbChannel.videoChannel, packet, 11)); + EXPECT_NE(0, ViE.network->ReceivedRTPPacket( + tbChannel.videoChannel, packet, 11)); + EXPECT_EQ(0, ViE.network->ReceivedRTPPacket( + tbChannel.videoChannel, packet, 3000)); + EXPECT_EQ(0, ViE.network->ReceivedRTPPacket( + tbChannel.videoChannel, packet, 3000)); + EXPECT_EQ(0, ViE.base->StopReceive(tbChannel.videoChannel)); + EXPECT_EQ(0, ViE.base->StartSend(tbChannel.videoChannel)); + EXPECT_NE(0, ViE.network->DeregisterSendTransport( + tbChannel.videoChannel)); // Sending + EXPECT_EQ(0, ViE.base->StopSend(tbChannel.videoChannel)); + EXPECT_EQ(0, ViE.network->DeregisterSendTransport( + tbChannel.videoChannel)); + EXPECT_NE(0, ViE.network->DeregisterSendTransport( + tbChannel.videoChannel)); // Already deregistered // // Local receiver @@ -492,252 +278,131 @@ int ViEAutoTest::ViENetworkAPITest() numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", __FUNCTION__, __LINE__);*/ - error = ViE.network->SetLocalReceiver(tbChannel.videoChannel, - 1234, 1235, "127.0.0.1"); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.network->SetLocalReceiver(tbChannel.videoChannel, - 1234, 1235, "127.0.0.1"); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.network->SetLocalReceiver(tbChannel.videoChannel, - 1236, 1237, "127.0.0.1"); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.network->SetLocalReceiver( + tbChannel.videoChannel, 1234, 1235, "127.0.0.1")); + EXPECT_EQ(0, ViE.network->SetLocalReceiver( + tbChannel.videoChannel, 1234, 1235, "127.0.0.1")); + EXPECT_EQ(0, ViE.network->SetLocalReceiver( + tbChannel.videoChannel, 1236, 1237, "127.0.0.1")); + unsigned short rtpPort = 0; unsigned short rtcpPort = 0; char ipAddress[64]; memset(ipAddress, 0, 64); - error = ViE.network->GetLocalReceiver(tbChannel.videoChannel, - rtpPort, rtcpPort, - ipAddress); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.base->StartReceive(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.network->SetLocalReceiver(tbChannel.videoChannel, - 1234, 1235, "127.0.0.1"); - numberOfErrors += ViETest::TestError(error == -1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.network->GetLocalReceiver(tbChannel.videoChannel, - rtpPort, rtcpPort, - ipAddress); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.base->StopReceive(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.network->GetLocalReceiver( + tbChannel.videoChannel, rtpPort, rtcpPort, ipAddress)); + EXPECT_EQ(0, ViE.base->StartReceive(tbChannel.videoChannel)); + EXPECT_NE(0, ViE.network->SetLocalReceiver( + tbChannel.videoChannel, 1234, 1235, "127.0.0.1")); + EXPECT_EQ(0, ViE.network->GetLocalReceiver( + tbChannel.videoChannel, rtpPort, rtcpPort, ipAddress)); + EXPECT_EQ(0, ViE.base->StopReceive(tbChannel.videoChannel)); // // Send destination // - error = ViE.network->SetSendDestination(tbChannel.videoChannel, - "127.0.0.1", 1234, 1235, - 1234, 1235); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.network->SetSendDestination(tbChannel.videoChannel, - "127.0.0.1", 1236, 1237, - 1234, 1235); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.network->SetSendDestination( + tbChannel.videoChannel, "127.0.0.1", 1234, 1235, 1234, 1235)); + EXPECT_EQ(0, ViE.network->SetSendDestination( + tbChannel.videoChannel, "127.0.0.1", 1236, 1237, 1234, 1235)); + unsigned short sourceRtpPort = 0; unsigned short sourceRtcpPort = 0; - error = ViE.network->GetSendDestination(tbChannel.videoChannel, - ipAddress, rtpPort, - rtcpPort, sourceRtpPort, - sourceRtcpPort); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.base->StartSend(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.network->GetSendDestination( + tbChannel.videoChannel, ipAddress, rtpPort, rtcpPort, + sourceRtpPort, sourceRtcpPort)); + EXPECT_EQ(0, ViE.base->StartSend(tbChannel.videoChannel)); // Not allowed while sending - error = ViE.network->SetSendDestination(tbChannel.videoChannel, - "127.0.0.1", 1234, 1235, - 1234, 1235); - numberOfErrors += ViETest::TestError(error == -1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError( - ViE.base->LastError() == kViENetworkAlreadySending, - "ERROR: %s at line %d", __FUNCTION__, __LINE__); + EXPECT_NE(0, ViE.network->SetSendDestination( + tbChannel.videoChannel, "127.0.0.1", 1234, 1235, 1234, 1235)); + EXPECT_EQ(kViENetworkAlreadySending, ViE.base->LastError()); - error = ViE.base->StopSend(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ViE.network->SetSendDestination(tbChannel.videoChannel, - "127.0.0.1", 1234, 1235, - 1234, 1235); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ViE.base->StartSend(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ViE.network->GetSendDestination(tbChannel.videoChannel, - ipAddress, rtpPort, - rtcpPort, sourceRtpPort, - sourceRtcpPort); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.base->StopSend(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.base->StopSend(tbChannel.videoChannel)); + EXPECT_EQ(0, ViE.network->SetSendDestination( + tbChannel.videoChannel, "127.0.0.1", 1234, 1235, 1234, 1235)); + EXPECT_EQ(0, ViE.base->StartSend(tbChannel.videoChannel)); + EXPECT_EQ(0, ViE.network->GetSendDestination( + tbChannel.videoChannel, ipAddress, rtpPort, rtcpPort, + sourceRtpPort, sourceRtcpPort)); + EXPECT_EQ(0, ViE.base->StopSend(tbChannel.videoChannel)); // // Address information // // GetSourceInfo: Tested in functional test - error = ViE.network->GetLocalIP(ipAddress, false); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - // TODO: IPv6 + EXPECT_EQ(0, ViE.network->GetLocalIP(ipAddress, false)); + + // TODO(unknown): IPv6 // // Filter // - error = ViE.network->GetSourceFilter(tbChannel.videoChannel, - rtpPort, rtcpPort, ipAddress); - numberOfErrors += ViETest::TestError(error == -1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.network->SetSourceFilter(tbChannel.videoChannel, - 1234, 1235, "10.10.10.10"); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.network->SetSourceFilter(tbChannel.videoChannel, - 1236, 1237, "127.0.0.1"); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.network->GetSourceFilter(tbChannel.videoChannel, - rtpPort, rtcpPort, ipAddress); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.network->SetSourceFilter(tbChannel.videoChannel, 0, - 0, NULL); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.network->GetSourceFilter(tbChannel.videoChannel, - rtpPort, rtcpPort, ipAddress); - numberOfErrors += ViETest::TestError(error == -1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_NE(0, ViE.network->GetSourceFilter( + tbChannel.videoChannel, rtpPort, rtcpPort, ipAddress)); + EXPECT_EQ(0, ViE.network->SetSourceFilter( + tbChannel.videoChannel, 1234, 1235, "10.10.10.10")); + EXPECT_EQ(0, ViE.network->SetSourceFilter( + tbChannel.videoChannel, 1236, 1237, "127.0.0.1")); + EXPECT_EQ(0, ViE.network->GetSourceFilter( + tbChannel.videoChannel, rtpPort, rtcpPort, ipAddress)); + EXPECT_EQ(0, ViE.network->SetSourceFilter( + tbChannel.videoChannel, 0, 0, NULL)); + EXPECT_NE(0, ViE.network->GetSourceFilter( + tbChannel.videoChannel, rtpPort, rtcpPort, ipAddress)); } { - tbVideoChannel tbChannel(ViE, numberOfErrors); // Create a video channel - error = ViE.network->SetLocalReceiver(tbChannel.videoChannel, - 1234); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + TbVideoChannel tbChannel(ViE); // Create a video channel + EXPECT_EQ(0, ViE.network->SetLocalReceiver( + tbChannel.videoChannel, 1234)); int DSCP = 0; bool useSetSockOpt = false; // SetSockOpt should work without a locally bind socket - error = ViE.network->GetSendToS(tbChannel.videoChannel, DSCP, - useSetSockOpt); // No ToS set - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError(DSCP == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - // Invalid input - error = ViE.network->SetSendToS(tbChannel.videoChannel, -1, true); - numberOfErrors += ViETest::TestError(error == -1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - // Invalid input - error = ViE.network->SetSendToS(tbChannel.videoChannel, 64, true); - numberOfErrors += ViETest::TestError(error == -1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - // Valid - error = ViE.network->SetSendToS(tbChannel.videoChannel, 20, true); + EXPECT_EQ(0, ViE.network->GetSendToS( + tbChannel.videoChannel, DSCP, useSetSockOpt)); // No ToS set + EXPECT_EQ(0, DSCP); + + // Invalid input + EXPECT_NE(0, ViE.network->SetSendToS(tbChannel.videoChannel, -1, true)); + + // Invalid input + EXPECT_NE(0, ViE.network->SetSendToS(tbChannel.videoChannel, 64, true)); + + // Valid + EXPECT_EQ(0, ViE.network->SetSendToS(tbChannel.videoChannel, 20, true)); + EXPECT_EQ(0, ViE.network->GetSendToS( + tbChannel.videoChannel, DSCP, useSetSockOpt)); + + EXPECT_EQ(20, DSCP); + EXPECT_TRUE(useSetSockOpt); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.network->GetSendToS(tbChannel.videoChannel, DSCP, - useSetSockOpt); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError((DSCP == 20 && useSetSockOpt - == true), "ERROR: %s at line %d", __FUNCTION__, __LINE__); // Disable - error = ViE.network->SetSendToS(tbChannel.videoChannel, 0, true); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.network->GetSendToS(tbChannel.videoChannel, DSCP, - useSetSockOpt); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError(DSCP == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.network->SetSendToS(tbChannel.videoChannel, 0, true)); + EXPECT_EQ(0, ViE.network->GetSendToS( + tbChannel.videoChannel, DSCP, useSetSockOpt)); + EXPECT_EQ(0, DSCP); char myIpAddress[64]; memset(myIpAddress, 0, 64); // Get local ip to be able to set ToS withtou setSockOpt - error = ViE.network->GetLocalIP(myIpAddress, false); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.network->SetLocalReceiver(tbChannel.videoChannel, - 1234, 1235, myIpAddress); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.network->GetLocalIP(myIpAddress, false)); + EXPECT_EQ(0, ViE.network->SetLocalReceiver( + tbChannel.videoChannel, 1234, 1235, myIpAddress)); + // Invalid input - error = ViE.network->SetSendToS(tbChannel.videoChannel, -1, - false); - numberOfErrors += ViETest::TestError(error == -1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.network->SetSendToS(tbChannel.videoChannel, 64, - false); // Invalid input - numberOfErrors += ViETest::TestError(error == -1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.network->GetSendToS(tbChannel.videoChannel, DSCP, - useSetSockOpt); // No ToS set - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError(DSCP == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.network->SetSendToS(tbChannel.videoChannel, 20, - false); // Valid - if (error != 0) + EXPECT_NE(0, ViE.network->SetSendToS( + tbChannel.videoChannel, -1, false)); + EXPECT_NE(0, ViE.network->SetSendToS( + tbChannel.videoChannel, 64, false)); // Invalid input + EXPECT_EQ(0, ViE.network->GetSendToS( + tbChannel.videoChannel, DSCP, useSetSockOpt)); // No ToS set + EXPECT_EQ(0, DSCP); + int tos_result = ViE.network->SetSendToS( + tbChannel.videoChannel, 20, false); // Valid + EXPECT_EQ(0, tos_result); + if (tos_result != 0) { ViETest::Log("ViESetSendToS error!."); ViETest::Log("You must be admin to run these tests."); @@ -746,36 +411,18 @@ int ViEAutoTest::ViENetworkAPITest() ViETest::Log("\"Run as administrator\"\n"); getchar(); } - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.network->GetSendToS(tbChannel.videoChannel, DSCP, - useSetSockOpt); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.network->GetSendToS( + tbChannel.videoChannel, DSCP, useSetSockOpt)); + EXPECT_EQ(20, DSCP); #ifdef _WIN32 - numberOfErrors += ViETest::TestError((DSCP == 20 - && useSetSockOpt == false), - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_FALSE(useSetSockOpt); #else // useSetSockOpt is true on Linux and Mac - numberOfErrors += ViETest::TestError((DSCP == 20 - && useSetSockOpt == true), - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_TRUE(useSetSockOpt); #endif - error = ViE.network->SetSendToS(tbChannel.videoChannel, 0, false); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.network->GetSendToS(tbChannel.videoChannel, DSCP, - useSetSockOpt); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError(DSCP == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.network->SetSendToS(tbChannel.videoChannel, 0, false)); + EXPECT_EQ(0, ViE.network->GetSendToS( + tbChannel.videoChannel, DSCP, useSetSockOpt)); + EXPECT_EQ(0, DSCP); } { // From qos.h. (*) -> supported by ViE @@ -796,178 +443,92 @@ int ViEAutoTest::ViENetworkAPITest() // #define SERVICE_GUARANTEED 0x80040000 // #define SERVICE_QUALITATIVE 0x80200000 - tbVideoChannel tbChannel(ViE, numberOfErrors); // Create a video channel + TbVideoChannel tbChannel(ViE); // Create a video channel #if defined(_WIN32) // No socket - error = ViE.network->SetSendGQoS(tbChannel.videoChannel, true, - SERVICETYPE_BESTEFFORT); - numberOfErrors += ViETest::TestError(error == -1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_NE(0, ViE.network->SetSendGQoS( + tbChannel.videoChannel, true, SERVICETYPE_BESTEFFORT)); + + EXPECT_EQ(0, ViE.network->SetLocalReceiver( + tbChannel.videoChannel, 1234)); - error = ViE.network->SetLocalReceiver(tbChannel.videoChannel, - 1234); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); // Sender not initialized - error = ViE.network->SetSendGQoS(tbChannel.videoChannel, true, - SERVICETYPE_BESTEFFORT); - numberOfErrors += ViETest::TestError(error == -1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.network->SetSendDestination(tbChannel.videoChannel, - "127.0.0.1", 12345); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_NE(0, ViE.network->SetSendGQoS( + tbChannel.videoChannel, true, SERVICETYPE_BESTEFFORT)); + EXPECT_EQ(0, ViE.network->SetSendDestination( + tbChannel.videoChannel, "127.0.0.1", 12345)); // Try to set all non-supported service types - error = ViE.network->SetSendGQoS(tbChannel.videoChannel, true, - SERVICETYPE_NOTRAFFIC); - numberOfErrors += ViETest::TestError(error == -1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.network->SetSendGQoS(tbChannel.videoChannel, true, - SERVICETYPE_NETWORK_UNAVAILABLE); - numberOfErrors += ViETest::TestError(error == -1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.network->SetSendGQoS(tbChannel.videoChannel, true, - SERVICETYPE_GENERAL_INFORMATION); - numberOfErrors += ViETest::TestError(error == -1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.network->SetSendGQoS(tbChannel.videoChannel, true, - SERVICETYPE_NOCHANGE); - numberOfErrors += ViETest::TestError(error == -1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.network->SetSendGQoS(tbChannel.videoChannel, true, - SERVICETYPE_NONCONFORMING); - numberOfErrors += ViETest::TestError(error == -1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.network->SetSendGQoS(tbChannel.videoChannel, true, - SERVICETYPE_NOTRAFFIC); - numberOfErrors += ViETest::TestError(error == -1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.network->SetSendGQoS(tbChannel.videoChannel, true, - SERVICETYPE_NETWORK_CONTROL); - numberOfErrors += ViETest::TestError(error == -1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.network->SetSendGQoS(tbChannel.videoChannel, true, - SERVICE_BESTEFFORT); - numberOfErrors += ViETest::TestError(error == -1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.network->SetSendGQoS(tbChannel.videoChannel, true, - SERVICE_CONTROLLEDLOAD); - numberOfErrors += ViETest::TestError(error == -1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.network->SetSendGQoS(tbChannel.videoChannel, true, - SERVICE_GUARANTEED); - numberOfErrors += ViETest::TestError(error == -1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.network->SetSendGQoS(tbChannel.videoChannel, true, - SERVICE_QUALITATIVE); - numberOfErrors += ViETest::TestError(error == -1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_NE(0, ViE.network->SetSendGQoS( + tbChannel.videoChannel, true, SERVICETYPE_NOTRAFFIC)); + EXPECT_NE(0, ViE.network->SetSendGQoS( + tbChannel.videoChannel, true, SERVICETYPE_NETWORK_UNAVAILABLE)); + EXPECT_NE(0, ViE.network->SetSendGQoS( + tbChannel.videoChannel, true, SERVICETYPE_GENERAL_INFORMATION)); + EXPECT_NE(0, ViE.network->SetSendGQoS( + tbChannel.videoChannel, true, SERVICETYPE_NOCHANGE)); + EXPECT_NE(0, ViE.network->SetSendGQoS( + tbChannel.videoChannel, true, SERVICETYPE_NONCONFORMING)); + EXPECT_NE(0, ViE.network->SetSendGQoS( + tbChannel.videoChannel, true, SERVICETYPE_NOTRAFFIC)); + EXPECT_NE(0, ViE.network->SetSendGQoS( + tbChannel.videoChannel, true, SERVICETYPE_NETWORK_CONTROL)); + EXPECT_NE(0, ViE.network->SetSendGQoS( + tbChannel.videoChannel, true, SERVICE_BESTEFFORT)); + EXPECT_NE(0, ViE.network->SetSendGQoS( + tbChannel.videoChannel, true, SERVICE_CONTROLLEDLOAD)); + EXPECT_NE(0, ViE.network->SetSendGQoS( + tbChannel.videoChannel, true, SERVICE_GUARANTEED)); + EXPECT_NE(0, ViE.network->SetSendGQoS( + tbChannel.videoChannel, true, SERVICE_QUALITATIVE)); // Loop through valid service settings bool enabled = false; int serviceType = 0; int overrideDSCP = 0; - error = ViE.network->GetSendGQoS(tbChannel.videoChannel, enabled, - serviceType, overrideDSCP); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError(enabled == false, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.network->SetSendGQoS(tbChannel.videoChannel, true, - SERVICETYPE_BESTEFFORT); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.network->GetSendGQoS(tbChannel.videoChannel, enabled, - serviceType, overrideDSCP); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError( - (enabled == true && - serviceType == SERVICETYPE_BESTEFFORT && - overrideDSCP == false), - "ERROR: %s at line %d", __FUNCTION__, __LINE__); - error = ViE.network->SetSendGQoS(tbChannel.videoChannel, true, - SERVICETYPE_CONTROLLEDLOAD); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.network->GetSendGQoS(tbChannel.videoChannel, enabled, - serviceType, overrideDSCP); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError( - (enabled == true && - serviceType == SERVICETYPE_CONTROLLEDLOAD && - overrideDSCP == false), - "ERROR: %s at line %d", __FUNCTION__, __LINE__); - error = ViE.network->SetSendGQoS(tbChannel.videoChannel, true, - SERVICETYPE_GUARANTEED); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.network->GetSendGQoS(tbChannel.videoChannel, enabled, - serviceType, overrideDSCP); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError( - (enabled == true - && serviceType == SERVICETYPE_GUARANTEED - && overrideDSCP == false), - "ERROR: %s at line %d", __FUNCTION__, __LINE__); - error = ViE.network->SetSendGQoS(tbChannel.videoChannel, true, - SERVICETYPE_QUALITATIVE); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.network->GetSendGQoS(tbChannel.videoChannel, enabled, - serviceType, overrideDSCP); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError( - (enabled == true && - serviceType == SERVICETYPE_QUALITATIVE && - overrideDSCP == false), - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.network->SetSendGQoS(tbChannel.videoChannel, false, - SERVICETYPE_QUALITATIVE); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.network->GetSendGQoS(tbChannel.videoChannel, enabled, - serviceType, overrideDSCP); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError(enabled == false, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.network->GetSendGQoS( + tbChannel.videoChannel, enabled, serviceType, overrideDSCP)); + EXPECT_FALSE(enabled); + EXPECT_EQ(0, ViE.network->SetSendGQoS( + tbChannel.videoChannel, true, SERVICETYPE_BESTEFFORT)); + EXPECT_EQ(0, ViE.network->GetSendGQoS( + tbChannel.videoChannel, enabled, serviceType, overrideDSCP)); + EXPECT_TRUE(enabled); + EXPECT_EQ(SERVICETYPE_BESTEFFORT, serviceType); + EXPECT_FALSE(overrideDSCP); + + EXPECT_EQ(0, ViE.network->SetSendGQoS( + tbChannel.videoChannel, true, SERVICETYPE_CONTROLLEDLOAD)); + EXPECT_EQ(0, ViE.network->GetSendGQoS( + tbChannel.videoChannel, enabled, serviceType, overrideDSCP)); + EXPECT_TRUE(enabled); + EXPECT_EQ(SERVICETYPE_CONTROLLEDLOAD, serviceType); + EXPECT_FALSE(overrideDSCP); + + EXPECT_EQ(0, ViE.network->SetSendGQoS( + tbChannel.videoChannel, true, SERVICETYPE_GUARANTEED)); + EXPECT_EQ(0, ViE.network->GetSendGQoS( + tbChannel.videoChannel, enabled, serviceType, overrideDSCP)); + EXPECT_TRUE(enabled); + EXPECT_EQ(SERVICETYPE_GUARANTEED, serviceType); + EXPECT_FALSE(overrideDSCP); + + EXPECT_EQ(0, ViE.network->SetSendGQoS( + tbChannel.videoChannel, true, SERVICETYPE_QUALITATIVE)); + EXPECT_EQ(0, ViE.network->GetSendGQoS( + tbChannel.videoChannel, enabled, serviceType, overrideDSCP)); + EXPECT_TRUE(enabled); + EXPECT_EQ(SERVICETYPE_QUALITATIVE, serviceType); + EXPECT_FALSE(overrideDSCP); + + EXPECT_EQ(0, ViE.network->SetSendGQoS( + tbChannel.videoChannel, false, SERVICETYPE_QUALITATIVE)); + EXPECT_EQ(0, ViE.network->GetSendGQoS( + tbChannel.videoChannel, enabled, serviceType, overrideDSCP)); + EXPECT_FALSE(enabled); #endif } { @@ -975,84 +536,34 @@ int ViEAutoTest::ViENetworkAPITest() // MTU and packet burst // // Create a video channel - tbVideoChannel tbChannel(ViE, numberOfErrors); + TbVideoChannel tbChannel(ViE); // Invalid input - error = ViE.network->SetMTU(tbChannel.videoChannel, 1600); - numberOfErrors += ViETest::TestError(error == -1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - // Invalid input - error = ViE.network->SetMTU(tbChannel.videoChannel, 800); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_NE(0, ViE.network->SetMTU(tbChannel.videoChannel, 1600)); + // Valid input + EXPECT_EQ(0, ViE.network->SetMTU(tbChannel.videoChannel, 800)); // // Observer and timeout // ViEAutoTestNetworkObserver vieTestObserver; - error = ViE.network->RegisterObserver(tbChannel.videoChannel, - vieTestObserver); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.network->RegisterObserver(tbChannel.videoChannel, - vieTestObserver); - numberOfErrors += ViETest::TestError(error == -1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.network->SetPeriodicDeadOrAliveStatus( - tbChannel.videoChannel, true); // No observer - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.network->DeregisterObserver(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.network->RegisterObserver( + tbChannel.videoChannel, vieTestObserver)); + EXPECT_NE(0, ViE.network->RegisterObserver( + tbChannel.videoChannel, vieTestObserver)); + EXPECT_EQ(0, ViE.network->SetPeriodicDeadOrAliveStatus( + tbChannel.videoChannel, true)); // No observer + EXPECT_EQ(0, ViE.network->DeregisterObserver(tbChannel.videoChannel)); - error = ViE.network->DeregisterObserver(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == -1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.network->SetPeriodicDeadOrAliveStatus( - tbChannel.videoChannel, true); // No observer - numberOfErrors += ViETest::TestError(error == -1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_NE(0, ViE.network->DeregisterObserver(tbChannel.videoChannel)); + EXPECT_NE(0, ViE.network->SetPeriodicDeadOrAliveStatus( + tbChannel.videoChannel, true)); // No observer // Packet timout notification - error = ViE.network->SetPacketTimeoutNotification( - tbChannel.videoChannel, true, 10); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.network->SetPacketTimeoutNotification( + tbChannel.videoChannel, true, 10)); } -#if 0 - virtual int SendUDPPacket(const int videoChannel, const void* data, - const unsigned int length, int& transmittedBytes, - bool useRtcpSocket = false) = 0; -#endif //*************************************************************** // Testing finished. Tear down Video Engine //*************************************************************** - - - if (numberOfErrors > 0) - { - // Test failed - ViETest::Log(" "); - ViETest::Log(" ERROR ViENetwork API Test FAILED!"); - ViETest::Log(" Number of errors: %d", numberOfErrors); - ViETest::Log("========================================"); - ViETest::Log(" "); - return numberOfErrors; - } - - ViETest::Log(" "); - ViETest::Log(" ViENetwork API Test PASSED!"); - ViETest::Log("========================================"); - ViETest::Log(" "); - return 0; } diff --git a/src/video_engine/test/auto_test/source/vie_autotest_render.cc b/src/video_engine/test/auto_test/source/vie_autotest_render.cc index 9308c18ab..27fc15692 100644 --- a/src/video_engine/test/auto_test/source/vie_autotest_render.cc +++ b/src/video_engine/test/auto_test/source/vie_autotest_render.cc @@ -76,144 +76,82 @@ private: int _width, _height; }; -int ViEAutoTest::ViERenderStandardTest() +void ViEAutoTest::ViERenderStandardTest() { - ViETest::Log(" "); - ViETest::Log("========================================"); - ViETest::Log(" ViERender Standard Test\n"); - //*************************************************************** // Begin create/initialize WebRTC Video Engine for testing //*************************************************************** - - - int error = 0; - int numberOfErrors = 0; int rtpPort = 6000; - TbInterfaces ViE("ViERenderStandardTest", numberOfErrors); + TbInterfaces ViE("ViERenderStandardTest"); // Create a video channel - tbVideoChannel tbChannel(ViE, numberOfErrors, webrtc::kVideoCodecVP8); - TbCaptureDevice tbCapture(ViE, numberOfErrors); // Create a capture device + TbVideoChannel tbChannel(ViE, webrtc::kVideoCodecVP8); + TbCaptureDevice tbCapture(ViE); // Create a capture device tbCapture.ConnectTo(tbChannel.videoChannel); tbChannel.StartReceive(rtpPort); tbChannel.StartSend(rtpPort); - error = ViE.render->RegisterVideoRenderModule(*_vrm1); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ViE.render->AddRenderer(tbCapture.captureId, _window1, 0, - 0.0, 0.0, 1.0, 1.0); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ViE.render->StartRender(tbCapture.captureId); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ViE.render->RegisterVideoRenderModule(*_vrm2); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ViE.render->AddRenderer(tbChannel.videoChannel, _window2, 1, - 0.0, 0.0, 1.0, 1.0); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ViE.render->StartRender(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.render->RegisterVideoRenderModule(*_vrm1)); + EXPECT_EQ(0, ViE.render->AddRenderer( + tbCapture.captureId, _window1, 0, 0.0, 0.0, 1.0, 1.0)); + EXPECT_EQ(0, ViE.render->StartRender(tbCapture.captureId)); + EXPECT_EQ(0, ViE.render->RegisterVideoRenderModule(*_vrm2)); + EXPECT_EQ(0, ViE.render->AddRenderer( + tbChannel.videoChannel, _window2, 1, 0.0, 0.0, 1.0, 1.0)); + EXPECT_EQ(0, ViE.render->StartRender(tbChannel.videoChannel)); ViETest::Log("\nCapture device is renderered in Window 1"); ViETest::Log("Remote stream is renderered in Window 2"); AutoTestSleep(KAutoTestSleepTimeMs); - error = ViE.render->StopRender(tbCapture.captureId); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ViE.render->RemoveRenderer(tbCapture.captureId); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.render->StopRender(tbCapture.captureId)); + EXPECT_EQ(0, ViE.render->RemoveRenderer(tbCapture.captureId)); // PIP and full screen rendering is not supported on Android #ifndef WEBRTC_ANDROID - error = ViE.render->DeRegisterVideoRenderModule(*_vrm1); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ViE.render->AddRenderer(tbCapture.captureId, _window2, 0, - 0.75, 0.75, 1.0, 1.0); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ViE.render->StartRender(tbCapture.captureId); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.render->DeRegisterVideoRenderModule(*_vrm1)); + EXPECT_EQ(0, ViE.render->AddRenderer( + tbCapture.captureId, _window2, 0, 0.75, 0.75, 1.0, 1.0)); + EXPECT_EQ(0, ViE.render->StartRender(tbCapture.captureId)); ViETest::Log("\nCapture device is now rendered in Window 2, PiP."); ViETest::Log("Switching to full screen rendering in %d seconds.\n", KAutoTestSleepTimeMs / 1000); AutoTestSleep(KAutoTestSleepTimeMs); - error = ViE.render->RemoveRenderer(tbCapture.captureId); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.render->RemoveRenderer(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.render->DeRegisterVideoRenderModule(*_vrm2); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.render->RemoveRenderer(tbCapture.captureId)); + EXPECT_EQ(0, ViE.render->RemoveRenderer(tbChannel.videoChannel)); + EXPECT_EQ(0, ViE.render->DeRegisterVideoRenderModule(*_vrm2)); // Destroy render module and create new in full screen mode webrtc::VideoRender::DestroyVideoRender(_vrm1); _vrm1 = NULL; _vrm1 = webrtc::VideoRender::CreateVideoRender( 4563, _window1, true, _renderType); - numberOfErrors += ViETest::TestError(_vrm1 != NULL, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_TRUE(_vrm1 != NULL); - error = ViE.render->RegisterVideoRenderModule(*_vrm1); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.render->AddRenderer(tbCapture.captureId, _window1, 0, - 0.75f, 0.75f, 1.0f, 1.0f); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.render->StartRender(tbCapture.captureId); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.render->AddRenderer(tbChannel.videoChannel, _window1, 1, - 0.0, 0.0, 1.0, 1.0); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.render->StartRender(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.render->RegisterVideoRenderModule(*_vrm1)); + EXPECT_EQ(0, ViE.render->AddRenderer( + tbCapture.captureId, _window1, 0, 0.75f, 0.75f, 1.0f, 1.0f)); + EXPECT_EQ(0, ViE.render->StartRender(tbCapture.captureId)); + EXPECT_EQ(0, ViE.render->AddRenderer( + tbChannel.videoChannel, _window1, 1, 0.0, 0.0, 1.0, 1.0)); + EXPECT_EQ(0, ViE.render->StartRender(tbChannel.videoChannel)); AutoTestSleep(KAutoTestSleepTimeMs); - error = ViE.render->RemoveRenderer(tbCapture.captureId); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.render->RemoveRenderer(tbCapture.captureId)); - error = ViE.render->RemoveRenderer(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.render->DeRegisterVideoRenderModule(*_vrm1); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.render->RemoveRenderer(tbChannel.videoChannel)); + EXPECT_EQ(0, ViE.render->DeRegisterVideoRenderModule(*_vrm1)); // Destroy full screen render module and create new in normal mode webrtc::VideoRender::DestroyVideoRender(_vrm1); _vrm1 = NULL; _vrm1 = webrtc::VideoRender::CreateVideoRender( 4561, _window1, false, _renderType); - numberOfErrors += ViETest::TestError(_vrm1 != NULL, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_TRUE(_vrm1 != NULL); #endif //*************************************************************** @@ -224,72 +162,30 @@ int ViEAutoTest::ViERenderStandardTest() //*************************************************************** // Testing finished. Tear down Video Engine //*************************************************************** - tbCapture.Disconnect(tbChannel.videoChannel); - - if (numberOfErrors > 0) - { - // Test failed - ViETest::Log(" "); - ViETest::Log(" ERROR ViERender Standard Test FAILED!"); - ViETest::Log(" Number of errors: %d", numberOfErrors); - ViETest::Log("========================================"); - ViETest::Log(" "); - return numberOfErrors; - } - - ViETest::Log(" "); - ViETest::Log(" ViERender Standard Test PASSED!"); - ViETest::Log("========================================"); - ViETest::Log(" "); - - return 0; } -int ViEAutoTest::ViERenderExtendedTest() +void ViEAutoTest::ViERenderExtendedTest() { - ViETest::Log(" "); - ViETest::Log("========================================"); - ViETest::Log(" ViERender Extended Test\n"); - - int error = 0; - int numberOfErrors = 0; int rtpPort = 6000; - TbInterfaces ViE("ViERenderExtendedTest", numberOfErrors); + TbInterfaces ViE("ViERenderExtendedTest"); // Create a video channel - tbVideoChannel tbChannel(ViE, numberOfErrors, webrtc::kVideoCodecVP8); - TbCaptureDevice tbCapture(ViE, numberOfErrors); // Create a capture device + TbVideoChannel tbChannel(ViE, webrtc::kVideoCodecVP8); + TbCaptureDevice tbCapture(ViE); // Create a capture device tbCapture.ConnectTo(tbChannel.videoChannel); tbChannel.StartReceive(rtpPort); tbChannel.StartSend(rtpPort); - error = ViE.render->RegisterVideoRenderModule(*_vrm1); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ViE.render->AddRenderer(tbCapture.captureId, _window1, 0, - 0.0, 0.0, 1.0, 1.0); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ViE.render->StartRender(tbCapture.captureId); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ViE.render->RegisterVideoRenderModule(*_vrm2); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ViE.render->AddRenderer(tbChannel.videoChannel, _window2, 1, - 0.0, 0.0, 1.0, 1.0); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ViE.render->StartRender(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.render->RegisterVideoRenderModule(*_vrm1)); + EXPECT_EQ(0, ViE.render->AddRenderer( + tbCapture.captureId, _window1, 0, 0.0, 0.0, 1.0, 1.0)); + EXPECT_EQ(0, ViE.render->StartRender(tbCapture.captureId)); + EXPECT_EQ(0, ViE.render->RegisterVideoRenderModule(*_vrm2)); + EXPECT_EQ(0, ViE.render->AddRenderer( + tbChannel.videoChannel, _window2, 1, 0.0, 0.0, 1.0, 1.0)); + EXPECT_EQ(0, ViE.render->StartRender(tbChannel.videoChannel)); ViETest::Log("\nCapture device is renderered in Window 1"); ViETest::Log("Remote stream is renderered in Window 2"); @@ -298,207 +194,102 @@ int ViEAutoTest::ViERenderExtendedTest() #ifdef _WIN32 ViETest::Log("\nConfiguring Window2"); ViETest::Log("you will see video only in first quadrant"); - error = ViE.render->ConfigureRender(tbChannel.videoChannel, 0, 0.0f, - 0.0f, 0.5f, 0.5f); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.render->ConfigureRender( + tbChannel.videoChannel, 0, 0.0f, 0.0f, 0.5f, 0.5f)); AutoTestSleep(KAutoTestSleepTimeMs); ViETest::Log("you will see video only in fourth quadrant"); - error = ViE.render->ConfigureRender(tbChannel.videoChannel, 0, 0.5f, - 0.5f, 1.0f, 1.0f); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.render->ConfigureRender( + tbChannel.videoChannel, 0, 0.5f, 0.5f, 1.0f, 1.0f)); AutoTestSleep(KAutoTestSleepTimeMs); ViETest::Log("normal video on Window2"); - error = ViE.render->ConfigureRender(tbChannel.videoChannel, 0, 0.0f, - 0.0f, 1.0f, 1.0f); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.render->ConfigureRender( + tbChannel.videoChannel, 0, 0.0f, 0.0f, 1.0f, 1.0f)); AutoTestSleep(KAutoTestSleepTimeMs); #endif ViETest::Log("Mirroring Local Preview (Window1) Left-Right"); - error = ViE.render->MirrorRenderStream(tbCapture.captureId, true, - false, true); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.render->MirrorRenderStream( + tbCapture.captureId, true, false, true)); AutoTestSleep(KAutoTestSleepTimeMs); ViETest::Log("\nMirroring Local Preview (Window1) Left-Right and Up-Down"); - error = ViE.render->MirrorRenderStream(tbCapture.captureId, true, - true, true); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.render->MirrorRenderStream( + tbCapture.captureId, true, true, true)); AutoTestSleep(KAutoTestSleepTimeMs); ViETest::Log("\nMirroring Remote Window(Window2) Up-Down"); - error = ViE.render->MirrorRenderStream(tbChannel.videoChannel, true, - true, false); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.render->MirrorRenderStream( + tbChannel.videoChannel, true, true, false)); AutoTestSleep(KAutoTestSleepTimeMs); ViETest::Log("Disabling Mirroing on Window1 and Window2"); - error = ViE.render->MirrorRenderStream(tbCapture.captureId, false, - false, false); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.render->MirrorRenderStream( + tbCapture.captureId, false, false, false)); AutoTestSleep(KAutoTestSleepTimeMs); - error = ViE.render->MirrorRenderStream(tbChannel.videoChannel, false, - false, false); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.render->MirrorRenderStream( + tbChannel.videoChannel, false, false, false)); AutoTestSleep(KAutoTestSleepTimeMs); ViETest::Log("\nEnabling Full Screen render in 5 sec"); - error = ViE.render->RemoveRenderer(tbCapture.captureId); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.render->DeRegisterVideoRenderModule(*_vrm1); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.render->RemoveRenderer(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.render->DeRegisterVideoRenderModule(*_vrm2); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.render->RemoveRenderer(tbCapture.captureId)); + EXPECT_EQ(0, ViE.render->DeRegisterVideoRenderModule(*_vrm1)); + EXPECT_EQ(0, ViE.render->RemoveRenderer(tbChannel.videoChannel)); + EXPECT_EQ(0, ViE.render->DeRegisterVideoRenderModule(*_vrm2)); // Destroy render module and create new in full screen mode webrtc::VideoRender::DestroyVideoRender(_vrm1); _vrm1 = NULL; _vrm1 = webrtc::VideoRender::CreateVideoRender( 4563, _window1, true, _renderType); - numberOfErrors += ViETest::TestError(_vrm1 != NULL, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_TRUE(_vrm1 != NULL); - error = ViE.render->RegisterVideoRenderModule(*_vrm1); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.render->AddRenderer(tbCapture.captureId, _window1, 0, - 0.0f, 0.0f, 1.0f, 1.0f); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.render->StartRender(tbCapture.captureId); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.render->RegisterVideoRenderModule(*_vrm1)); + EXPECT_EQ(0, ViE.render->AddRenderer( + tbCapture.captureId, _window1, 0, 0.0f, 0.0f, 1.0f, 1.0f)); + EXPECT_EQ(0, ViE.render->StartRender(tbCapture.captureId)); AutoTestSleep(KAutoTestSleepTimeMs); - error = ViE.render->StopRender(tbCapture.captureId); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - /* error = ViE.ptrViERender->StopRender(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", __FUNCTION__, __LINE__); - */ ViETest::Log("\nStop renderer"); - - error = ViE.render->RemoveRenderer(tbCapture.captureId); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - /* error = ViE.ptrViERender->RemoveRenderer(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", __FUNCTION__, __LINE__); - */ + EXPECT_EQ(0, ViE.render->StopRender(tbCapture.captureId)); ViETest::Log("\nRemove renderer"); + EXPECT_EQ(0, ViE.render->RemoveRenderer(tbCapture.captureId)); - error = ViE.render->DeRegisterVideoRenderModule(*_vrm1); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.render->DeRegisterVideoRenderModule(*_vrm1)); // Destroy full screen render module and create new for external rendering webrtc::VideoRender::DestroyVideoRender(_vrm1); _vrm1 = NULL; _vrm1 = webrtc::VideoRender::CreateVideoRender(4564, NULL, false, _renderType); - numberOfErrors += ViETest::TestError(_vrm1 != NULL, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_TRUE(_vrm1 != NULL); - error = ViE.render->RegisterVideoRenderModule(*_vrm1); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.render->RegisterVideoRenderModule(*_vrm1)); ViETest::Log("\nExternal Render Test"); ViEAutoTestExternalRenderer externalRenderObj; - error = ViE.render->AddRenderer(tbCapture.captureId, - webrtc::kVideoI420, - &externalRenderObj); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.render->StartRender(tbCapture.captureId); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.render->AddRenderer( + tbCapture.captureId, webrtc::kVideoI420, &externalRenderObj)); + EXPECT_EQ(0, ViE.render->StartRender(tbCapture.captureId)); AutoTestSleep(KAutoTestSleepTimeMs); - error = ViE.render->StopRender(tbCapture.captureId); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ViE.render->RemoveRenderer(tbCapture.captureId); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.render->DeRegisterVideoRenderModule(*_vrm1); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.render->StopRender(tbCapture.captureId)); + EXPECT_EQ(0, ViE.render->RemoveRenderer(tbCapture.captureId)); + EXPECT_EQ(0, ViE.render->DeRegisterVideoRenderModule(*_vrm1)); // Destroy render module for external rendering and create new in normal // mode webrtc::VideoRender::DestroyVideoRender(_vrm1); _vrm1 = NULL; - _vrm1 = webrtc::VideoRender::CreateVideoRender(4561, _window1, false, - _renderType); - numberOfErrors += ViETest::TestError(_vrm1 != NULL, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - + _vrm1 = webrtc::VideoRender::CreateVideoRender( + 4561, _window1, false, _renderType); + EXPECT_TRUE(_vrm1 != NULL); tbCapture.Disconnect(tbChannel.videoChannel); - - if (numberOfErrors > 0) - { - // Test failed - ViETest::Log(" "); - ViETest::Log(" ERROR ViERender Extended Test FAILED!"); - ViETest::Log(" Number of errors: %d", numberOfErrors); - ViETest::Log("========================================"); - ViETest::Log(" "); - return numberOfErrors; - } - - ViETest::Log(" "); - ViETest::Log(" ViERender Extended Test PASSED!"); - ViETest::Log("========================================"); - ViETest::Log(" "); - - return 0; } -int ViEAutoTest::ViERenderAPITest() +void ViEAutoTest::ViERenderAPITest() { - ViETest::Log(" "); - ViETest::Log("========================================"); - ViETest::Log(" ViERender API Test\n"); - - int numberOfErrors = 0; - - //TODO add the real tests cases - - if (numberOfErrors > 0) - { - // Test failed - ViETest::Log(" "); - ViETest::Log(" ERROR ViERender API Test FAILED!"); - ViETest::Log(" Number of errors: %d", numberOfErrors); - ViETest::Log("========================================"); - ViETest::Log(" "); - return numberOfErrors; - } - - ViETest::Log(" "); - ViETest::Log(" ViERender API Test PASSED!"); - ViETest::Log("========================================"); - ViETest::Log(" "); - - return 0; + // TODO(unknown): add the real tests cases } diff --git a/src/video_engine/test/auto_test/source/vie_autotest_rtp_rtcp.cc b/src/video_engine/test/auto_test/source/vie_autotest_rtp_rtcp.cc index e09933531..1079ca83c 100644 --- a/src/video_engine/test/auto_test/source/vie_autotest_rtp_rtcp.cc +++ b/src/video_engine/test/auto_test/source/vie_autotest_rtp_rtcp.cc @@ -88,116 +88,81 @@ public: } }; -int ViEAutoTest::ViERtpRtcpStandardTest() +void ViEAutoTest::ViERtpRtcpStandardTest() { - ViETest::Log(" "); - ViETest::Log("========================================"); - ViETest::Log(" ViERTP_RTCP Standard Test\n"); - - //*************************************************************** - // Begin create/initialize WebRTC Video Engine for testing - //*************************************************************** - - int error = 0; - int numberOfErrors = 0; + // *************************************************************** + // Begin create/initialize WebRTC Video Engine for testing + // *************************************************************** // Create VIE - TbInterfaces ViE("ViERtpRtcpStandardTest", numberOfErrors); + TbInterfaces ViE("ViERtpRtcpStandardTest"); // Create a video channel - tbVideoChannel tbChannel(ViE, numberOfErrors, webrtc::kVideoCodecVP8); + TbVideoChannel tbChannel(ViE, webrtc::kVideoCodecVP8); // Create a capture device - TbCaptureDevice tbCapture(ViE, numberOfErrors); + TbCaptureDevice tbCapture(ViE); tbCapture.ConnectTo(tbChannel.videoChannel); ViETest::Log("\n"); TbExternalTransport myTransport(*(ViE.network)); - error = ViE.network->RegisterSendTransport(tbChannel.videoChannel, - myTransport); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.network->RegisterSendTransport( + tbChannel.videoChannel, myTransport)); - //*************************************************************** - // Engine ready. Begin testing class - //*************************************************************** + // *************************************************************** + // Engine ready. Begin testing class + // *************************************************************** unsigned short startSequenceNumber = 12345; ViETest::Log("Set start sequence number: %u", startSequenceNumber); - error = ViE.rtp_rtcp->SetStartSequenceNumber(tbChannel.videoChannel, - startSequenceNumber); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.rtp_rtcp->SetStartSequenceNumber( + tbChannel.videoChannel, startSequenceNumber)); myTransport.EnableSequenceNumberCheck(); - error = ViE.base->StartReceive(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.base->StartReceive(tbChannel.videoChannel)); + EXPECT_EQ(0, ViE.base->StartSend(tbChannel.videoChannel)); - error = ViE.base->StartSend(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); AutoTestSleep(2000); unsigned short receivedSequenceNumber = myTransport.GetFirstSequenceNumber(); ViETest::Log("First received sequence number: %u\n", receivedSequenceNumber); - numberOfErrors += ViETest::TestError( - receivedSequenceNumber == startSequenceNumber, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(startSequenceNumber, receivedSequenceNumber); - error = ViE.base->StopSend(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.base->StopSend(tbChannel.videoChannel)); // // RTCP CName // ViETest::Log("Testing CName\n"); const char* sendCName = "ViEAutoTestCName\0"; - error = ViE.rtp_rtcp->SetRTCPCName(tbChannel.videoChannel, sendCName); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.rtp_rtcp->SetRTCPCName(tbChannel.videoChannel, sendCName)); char returnCName[webrtc::ViERTP_RTCP::KMaxRTCPCNameLength]; memset(returnCName, 0, webrtc::ViERTP_RTCP::KMaxRTCPCNameLength); - error = ViE.rtp_rtcp->GetRTCPCName(tbChannel.videoChannel, returnCName); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError((strcmp(sendCName, returnCName) == 0), - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); + EXPECT_EQ(0, ViE.rtp_rtcp->GetRTCPCName( + tbChannel.videoChannel, returnCName)); + EXPECT_STRCASEEQ(sendCName, returnCName); - error = ViE.base->StartSend(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.base->StartSend(tbChannel.videoChannel)); AutoTestSleep(1000); char remoteCName[webrtc::ViERTP_RTCP::KMaxRTCPCNameLength]; memset(remoteCName, 0, webrtc::ViERTP_RTCP::KMaxRTCPCNameLength); - error = ViE.rtp_rtcp->GetRemoteRTCPCName(tbChannel.videoChannel, - remoteCName); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError((strcmp(sendCName, remoteCName) == 0), - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); + EXPECT_EQ(0, ViE.rtp_rtcp->GetRemoteRTCPCName( + tbChannel.videoChannel, remoteCName)); + EXPECT_STRCASEEQ(sendCName, remoteCName); // // Statistics // // Stop and restart to clear stats ViETest::Log("Testing statistics\n"); - error = ViE.base->StopReceive(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ViE.base->StopSend(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.base->StopReceive(tbChannel.videoChannel)); + EXPECT_EQ(0, ViE.base->StopSend(tbChannel.videoChannel)); myTransport.ClearStats(); int rate = 20; @@ -205,18 +170,10 @@ int ViEAutoTest::ViERtpRtcpStandardTest() // Start send to verify sending stats - error = ViE.rtp_rtcp->SetStartSequenceNumber(tbChannel.videoChannel, - startSequenceNumber); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ViE.base->StartSend(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ViE.base->StartReceive(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.rtp_rtcp->SetStartSequenceNumber( + tbChannel.videoChannel, startSequenceNumber)); + EXPECT_EQ(0, ViE.base->StartSend(tbChannel.videoChannel)); + EXPECT_EQ(0, ViE.base->StartReceive(tbChannel.videoChannel)); AutoTestSleep(KAutoTestSleepTimeMs); @@ -236,60 +193,38 @@ int ViEAutoTest::ViERtpRtcpStandardTest() unsigned int sentFecBitrate = 0; unsigned int sentNackBitrate = 0; - error = ViE.rtp_rtcp->GetBandwidthUsage(tbChannel.videoChannel, - sentTotalBitrate, - sentVideoBitrate, - sentFecBitrate, - sentNackBitrate); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.rtp_rtcp->GetBandwidthUsage( + tbChannel.videoChannel, sentTotalBitrate, sentVideoBitrate, + sentFecBitrate, sentNackBitrate)); - numberOfErrors += ViETest::TestError(sentTotalBitrate > 0 && - sentFecBitrate == 0 && - sentNackBitrate == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_GT(sentTotalBitrate, 0u); + EXPECT_EQ(sentFecBitrate, 0u); + EXPECT_EQ(sentNackBitrate, 0u); - error = ViE.base->StopReceive(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.base->StopReceive(tbChannel.videoChannel)); AutoTestSleep(2000); - error = ViE.rtp_rtcp->GetSentRTCPStatistics(tbChannel.videoChannel, - sentFractionsLost, - sentCumulativeLost, - sentExtendedMax, - sentJitter, - sentRttMs); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError((sentCumulativeLost > 0 - && sentExtendedMax > startSequenceNumber && sentJitter > 0 && sentRttMs - > 0), "ERROR: %s at line %d", __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.rtp_rtcp->GetSentRTCPStatistics( + tbChannel.videoChannel, sentFractionsLost, sentCumulativeLost, + sentExtendedMax, sentJitter, sentRttMs)); + EXPECT_GT(sentCumulativeLost, 0u); + EXPECT_GT(sentExtendedMax, startSequenceNumber); + EXPECT_GT(sentJitter, 0u); + EXPECT_GT(sentRttMs, 0); + + EXPECT_EQ(0, ViE.rtp_rtcp->GetReceivedRTCPStatistics( + tbChannel.videoChannel, recFractionsLost, recCumulativeLost, + recExtendedMax, recJitter, recRttMs)); + + EXPECT_GT(recCumulativeLost, 0u); + EXPECT_GT(recExtendedMax, startSequenceNumber); + EXPECT_GT(recJitter, 0u); + EXPECT_GT(recRttMs, 0); - error = ViE.rtp_rtcp->GetReceivedRTCPStatistics(tbChannel.videoChannel, - recFractionsLost, - recCumulativeLost, - recExtendedMax, - recJitter, - recRttMs); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError( - (recCumulativeLost > 0 - && recExtendedMax > startSequenceNumber - && recJitter > 0 - && recRttMs > 0), - "ERROR: %s at line %d", __FUNCTION__, __LINE__); // Check that rec stats extended max is greater than what we've sent. - numberOfErrors += ViETest::TestError(recExtendedMax >= sentExtendedMax, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); - - error = ViE.base->StopSend(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_GE(recExtendedMax, sentExtendedMax); + EXPECT_EQ(0, ViE.base->StopSend(tbChannel.videoChannel)); // // Test bandwidth statistics with NACK and FEC separately @@ -298,56 +233,33 @@ int ViEAutoTest::ViERtpRtcpStandardTest() myTransport.ClearStats(); myTransport.SetPacketLoss(rate); - error = ViE.rtp_rtcp->SetFECStatus(tbChannel.videoChannel, true, 96, 97); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ViE.base->StartReceive(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.base->StartSend(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.rtp_rtcp->SetFECStatus( + tbChannel.videoChannel, true, 96, 97)); + EXPECT_EQ(0, ViE.base->StartReceive(tbChannel.videoChannel)); + EXPECT_EQ(0, ViE.base->StartSend(tbChannel.videoChannel)); AutoTestSleep(KAutoTestSleepTimeMs); - error = ViE.rtp_rtcp->GetBandwidthUsage(tbChannel.videoChannel, - sentTotalBitrate, - sentVideoBitrate, - sentFecBitrate, - sentNackBitrate); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.rtp_rtcp->GetBandwidthUsage( + tbChannel.videoChannel, sentTotalBitrate, sentVideoBitrate, + sentFecBitrate, sentNackBitrate)); - numberOfErrors += ViETest::TestError(sentTotalBitrate > 0 && - sentFecBitrate > 0 && - sentNackBitrate == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_GT(sentTotalBitrate, 0u); + EXPECT_GE(sentFecBitrate, 10u); + EXPECT_EQ(sentNackBitrate, 0u); - error = ViE.base->StopSend(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ViE.rtp_rtcp->SetFECStatus(tbChannel.videoChannel, false, 96, 97); - error = ViE.rtp_rtcp->SetNACKStatus(tbChannel.videoChannel, true); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ViE.base->StartSend(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.base->StopSend(tbChannel.videoChannel)); + EXPECT_EQ(0, ViE.rtp_rtcp->SetFECStatus( + tbChannel.videoChannel, false, 96, 97)); + EXPECT_EQ(0, ViE.rtp_rtcp->SetNACKStatus(tbChannel.videoChannel, true)); + EXPECT_EQ(0, ViE.base->StartSend(tbChannel.videoChannel)); AutoTestSleep(KAutoTestSleepTimeMs); - error = ViE.rtp_rtcp->GetBandwidthUsage(tbChannel.videoChannel, - sentTotalBitrate, - sentVideoBitrate, - sentFecBitrate, - sentNackBitrate); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - + EXPECT_EQ(0, ViE.rtp_rtcp->GetBandwidthUsage( + tbChannel.videoChannel, sentTotalBitrate, sentVideoBitrate, + sentFecBitrate, sentNackBitrate)); + // TODO(holmer): Write a non-flaky verification of this API. // numberOfErrors += ViETest::TestError(sentTotalBitrate > 0 && // sentFecBitrate == 0 && @@ -355,46 +267,28 @@ int ViEAutoTest::ViERtpRtcpStandardTest() // "ERROR: %s at line %d", // __FUNCTION__, __LINE__); - - error = ViE.base->StopReceive(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ViE.rtp_rtcp->SetNACKStatus(tbChannel.videoChannel, false); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.base->StopReceive(tbChannel.videoChannel)); + EXPECT_EQ(0, ViE.rtp_rtcp->SetNACKStatus(tbChannel.videoChannel, false)); // // Keepalive // ViETest::Log("Testing RTP keep alive...\n"); - error = ViE.base->StopSend(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.base->StartReceive(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.base->StopSend(tbChannel.videoChannel)); + EXPECT_EQ(0, ViE.base->StartReceive(tbChannel.videoChannel)); myTransport.SetPacketLoss(0); myTransport.ClearStats(); const char keepAlivePT = 109; unsigned int deltaTimeSeconds = 2; - error = ViE.rtp_rtcp->SetRTPKeepAliveStatus(tbChannel.videoChannel, - true, - keepAlivePT, - deltaTimeSeconds); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.rtp_rtcp->SetRTPKeepAliveStatus( + tbChannel.videoChannel, true, keepAlivePT, deltaTimeSeconds)); AutoTestSleep(KAutoTestSleepTimeMs); - error = ViE.rtp_rtcp->SetRTPKeepAliveStatus(tbChannel.videoChannel, - false, - keepAlivePT, - deltaTimeSeconds); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.rtp_rtcp->SetRTPKeepAliveStatus( + tbChannel.videoChannel, false, keepAlivePT, deltaTimeSeconds)); WebRtc_Word32 numRtpPackets = 0; WebRtc_Word32 numDroppedPackets = 0; @@ -402,54 +296,32 @@ int ViEAutoTest::ViERtpRtcpStandardTest() myTransport.GetStats(numRtpPackets, numDroppedPackets, numRtcpPackets); WebRtc_Word32 expectedPackets = KAutoTestSleepTimeMs / (1000 * static_cast(deltaTimeSeconds)); - numberOfErrors += ViETest::TestError(numRtpPackets == expectedPackets, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); + EXPECT_EQ(expectedPackets, numRtpPackets); // Test to set SSRC unsigned int setSSRC = 0x01234567; ViETest::Log("Set SSRC %u", setSSRC); - error = ViE.rtp_rtcp->SetLocalSSRC(tbChannel.videoChannel, setSSRC); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ViE.base->StartReceive(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ViE.base->StartSend(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.rtp_rtcp->SetLocalSSRC(tbChannel.videoChannel, setSSRC)); + EXPECT_EQ(0, ViE.base->StartReceive(tbChannel.videoChannel)); + EXPECT_EQ(0, ViE.base->StartSend(tbChannel.videoChannel)); myTransport.EnableSSRCCheck(); AutoTestSleep(2000); unsigned int receivedSSRC = myTransport.ReceivedSSRC(); ViETest::Log("Received SSRC %u\n", receivedSSRC); - numberOfErrors += ViETest::TestError(setSSRC == receivedSSRC, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); + EXPECT_EQ(setSSRC, receivedSSRC); unsigned int localSSRC = 0; - error = ViE.rtp_rtcp->GetLocalSSRC(tbChannel.videoChannel, localSSRC); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError(localSSRC == setSSRC, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); + EXPECT_EQ(0, ViE.rtp_rtcp->GetLocalSSRC(tbChannel.videoChannel, localSSRC)); + EXPECT_EQ(setSSRC, localSSRC); unsigned int remoteSSRC = 0; - error = ViE.rtp_rtcp->GetRemoteSSRC(tbChannel.videoChannel, remoteSSRC); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError(remoteSSRC == setSSRC, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); - - error = ViE.base->StopSend(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.rtp_rtcp->GetRemoteSSRC( + tbChannel.videoChannel, remoteSSRC)); + EXPECT_EQ(setSSRC, remoteSSRC); + EXPECT_EQ(0, ViE.base->StopSend(tbChannel.videoChannel)); ViETest::Log("Testing RTP dump...\n"); @@ -461,39 +333,25 @@ int ViEAutoTest::ViERtpRtcpStandardTest() const char* outDumpName = "OutgoingRTPDump.rtp"; #endif - error = ViE.rtp_rtcp->StartRTPDump(tbChannel.videoChannel, - inDumpName, - webrtc::kRtpIncoming); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.rtp_rtcp->StartRTPDump(tbChannel.videoChannel, - outDumpName, - webrtc::kRtpOutgoing); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.rtp_rtcp->StartRTPDump( + tbChannel.videoChannel, inDumpName, webrtc::kRtpIncoming)); + EXPECT_EQ(0, ViE.rtp_rtcp->StartRTPDump( + tbChannel.videoChannel, outDumpName, webrtc::kRtpOutgoing)); - error = ViE.base->StartSend(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.base->StartSend(tbChannel.videoChannel)); AutoTestSleep(KAutoTestSleepTimeMs); - error = ViE.base->StopSend(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.base->StopSend(tbChannel.videoChannel)); AutoTestSleep(1000); - error = ViE.rtp_rtcp->StopRTPDump(tbChannel.videoChannel, - webrtc::kRtpIncoming); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.rtp_rtcp->StopRTPDump(tbChannel.videoChannel, - webrtc::kRtpOutgoing); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.rtp_rtcp->StopRTPDump( + tbChannel.videoChannel, webrtc::kRtpIncoming)); + EXPECT_EQ(0, ViE.rtp_rtcp->StopRTPDump( + tbChannel.videoChannel, webrtc::kRtpOutgoing)); - // Make sure data was actuall saved to the file and we stored the same + // Make sure data was actually saved to the file and we stored the same // amount of data in both files FILE* inDump = fopen(inDumpName, "r"); fseek(inDump, 0L, SEEK_END); @@ -504,283 +362,164 @@ int ViEAutoTest::ViERtpRtcpStandardTest() long outEndPos = ftell(outDump); fclose(outDump); - numberOfErrors += ViETest::TestError((inEndPos > 0 - && inEndPos < outEndPos + 100), - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); + EXPECT_GT(inEndPos, 0); + EXPECT_LT(inEndPos, outEndPos + 100); // Deregister external transport - error = ViE.network->DeregisterSendTransport(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.network->DeregisterSendTransport(tbChannel.videoChannel)); //*************************************************************** // Testing finished. Tear down Video Engine //*************************************************************** - - - if (numberOfErrors > 0) - { - // Test failed - ViETest::Log(" "); - ViETest::Log(" ERROR ViERTP_RTCP Standard Test FAILED!"); - ViETest::Log(" Number of errors: %d", numberOfErrors); - ViETest::Log("========================================"); - ViETest::Log(" "); - return numberOfErrors; - } - - ViETest::Log(" "); - ViETest::Log(" ViERTP_RTCP Standard Test PASSED!"); - ViETest::Log("========================================"); - ViETest::Log(" "); - return 0; } -int ViEAutoTest::ViERtpRtcpExtendedTest() +void ViEAutoTest::ViERtpRtcpExtendedTest() { - ViETest::Log(" "); - ViETest::Log("========================================"); - ViETest::Log(" ViERTP_RTCP Extended Test\n"); - //*************************************************************** // Begin create/initialize WebRTC Video Engine for testing //*************************************************************** - - - int error = 0; - int numberOfErrors = 0; - - numberOfErrors = ViERtpRtcpStandardTest(); + ViERtpRtcpStandardTest(); // Create VIE - TbInterfaces ViE("ViERtpRtcpExtendedTest", numberOfErrors); + TbInterfaces ViE("ViERtpRtcpExtendedTest"); // Create a video channel - tbVideoChannel tbChannel(ViE, numberOfErrors, webrtc::kVideoCodecVP8); + TbVideoChannel tbChannel(ViE, webrtc::kVideoCodecVP8); // Create a capture device - TbCaptureDevice tbCapture(ViE, numberOfErrors); + TbCaptureDevice tbCapture(ViE); tbCapture.ConnectTo(tbChannel.videoChannel); //tbChannel.StartReceive(rtpPort); //tbChannel.StartSend(rtpPort); TbExternalTransport myTransport(*(ViE.network)); - error = ViE.network->RegisterSendTransport(tbChannel.videoChannel, - myTransport); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ViE.base->StartReceive(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ViE.base->StartSend(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.network->RegisterSendTransport( + tbChannel.videoChannel, myTransport)); + EXPECT_EQ(0, ViE.base->StartReceive(tbChannel.videoChannel)); + EXPECT_EQ(0, ViE.base->StartSend(tbChannel.videoChannel)); //*************************************************************** // Engine ready. Begin testing class //*************************************************************** - // // Application specific RTCP // // ViERtcpObserver rtcpObserver; - error = ViE.rtp_rtcp->RegisterRTCPObserver(tbChannel.videoChannel, - rtcpObserver); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.rtp_rtcp->RegisterRTCPObserver( + tbChannel.videoChannel, rtcpObserver)); unsigned char subType = 3; unsigned int name = static_cast (0x41424344); // 'ABCD'; const char* data = "ViEAutoTest Data of length 32 --"; const unsigned short numBytes = 32; - error = ViE.rtp_rtcp->SendApplicationDefinedRTCPPacket( - tbChannel.videoChannel, subType, name, data, numBytes); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.rtp_rtcp->SendApplicationDefinedRTCPPacket( + tbChannel.videoChannel, subType, name, data, numBytes)); ViETest::Log("Sending RTCP application data...\n"); AutoTestSleep(KAutoTestSleepTimeMs); - numberOfErrors += ViETest::TestError( - (subType = rtcpObserver._subType - && !strncmp(data, rtcpObserver._data, 32) - && name == rtcpObserver._name - && numBytes == rtcpObserver._dataLength), - "ERROR: %s at line %d", __FUNCTION__, __LINE__); + + EXPECT_EQ(subType, rtcpObserver._subType); + EXPECT_STRCASEEQ(data, rtcpObserver._data); + EXPECT_EQ(name, rtcpObserver._name); + EXPECT_EQ(numBytes, rtcpObserver._dataLength); + ViETest::Log("\t RTCP application data received\n"); //*************************************************************** // Testing finished. Tear down Video Engine //*************************************************************** + EXPECT_EQ(0, ViE.base->StopReceive(tbChannel.videoChannel)); + EXPECT_EQ(0, ViE.base->StopSend(tbChannel.videoChannel)); - - error = ViE.base->StopReceive(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.base->StopSend(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ViE.network->DeregisterSendTransport(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - if (numberOfErrors > 0) - { - // Test failed - ViETest::Log(" "); - ViETest::Log(" ERROR ViERTP_RTCP Extended Test FAILED!"); - ViETest::Log(" Number of errors: %d", numberOfErrors); - ViETest::Log("========================================"); - ViETest::Log(" "); - return numberOfErrors; - } - - ViETest::Log(" "); - ViETest::Log(" ViERTP_RTCP Extended Test PASSED!"); - ViETest::Log("========================================"); - ViETest::Log(" "); - return 0; + EXPECT_EQ(0, ViE.network->DeregisterSendTransport(tbChannel.videoChannel)); } -int ViEAutoTest::ViERtpRtcpAPITest() +void ViEAutoTest::ViERtpRtcpAPITest() { - ViETest::Log(" "); - ViETest::Log("========================================"); - ViETest::Log(" ViERTP_RTCP API Test\n"); - //*************************************************************** // Begin create/initialize WebRTC Video Engine for testing //*************************************************************** - - - int error = 0; - int numberOfErrors = 0; - // Create VIE - TbInterfaces ViE("ViERtpRtcpAPITest", numberOfErrors); + TbInterfaces ViE("ViERtpRtcpAPITest"); // Create a video channel - tbVideoChannel tbChannel(ViE, numberOfErrors, webrtc::kVideoCodecVP8); + TbVideoChannel tbChannel(ViE, webrtc::kVideoCodecVP8); // Create a capture device - TbCaptureDevice tbCapture(ViE, numberOfErrors); + TbCaptureDevice tbCapture(ViE); tbCapture.ConnectTo(tbChannel.videoChannel); //*************************************************************** // Engine ready. Begin testing class //*************************************************************** - // // Check different RTCP modes // webrtc::ViERTCPMode rtcpMode = webrtc::kRtcpNone; - error = ViE.rtp_rtcp->GetRTCPStatus(tbChannel.videoChannel, - rtcpMode); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError( - rtcpMode == webrtc::kRtcpCompound_RFC4585, - "ERROR: %s at line %d", __FUNCTION__, __LINE__); - error = ViE.rtp_rtcp->SetRTCPStatus(tbChannel.videoChannel, - webrtc::kRtcpCompound_RFC4585); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.rtp_rtcp->GetRTCPStatus(tbChannel.videoChannel, - rtcpMode); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError( - rtcpMode == webrtc::kRtcpCompound_RFC4585, - "ERROR: %s at line %d", __FUNCTION__, __LINE__); - error = ViE.rtp_rtcp->SetRTCPStatus(tbChannel.videoChannel, - webrtc::kRtcpNonCompound_RFC5506); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.rtp_rtcp->GetRTCPStatus(tbChannel.videoChannel, - rtcpMode); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError( - rtcpMode == webrtc::kRtcpNonCompound_RFC5506, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.rtp_rtcp->SetRTCPStatus(tbChannel.videoChannel, - webrtc::kRtcpNone); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.rtp_rtcp->GetRTCPStatus(tbChannel.videoChannel, - rtcpMode); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError(rtcpMode == webrtc::kRtcpNone, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); - error = ViE.rtp_rtcp->SetRTCPStatus(tbChannel.videoChannel, - webrtc::kRtcpCompound_RFC4585); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.rtp_rtcp->GetRTCPStatus( + tbChannel.videoChannel, rtcpMode)); + EXPECT_EQ(webrtc::kRtcpCompound_RFC4585, rtcpMode); + EXPECT_EQ(0, ViE.rtp_rtcp->SetRTCPStatus( + tbChannel.videoChannel, webrtc::kRtcpCompound_RFC4585)); + EXPECT_EQ(0, ViE.rtp_rtcp->GetRTCPStatus( + tbChannel.videoChannel, rtcpMode)); + EXPECT_EQ(webrtc::kRtcpCompound_RFC4585, rtcpMode); + EXPECT_EQ(0, ViE.rtp_rtcp->SetRTCPStatus( + tbChannel.videoChannel, webrtc::kRtcpNonCompound_RFC5506)); + EXPECT_EQ(0, ViE.rtp_rtcp->GetRTCPStatus( + tbChannel.videoChannel, rtcpMode)); + EXPECT_EQ(webrtc::kRtcpNonCompound_RFC5506, rtcpMode); + EXPECT_EQ(0, ViE.rtp_rtcp->SetRTCPStatus( + tbChannel.videoChannel, webrtc::kRtcpNone)); + EXPECT_EQ(0, ViE.rtp_rtcp->GetRTCPStatus( + tbChannel.videoChannel, rtcpMode)); + EXPECT_EQ(webrtc::kRtcpNone, rtcpMode); + EXPECT_EQ(0, ViE.rtp_rtcp->SetRTCPStatus( + tbChannel.videoChannel, webrtc::kRtcpCompound_RFC4585)); // // CName is testedn in SimpleTest // Start sequence number is tested in SimplTEst // const char* testCName = "ViEAutotestCName"; - error = ViE.rtp_rtcp->SetRTCPCName(tbChannel.videoChannel, - testCName); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.rtp_rtcp->SetRTCPCName( + tbChannel.videoChannel, testCName)); + char returnCName[256]; memset(returnCName, 0, 256); - error = ViE.rtp_rtcp->GetRTCPCName(tbChannel.videoChannel, returnCName); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError((strcmp(testCName, returnCName) == 0), - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); + EXPECT_EQ(0, ViE.rtp_rtcp->GetRTCPCName( + tbChannel.videoChannel, returnCName)); + EXPECT_STRCASEEQ(testCName, returnCName); // // SSRC // - error = ViE.rtp_rtcp->SetLocalSSRC(tbChannel.videoChannel, - 0x01234567); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.rtp_rtcp->SetLocalSSRC(tbChannel.videoChannel, - 0x76543210); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.rtp_rtcp->SetLocalSSRC( + tbChannel.videoChannel, 0x01234567)); + EXPECT_EQ(0, ViE.rtp_rtcp->SetLocalSSRC( + tbChannel.videoChannel, 0x76543210)); unsigned int ssrc = 0; - error = ViE.rtp_rtcp->GetLocalSSRC(tbChannel.videoChannel, ssrc); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ViE.rtp_rtcp->SetStartSequenceNumber(tbChannel.videoChannel, 1000); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.rtp_rtcp->GetLocalSSRC(tbChannel.videoChannel, ssrc)); + EXPECT_EQ(0, ViE.rtp_rtcp->SetStartSequenceNumber( + tbChannel.videoChannel, 1000)); tbChannel.StartSend(); - error = ViE.rtp_rtcp->SetStartSequenceNumber(tbChannel.videoChannel, 12345); - numberOfErrors += ViETest::TestError(error == -1, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_NE(0, ViE.rtp_rtcp->SetStartSequenceNumber( + tbChannel.videoChannel, 12345)); tbChannel.StopSend(); // // Start sequence number // - error = ViE.rtp_rtcp->SetStartSequenceNumber(tbChannel.videoChannel, 12345); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.rtp_rtcp->SetStartSequenceNumber(tbChannel.videoChannel, 1000); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.rtp_rtcp->SetStartSequenceNumber( + tbChannel.videoChannel, 12345)); + EXPECT_EQ(0, ViE.rtp_rtcp->SetStartSequenceNumber( + tbChannel.videoChannel, 1000)); tbChannel.StartSend(); - error = ViE.rtp_rtcp->SetStartSequenceNumber(tbChannel.videoChannel, 12345); - numberOfErrors += ViETest::TestError(error == -1, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_NE(0, ViE.rtp_rtcp->SetStartSequenceNumber( + tbChannel.videoChannel, 12345)); tbChannel.StopSend(); // @@ -793,43 +532,24 @@ int ViEAutoTest::ViERtpRtcpAPITest() const unsigned short numBytes = 32; tbChannel.StartSend(); - error = ViE.rtp_rtcp->SendApplicationDefinedRTCPPacket( - tbChannel.videoChannel, subType, name, data, numBytes); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.rtp_rtcp->SendApplicationDefinedRTCPPacket( - tbChannel.videoChannel, subType, name, NULL, numBytes); - // NULL input - numberOfErrors += ViETest::TestError(error != 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.rtp_rtcp->SendApplicationDefinedRTCPPacket( - tbChannel.videoChannel, subType, name, data, numBytes - 1); - // incorrect length - numberOfErrors += ViETest::TestError(error != 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.rtp_rtcp->GetRTCPStatus(tbChannel.videoChannel, - rtcpMode); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.rtp_rtcp->SendApplicationDefinedRTCPPacket( - tbChannel.videoChannel, subType, name, data, numBytes); - // RTCP off - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.rtp_rtcp->SetRTCPStatus(tbChannel.videoChannel, - webrtc::kRtcpCompound_RFC4585); - numberOfErrors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.rtp_rtcp->SendApplicationDefinedRTCPPacket( + tbChannel.videoChannel, subType, name, data, numBytes)); + EXPECT_NE(0, ViE.rtp_rtcp->SendApplicationDefinedRTCPPacket( + tbChannel.videoChannel, subType, name, NULL, numBytes)) << + "Should fail on NULL input."; + EXPECT_NE(0, ViE.rtp_rtcp->SendApplicationDefinedRTCPPacket( + tbChannel.videoChannel, subType, name, data, numBytes - 1)) << + "Should fail on incorrect length."; + + EXPECT_EQ(0, ViE.rtp_rtcp->GetRTCPStatus( + tbChannel.videoChannel, rtcpMode)); + EXPECT_EQ(0, ViE.rtp_rtcp->SendApplicationDefinedRTCPPacket( + tbChannel.videoChannel, subType, name, data, numBytes)); + EXPECT_EQ(0, ViE.rtp_rtcp->SetRTCPStatus( + tbChannel.videoChannel, webrtc::kRtcpCompound_RFC4585)); tbChannel.StopSend(); - error = ViE.rtp_rtcp->SendApplicationDefinedRTCPPacket( - tbChannel.videoChannel, subType, name, data, numBytes); - // Not sending - numberOfErrors += ViETest::TestError(error != 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_NE(0, ViE.rtp_rtcp->SendApplicationDefinedRTCPPacket( + tbChannel.videoChannel, subType, name, data, numBytes)); } // @@ -847,59 +567,31 @@ int ViEAutoTest::ViERtpRtcpAPITest() bool enabled = false; char getPT = 0; unsigned int getDeltaTime = 0; - error = ViE.rtp_rtcp->SetRTPKeepAliveStatus(tbChannel.videoChannel, - true, 119); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.rtp_rtcp->SetRTPKeepAliveStatus(tbChannel.videoChannel, - true, setPT, setDeltaTime); - numberOfErrors += ViETest::TestError(error == -1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.rtp_rtcp->SetRTPKeepAliveStatus(tbChannel.videoChannel, - false, setPT, setDeltaTime); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.rtp_rtcp->SetRTPKeepAliveStatus(tbChannel.videoChannel, - true, setPT, setDeltaTime); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.rtp_rtcp->SetRTPKeepAliveStatus( + tbChannel.videoChannel, true, 119)); + EXPECT_NE(0, ViE.rtp_rtcp->SetRTPKeepAliveStatus( + tbChannel.videoChannel, true, setPT, setDeltaTime)); + EXPECT_EQ(0, ViE.rtp_rtcp->SetRTPKeepAliveStatus( + tbChannel.videoChannel, false, setPT, setDeltaTime)); + EXPECT_EQ(0, ViE.rtp_rtcp->SetRTPKeepAliveStatus( + tbChannel.videoChannel, true, setPT, setDeltaTime)); + EXPECT_EQ(0, ViE.rtp_rtcp->GetRTPKeepAliveStatus( + tbChannel.videoChannel, enabled, getPT, getDeltaTime)); - error = ViE.rtp_rtcp->GetRTPKeepAliveStatus(tbChannel.videoChannel, - enabled, getPT, - getDeltaTime); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - numberOfErrors += ViETest::TestError((enabled == true && setPT == getPT - && setDeltaTime == getDeltaTime), - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_TRUE(enabled); + EXPECT_EQ(setPT, getPT); + EXPECT_EQ(setDeltaTime, getDeltaTime); - error = ViE.base->StartSend(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.base->StartSend(tbChannel.videoChannel)); + + EXPECT_NE(0, ViE.rtp_rtcp->SetRTPKeepAliveStatus( + tbChannel.videoChannel, true, setPT, setDeltaTime)); - error = ViE.rtp_rtcp->SetRTPKeepAliveStatus(tbChannel.videoChannel, - true, setPT, setDeltaTime); - numberOfErrors += ViETest::TestError(error == -1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); tbChannel.StopSend(); - error = ViE.rtp_rtcp->SetRTPKeepAliveStatus(tbChannel.videoChannel, - enabled, getPT, 0); - numberOfErrors += ViETest::TestError(error == -1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.rtp_rtcp->SetRTPKeepAliveStatus(tbChannel.videoChannel, - enabled, getPT, 61); - numberOfErrors += ViETest::TestError(error == -1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_NE(0, ViE.rtp_rtcp->SetRTPKeepAliveStatus( + tbChannel.videoChannel, enabled, getPT, 0)); + EXPECT_NE(0, ViE.rtp_rtcp->SetRTPKeepAliveStatus( + tbChannel.videoChannel, enabled, getPT, 61)); } // // RTP Dump @@ -910,146 +602,66 @@ int ViEAutoTest::ViERtpRtcpAPITest() #else const char* dumpName = "DumpFileName.rtp"; #endif - error = ViE.rtp_rtcp->StartRTPDump(tbChannel.videoChannel, - dumpName, - webrtc::kRtpIncoming); - - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.rtp_rtcp->StopRTPDump(tbChannel.videoChannel, - webrtc::kRtpIncoming); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.rtp_rtcp->StopRTPDump(tbChannel.videoChannel, - webrtc::kRtpIncoming); - numberOfErrors += ViETest::TestError(error == -1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.rtp_rtcp->StartRTPDump(tbChannel.videoChannel, - dumpName, - webrtc::kRtpOutgoing); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.rtp_rtcp->StopRTPDump(tbChannel.videoChannel, - webrtc::kRtpOutgoing); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.rtp_rtcp->StopRTPDump(tbChannel.videoChannel, - webrtc::kRtpOutgoing); - numberOfErrors += ViETest::TestError(error == -1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.rtp_rtcp->StartRTPDump(tbChannel.videoChannel, - dumpName, - (webrtc::RTPDirections) 3); - numberOfErrors += ViETest::TestError(error == -1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.rtp_rtcp->StartRTPDump( + tbChannel.videoChannel, dumpName, webrtc::kRtpIncoming)); + EXPECT_EQ(0, ViE.rtp_rtcp->StopRTPDump( + tbChannel.videoChannel, webrtc::kRtpIncoming)); + EXPECT_NE(0, ViE.rtp_rtcp->StopRTPDump( + tbChannel.videoChannel, webrtc::kRtpIncoming)); + EXPECT_EQ(0, ViE.rtp_rtcp->StartRTPDump( + tbChannel.videoChannel, dumpName, webrtc::kRtpOutgoing)); + EXPECT_EQ(0, ViE.rtp_rtcp->StopRTPDump( + tbChannel.videoChannel, webrtc::kRtpOutgoing)); + EXPECT_NE(0, ViE.rtp_rtcp->StopRTPDump( + tbChannel.videoChannel, webrtc::kRtpOutgoing)); + EXPECT_NE(0, ViE.rtp_rtcp->StartRTPDump( + tbChannel.videoChannel, dumpName, (webrtc::RTPDirections) 3)); } // // RTP/RTCP Observers // { ViERtpObserver rtpObserver; - error = ViE.rtp_rtcp->RegisterRTPObserver(tbChannel.videoChannel, - rtpObserver); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.rtp_rtcp->RegisterRTPObserver(tbChannel.videoChannel, - rtpObserver); - numberOfErrors += ViETest::TestError(error == -1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.rtp_rtcp->DeregisterRTPObserver( - tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.rtp_rtcp->DeregisterRTPObserver( - tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == -1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.rtp_rtcp->RegisterRTPObserver( + tbChannel.videoChannel, rtpObserver)); + EXPECT_NE(0, ViE.rtp_rtcp->RegisterRTPObserver( + tbChannel.videoChannel, rtpObserver)); + EXPECT_EQ(0, ViE.rtp_rtcp->DeregisterRTPObserver( + tbChannel.videoChannel)); + EXPECT_NE(0, ViE.rtp_rtcp->DeregisterRTPObserver( + tbChannel.videoChannel)); ViERtcpObserver rtcpObserver; - error = ViE.rtp_rtcp->RegisterRTCPObserver(tbChannel.videoChannel, - rtcpObserver); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.rtp_rtcp-> - RegisterRTCPObserver(tbChannel.videoChannel, rtcpObserver); - numberOfErrors += ViETest::TestError(error == -1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.rtp_rtcp->DeregisterRTCPObserver(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.rtp_rtcp->DeregisterRTCPObserver(tbChannel.videoChannel); - numberOfErrors += ViETest::TestError(error == -1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.rtp_rtcp->RegisterRTCPObserver( + tbChannel.videoChannel, rtcpObserver)); + EXPECT_NE(0, ViE.rtp_rtcp->RegisterRTCPObserver( + tbChannel.videoChannel, rtcpObserver)); + EXPECT_EQ(0, ViE.rtp_rtcp->DeregisterRTCPObserver( + tbChannel.videoChannel)); + EXPECT_NE(0, ViE.rtp_rtcp->DeregisterRTCPObserver( + tbChannel.videoChannel)); } // // PLI // { - error = ViE.rtp_rtcp->SetKeyFrameRequestMethod( - tbChannel.videoChannel, webrtc::kViEKeyFrameRequestPliRtcp); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.rtp_rtcp->SetKeyFrameRequestMethod( - tbChannel.videoChannel, webrtc::kViEKeyFrameRequestPliRtcp); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.rtp_rtcp->SetKeyFrameRequestMethod( - tbChannel.videoChannel, webrtc::kViEKeyFrameRequestNone); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.rtp_rtcp->SetKeyFrameRequestMethod( - tbChannel.videoChannel, webrtc::kViEKeyFrameRequestNone); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.rtp_rtcp->SetKeyFrameRequestMethod( + tbChannel.videoChannel, webrtc::kViEKeyFrameRequestPliRtcp)); + EXPECT_EQ(0, ViE.rtp_rtcp->SetKeyFrameRequestMethod( + tbChannel.videoChannel, webrtc::kViEKeyFrameRequestPliRtcp)); + EXPECT_EQ(0, ViE.rtp_rtcp->SetKeyFrameRequestMethod( + tbChannel.videoChannel, webrtc::kViEKeyFrameRequestNone)); + EXPECT_EQ(0, ViE.rtp_rtcp->SetKeyFrameRequestMethod( + tbChannel.videoChannel, webrtc::kViEKeyFrameRequestNone)); } // // NACK // { - error = ViE.rtp_rtcp->SetNACKStatus(tbChannel.videoChannel, - true); - numberOfErrors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, ViE.rtp_rtcp->SetNACKStatus(tbChannel.videoChannel, true)); } //*************************************************************** // Testing finished. Tear down Video Engine //*************************************************************** - - if (numberOfErrors > 0) - { - // Test failed - ViETest::Log(" "); - ViETest::Log(" ERROR ViERTP_RTCP API Test FAILED!"); - ViETest::Log(" Number of errors: %d", numberOfErrors); - ViETest::Log("========================================"); - ViETest::Log(" "); - return numberOfErrors; - } - - ViETest::Log(" "); - ViETest::Log(" ViERTP_RTCP API Test PASSED!"); - ViETest::Log("========================================"); - ViETest::Log(" "); - return 0; } diff --git a/src/video_engine/test/auto_test/source/vie_comparison_tests.cc b/src/video_engine/test/auto_test/source/vie_comparison_tests.cc index b0cef00a4..bf56dacfb 100644 --- a/src/video_engine/test/auto_test/source/vie_comparison_tests.cc +++ b/src/video_engine/test/auto_test/source/vie_comparison_tests.cc @@ -18,49 +18,36 @@ #include "vie_fake_camera.h" #include "vie_to_file_renderer.h" -ViEComparisonTests::ViEComparisonTests() { - ViETest::Init(ViETest::kUseGTestExpectsForTestErrors); -} - -ViEComparisonTests::~ViEComparisonTests() { - ViETest::Terminate(); -} void ViEComparisonTests::TestCallSetup( - const std::string& i420_test_video_path, + const std::string& i420_video_file, int width, int height, ViEToFileRenderer* local_file_renderer, ViEToFileRenderer* remote_file_renderer) { - int ignored; - TbInterfaces interfaces("TestCallSetup", ignored); + TbInterfaces interfaces("TestCallSetup"); int video_channel = -1; - int error = interfaces.base->CreateChannel(video_channel); - ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, interfaces.base->CreateChannel(video_channel)); ViEFakeCamera fake_camera(interfaces.capture); - if (!fake_camera.StartCameraInNewThread(i420_test_video_path, + if (!fake_camera.StartCameraInNewThread(i420_video_file, width, height)) { // No point in continuing if we have no proper video source - ViETest::TestError(false, "ERROR: %s at line %d: " - "Could not open input video %s: aborting test...", - __FUNCTION__, __LINE__, i420_test_video_path.c_str()); + ADD_FAILURE() << "Could not open input video " << i420_video_file << + ": aborting test..."; return; } int capture_id = fake_camera.capture_id(); // Apparently, we need to connect external capture devices, but we should // not start them since the external device is not a proper device. - error = interfaces.capture->ConnectCaptureDevice(capture_id, - video_channel); - ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, interfaces.capture->ConnectCaptureDevice( + capture_id, video_channel)); - ConfigureRtpRtcp(interfaces.rtp_rtcp, &ignored, video_channel); + ConfigureRtpRtcp(interfaces.rtp_rtcp, video_channel); webrtc::ViERender *render_interface = interfaces.render; @@ -72,17 +59,15 @@ void ViEComparisonTests::TestCallSetup( reinterpret_cast("Fake Capture Device"); ::TestI420CallSetup(interfaces.codec, interfaces.video_engine, - interfaces.base, interfaces.network, - &ignored, video_channel, device_name); + interfaces.base, interfaces.network, video_channel, + device_name); AutoTestSleep(KAutoTestSleepTimeMs); - error = interfaces.base->StopReceive(video_channel); - ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, interfaces.base->StopReceive(video_channel)); - StopAndRemoveRenderers(interfaces.base, render_interface, &ignored, - video_channel, capture_id); + StopAndRemoveRenderers(interfaces.base, render_interface, video_channel, + capture_id); interfaces.capture->DisconnectCaptureDevice(video_channel); @@ -92,9 +77,7 @@ void ViEComparisonTests::TestCallSetup( // data after rendering has been stopped. fake_camera.StopCamera(); - error = interfaces.base->DeleteChannel(video_channel); - ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, interfaces.base->DeleteChannel(video_channel)); } void ViEComparisonTests::TestCodecs( @@ -103,37 +86,32 @@ void ViEComparisonTests::TestCodecs( int height, ViEToFileRenderer* local_file_renderer, ViEToFileRenderer* remote_file_renderer) { - int ignored = 0; - TbInterfaces interfaces = TbInterfaces("TestCodecs", ignored); + TbInterfaces interfaces = TbInterfaces("TestCodecs"); ViEFakeCamera fake_camera(interfaces.capture); if (!fake_camera.StartCameraInNewThread(i420_video_file, width, height)) { // No point in continuing if we have no proper video source - ViETest::TestError(false, "ERROR: %s at line %d: " - "Could not open input video %s: aborting test...", - __FUNCTION__, __LINE__, i420_video_file.c_str()); + ADD_FAILURE() << "Could not open input video " << i420_video_file << + ": aborting test..."; return; } int video_channel = -1; int capture_id = fake_camera.capture_id(); - int error = interfaces.base->CreateChannel(video_channel); - ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = interfaces.capture->ConnectCaptureDevice(capture_id, video_channel); - ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); + EXPECT_EQ(0, interfaces.base->CreateChannel(video_channel)); + EXPECT_EQ(0, interfaces.capture->ConnectCaptureDevice( + capture_id, video_channel)); - ConfigureRtpRtcp(interfaces.rtp_rtcp, &ignored, video_channel); + ConfigureRtpRtcp(interfaces.rtp_rtcp, video_channel); RenderToFile(interfaces.render, capture_id, local_file_renderer); RenderToFile(interfaces.render, video_channel, remote_file_renderer); // Force the codec resolution to what our input video is so we can make // comparisons later. Our comparison algorithms wouldn't like scaling. - ::TestCodecs(interfaces, ignored, fake_camera.capture_id(), video_channel, + ::TestCodecs(interfaces, fake_camera.capture_id(), video_channel, width, height); fake_camera.StopCamera(); diff --git a/src/video_engine/vie_capture_impl.cc b/src/video_engine/vie_capture_impl.cc index c1664979c..0fa1ae376 100644 --- a/src/video_engine/vie_capture_impl.cc +++ b/src/video_engine/vie_capture_impl.cc @@ -265,7 +265,7 @@ int ViECaptureImpl::ReleaseCaptureDevice(const int captureId) WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, ViEId(_instanceId), "%s: Capture device %d doesn't exist", __FUNCTION__, captureId); - SetLastError(kViECaptureDeviceDoesnNotExist); + SetLastError(kViECaptureDeviceDoesNotExist); return -1; } @@ -302,7 +302,7 @@ int ViECaptureImpl::ConnectCaptureDevice(const int captureId, ViEId(_instanceId, videoChannel), "%s: Capture device %d doesn't exist", __FUNCTION__, captureId); - SetLastError(kViECaptureDeviceDoesnNotExist); + SetLastError(kViECaptureDeviceDoesNotExist); return -1; } @@ -424,7 +424,7 @@ int ViECaptureImpl::StartCapture(const int captureId, ViEId(_instanceId, captureId), "%s: Capture device %d doesn't exist", __FUNCTION__, captureId); - SetLastError(kViECaptureDeviceDoesnNotExist); + SetLastError(kViECaptureDeviceDoesNotExist); return -1; } if (ptrViECapture->Started()) @@ -458,7 +458,7 @@ int ViECaptureImpl::StopCapture(const int captureId) ViEId(_instanceId, captureId), "%s: Capture device %d doesn't exist", __FUNCTION__, captureId); - SetLastError(kViECaptureDeviceDoesnNotExist); + SetLastError(kViECaptureDeviceDoesNotExist); return -1; } if (!ptrViECapture->Started()) @@ -513,7 +513,7 @@ int ViECaptureImpl::SetRotateCapturedFrames(const int captureId, ViEId(_instanceId, captureId), "%s: Capture device %d doesn't exist", __FUNCTION__, captureId); - SetLastError(kViECaptureDeviceDoesnNotExist); + SetLastError(kViECaptureDeviceDoesNotExist); return -1; } if (ptrViECapture->SetRotateCapturedFrames(rotation) != 0) @@ -548,7 +548,7 @@ int ViECaptureImpl::SetCaptureDelay(const int captureId, ViEId(_instanceId, captureId), "%s: Capture device %d doesn't exist", __FUNCTION__, captureId); - SetLastError(kViECaptureDeviceDoesnNotExist); + SetLastError(kViECaptureDeviceDoesNotExist); return -1; } @@ -711,7 +711,7 @@ int ViECaptureImpl::EnableBrightnessAlarm(const int captureId, ViEId(_instanceId, captureId), "%s: Capture device %d doesn't exist", __FUNCTION__, captureId); - SetLastError(kViECaptureDeviceDoesnNotExist); + SetLastError(kViECaptureDeviceDoesNotExist); return -1; } if (ptrViECapture->EnableBrightnessAlarm(enable) != 0) @@ -738,7 +738,7 @@ int ViECaptureImpl::RegisterObserver(const int captureId, ViEId(_instanceId, captureId), "%s: Capture device %d doesn't exist", __FUNCTION__, captureId); - SetLastError(kViECaptureDeviceDoesnNotExist); + SetLastError(kViECaptureDeviceDoesNotExist); return -1; } if (ptrViECapture->IsObserverRegistered()) @@ -773,7 +773,7 @@ int ViECaptureImpl::DeregisterObserver(const int captureId) ViEId(_instanceId, captureId), "%s: Capture device %d doesn't exist", __FUNCTION__, captureId); - SetLastError(kViECaptureDeviceDoesnNotExist); + SetLastError(kViECaptureDeviceDoesNotExist); return -1; } if (!ptrViECapture->IsObserverRegistered()) diff --git a/src/video_engine/vie_input_manager.cc b/src/video_engine/vie_input_manager.cc index 8e3e3b495..46ffe2800 100644 --- a/src/video_engine/vie_input_manager.cc +++ b/src/video_engine/vie_input_manager.cc @@ -295,7 +295,7 @@ int ViEInputManager::CreateCaptureDevice(const WebRtc_UWord8* deviceUniqueIdUTF8 WEBRTC_TRACE(webrtc::kTraceDebug, webrtc::kTraceVideo, ViEId(_engineId), "%s:%d Capture device NOT found by unique ID: %s. Returning", __FUNCTION__, __LINE__, deviceUniqueIdUTF8); - return kViECaptureDeviceDoesnNotExist; + return kViECaptureDeviceDoesNotExist; } int newcaptureId = 0;