diff --git a/DEPS b/DEPS index c076cda9c..2208b02b0 100644 --- a/DEPS +++ b/DEPS @@ -14,7 +14,7 @@ vars = { # External resources like video and audio files used for testing purposes. # Downloaded on demand when needed. - "webrtc_resources_revision": "3", + "webrtc_resources_revision": "4", } # NOTE: Prefer revision numbers to tags for svn deps. diff --git a/src/modules/video_processing/main/test/unit_test/color_enhancement_test.cc b/src/modules/video_processing/main/test/unit_test/color_enhancement_test.cc index cdf7cbeed..c494c856f 100644 --- a/src/modules/video_processing/main/test/unit_test/color_enhancement_test.cc +++ b/src/modules/video_processing/main/test/unit_test/color_enhancement_test.cc @@ -8,14 +8,15 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "unit_test.h" -#include "video_processing.h" -#include "tick_util.h" - #include #include -using namespace webrtc; +#include "modules/video_processing/main/interface/video_processing.h" +#include "modules/video_processing/main/test/unit_test/unit_test.h" +#include "system_wrappers/interface/tick_util.h" +#include "testsupport/fileutils.h" + +namespace webrtc { TEST_F(VideoProcessingModuleTest, ColorEnhancement) { @@ -23,7 +24,17 @@ TEST_F(VideoProcessingModuleTest, ColorEnhancement) TickTime t1; TickInterval accTicks; - FILE* modFile = fopen("foremanColorEnhancedVPM.yuv", "w+b"); + // Use a shorter version of the Foreman clip for this test. + fclose(_sourceFile); + const std::string video_file = + webrtc::test::ResourcePath("foreman_cif_short", "yuv"); + _sourceFile = fopen(video_file.c_str(), "rb"); + ASSERT_TRUE(_sourceFile != NULL) << + "Cannot read source file: " + video_file + "\n"; + + std::string output_file = webrtc::test::OutputPath() + + "foremanColorEnhancedVPM_cif_short.yuv"; + FILE* modFile = fopen(output_file.c_str(), "w+b"); ASSERT_TRUE(modFile != NULL) << "Could not open output file.\n"; WebRtc_UWord32 frameNum = 0; @@ -43,8 +54,11 @@ TEST_F(VideoProcessingModuleTest, ColorEnhancement) rewind(modFile); printf("Comparing files...\n\n"); - FILE* refFile = fopen("foremanColorEnhanced.yuv", "rb"); - ASSERT_TRUE(refFile != NULL) << "Cannot open reference file foremanColorEnhanced.yuv\n" + std::string reference_filename = + webrtc::test::ResourcePath("foremanColorEnhanced_cif_short", "yuv"); + FILE* refFile = fopen(reference_filename.c_str(), "rb"); + ASSERT_TRUE(refFile != NULL) << "Cannot open reference file: " << + reference_filename << "\n" "Create the reference by running Matlab script createTable.m."; // get file lenghts @@ -102,7 +116,10 @@ TEST_F(VideoProcessingModuleTest, ColorEnhancement) &refFrame[safeGuard + numPixels], numPixels / 2)) << "Function is not modifying all chrominance pixels"; + ASSERT_EQ(0, fclose(refFile)); + ASSERT_EQ(0, fclose(modFile)); delete [] testFrame; delete [] refFrame; } +} // namespace webrtc diff --git a/src/modules/video_processing/main/test/unit_test/content_metrics_test.cc b/src/modules/video_processing/main/test/unit_test/content_metrics_test.cc index 4374d24d0..20e803c78 100644 --- a/src/modules/video_processing/main/test/unit_test/content_metrics_test.cc +++ b/src/modules/video_processing/main/test/unit_test/content_metrics_test.cc @@ -8,11 +8,11 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "unit_test.h" -#include "video_processing.h" -#include "content_analysis.h" +#include "modules/video_processing/main/interface/video_processing.h" +#include "modules/video_processing/main/source/content_analysis.h" +#include "modules/video_processing/main/test/unit_test/unit_test.h" -using namespace webrtc; +namespace webrtc { TEST_F(VideoProcessingModuleTest, ContentAnalysis) { @@ -36,3 +36,5 @@ TEST_F(VideoProcessingModuleTest, ContentAnalysis) } ASSERT_NE(0, feof(_sourceFile)) << "Error reading source file"; } + +} // namespace webrtc diff --git a/src/modules/video_processing/main/test/unit_test/deflickering_test.cc b/src/modules/video_processing/main/test/unit_test/deflickering_test.cc index 42f952aa7..f91dc133f 100644 --- a/src/modules/video_processing/main/test/unit_test/deflickering_test.cc +++ b/src/modules/video_processing/main/test/unit_test/deflickering_test.cc @@ -8,14 +8,15 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "unit_test.h" -#include "video_processing.h" -#include "tick_util.h" - #include #include -using namespace webrtc; +#include "modules/video_processing/main/interface/video_processing.h" +#include "modules/video_processing/main/test/unit_test/unit_test.h" +#include "system_wrappers/interface/tick_util.h" +#include "testsupport/fileutils.h" + +namespace webrtc { TEST_F(VideoProcessingModuleTest, Deflickering) { @@ -28,12 +29,17 @@ TEST_F(VideoProcessingModuleTest, Deflickering) // Close automatically opened Foreman. fclose(_sourceFile); - _sourceFile = fopen("deflicker_testfile_before.yuv", "rb"); + const std::string input_file = + webrtc::test::ResourcePath("deflicker_before_cif_short", "yuv"); + _sourceFile = fopen(input_file.c_str(), "rb"); ASSERT_TRUE(_sourceFile != NULL) << - "Cannot read input file deflicker_testfile_before.yuv\n"; + "Cannot read input file: " << input_file << "\n"; - FILE* deflickerFile = fopen("deflicker_testfile.yuv", "wb"); - ASSERT_TRUE(deflickerFile != NULL) << "Could not open output file.\n"; + const std::string output_file = + webrtc::test::OutputPath() + "deflicker_output_cif_short.yuv"; + FILE* deflickerFile = fopen(output_file.c_str(), "wb"); + ASSERT_TRUE(deflickerFile != NULL) << + "Could not open output file: " << output_file << "\n"; printf("\nRun time [us / frame]:\n"); for (WebRtc_UWord32 runIdx = 0; runIdx < NumRuns; runIdx++) @@ -73,9 +79,13 @@ TEST_F(VideoProcessingModuleTest, Deflickering) rewind(_sourceFile); } + ASSERT_EQ(0, fclose(deflickerFile)); + // TODO(kjellander): Add verification of deflicker output file. printf("\nAverage run time = %d us / frame\n", static_cast(avgRuntime / frameNum / NumRuns)); printf("Min run time = %d us / frame\n\n", static_cast(minRuntime / frameNum)); } + +} // namespace webrtc diff --git a/src/modules/video_processing/main/test/unit_test/denoising_test.cc b/src/modules/video_processing/main/test/unit_test/denoising_test.cc index 0dc53ed78..173ceb8ce 100644 --- a/src/modules/video_processing/main/test/unit_test/denoising_test.cc +++ b/src/modules/video_processing/main/test/unit_test/denoising_test.cc @@ -8,15 +8,15 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "unit_test.h" -#include "video_processing.h" - -#include "tick_util.h" - #include #include -using namespace webrtc; +#include "modules/video_processing/main/interface/video_processing.h" +#include "modules/video_processing/main/test/unit_test/unit_test.h" +#include "system_wrappers/interface/tick_util.h" +#include "testsupport/fileutils.h" + +namespace webrtc { TEST_F(VideoProcessingModuleTest, Denoising) { @@ -26,11 +26,17 @@ TEST_F(VideoProcessingModuleTest, Denoising) WebRtc_Word64 minRuntime = 0; WebRtc_Word64 avgRuntime = 0; - FILE* denoiseFile = fopen("denoise_testfile.yuv", "wb"); - ASSERT_TRUE(denoiseFile != NULL) << "Could not open output file.\n"; + const std::string denoise_filename = + webrtc::test::OutputPath() + "denoise_testfile.yuv"; + FILE* denoiseFile = fopen(denoise_filename.c_str(), "wb"); + ASSERT_TRUE(denoiseFile != NULL) << + "Could not open output file: " << denoise_filename << "\n"; - FILE* noiseFile = fopen("noise_testfile.yuv", "wb"); - ASSERT_TRUE(noiseFile != NULL) << "Could not open noisy file.\n"; + const std::string noise_filename = + webrtc::test::OutputPath() + "noise_testfile.yuv"; + FILE* noiseFile = fopen(noise_filename.c_str(), "wb"); + ASSERT_TRUE(noiseFile != NULL) << + "Could not open noisy file: " << noise_filename << "\n"; printf("\nRun time [us / frame]:\n"); for (WebRtc_UWord32 runIdx = 0; runIdx < NumRuns; runIdx++) @@ -110,9 +116,12 @@ TEST_F(VideoProcessingModuleTest, Denoising) rewind(_sourceFile); } - + ASSERT_EQ(0, fclose(denoiseFile)); + ASSERT_EQ(0, fclose(noiseFile)); printf("\nAverage run time = %d us / frame\n", static_cast(avgRuntime / frameNum / NumRuns)); printf("Min run time = %d us / frame\n\n", static_cast(minRuntime / frameNum)); } + +} // namespace webrtc diff --git a/src/modules/video_processing/main/test/unit_test/unit_test.cc b/src/modules/video_processing/main/test/unit_test/unit_test.cc index 9b627efad..32c31129c 100644 --- a/src/modules/video_processing/main/test/unit_test/unit_test.cc +++ b/src/modules/video_processing/main/test/unit_test/unit_test.cc @@ -8,33 +8,20 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "unit_test.h" +#include "modules/video_processing/main/test/unit_test/unit_test.h" + +#include #include "common_video/libyuv/include/libyuv.h" -#include "tick_util.h" -#include "trace.h" +#include "system_wrappers/interface/tick_util.h" +#include "testsupport/fileutils.h" - -using webrtc::Trace; +namespace webrtc { void TestSize(VideoFrame& sourceFrame, WebRtc_UWord32 targetWidth, WebRtc_UWord32 targetHeight, WebRtc_UWord32 mode, VideoProcessingModule *vpm); -class VPMEnvironment : public ::testing::Environment -{ -public: - virtual void SetUp() - { - Trace::CreateTrace(); - ASSERT_EQ(0, Trace::SetTraceFile("VPMTrace.txt")); - } - - virtual void TearDown() - { - Trace::ReturnTrace(); - } -}; VideoProcessingModuleTest::VideoProcessingModuleTest() : _vpm(NULL), _sourceFile(NULL), @@ -53,9 +40,11 @@ void VideoProcessingModuleTest::SetUp() _videoFrame.SetWidth(_width); _videoFrame.SetHeight(_height); - _sourceFile = fopen("testFiles/foreman_cif.yuv","rb"); + const std::string video_file = + webrtc::test::ResourcePath("foreman_cif", "yuv"); + _sourceFile = fopen(video_file.c_str(),"rb"); ASSERT_TRUE(_sourceFile != NULL) << - "Cannot read source file: testFiles/foreman_cif.yuv\n"; + "Cannot read source file: " + video_file + "\n"; } void VideoProcessingModuleTest::TearDown() @@ -357,8 +346,9 @@ void TestSize(VideoFrame& sourceFrame, WebRtc_UWord32 targetWidth, { VideoFrame *outFrame = NULL; std::ostringstream filename; - filename << "Resampler_"<< mode <<"_" << targetWidth << "x" << - targetHeight << "_30Hz_P420.yuv"; + filename << webrtc::test::OutputPath() << "Resampler_"<< mode << "_" << + targetWidth << "x" << targetHeight << "_30Hz_P420.yuv"; + // TODO(kjellander): Add automatic verification of these output files: std::cout << "Watch " << filename.str() << " and verify that it is okay." << std::endl; FILE* standAloneFile = fopen(filename.str().c_str(), "wb"); @@ -375,14 +365,4 @@ void TestSize(VideoFrame& sourceFrame, WebRtc_UWord32 targetWidth, fclose(standAloneFile); } -// TODO(kjellander): Get rid of this main and use test_support_main instead -// This can be done by inheriting TestSuite instead of testing::Test and -// override Initialize(). -int main(int argc, char** argv) -{ - ::testing::InitGoogleTest(&argc, argv); - VPMEnvironment* env = new VPMEnvironment; - ::testing::AddGlobalTestEnvironment(env); - - return RUN_ALL_TESTS(); -} +} // namespace webrtc diff --git a/src/modules/video_processing/main/test/unit_test/unit_test.h b/src/modules/video_processing/main/test/unit_test/unit_test.h index 855bf1b1d..2363e1a14 100644 --- a/src/modules/video_processing/main/test/unit_test/unit_test.h +++ b/src/modules/video_processing/main/test/unit_test/unit_test.h @@ -8,15 +8,15 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef VPM_UNIT_TEST_H -#define VPM_UNIT_TEST_H +#ifndef WEBRTC_MODULES_VIDEO_PROCESSING_MAIN_TEST_UNIT_TEST_VPM_UNIT_TEST_H +#define WEBRTC_MODULES_VIDEO_PROCESSING_MAIN_TEST_UNIT_TEST_VPM_UNIT_TEST_H -#include "video_processing.h" +#include "gtest/gtest.h" +#include "modules/video_processing/main/interface/video_processing.h" +#include "system_wrappers/interface/trace.h" +#include "testsupport/fileutils.h" - -#include - -using namespace webrtc; +namespace webrtc { class VideoProcessingModuleTest : public ::testing::Test { @@ -24,7 +24,16 @@ protected: VideoProcessingModuleTest(); virtual void SetUp(); virtual void TearDown(); - + static void SetUpTestCase() + { + Trace::CreateTrace(); + std::string trace_file = webrtc::test::OutputPath() + "VPMTrace.txt"; + ASSERT_EQ(0, Trace::SetTraceFile(trace_file.c_str())); + } + static void TearDownTestCase() + { + Trace::ReturnTrace(); + } VideoProcessingModule* _vpm; FILE* _sourceFile; VideoFrame _videoFrame; @@ -33,5 +42,6 @@ protected: const WebRtc_UWord32 _frameLength; }; +} // namespace webrtc -#endif // VPM_UNIT_TEST_H +#endif // WEBRTC_MODULES_VIDEO_PROCESSING_MAIN_TEST_UNIT_TEST_VPM_UNIT_TEST_H diff --git a/src/modules/video_processing/main/test/vpm_tests.gypi b/src/modules/video_processing/main/test/vpm_tests.gypi index 705c2c769..e53ac07bd 100644 --- a/src/modules/video_processing/main/test/vpm_tests.gypi +++ b/src/modules/video_processing/main/test/vpm_tests.gypi @@ -14,17 +14,12 @@ 'dependencies': [ 'video_processing', 'webrtc_utility', + '<(webrtc_root)/../test/test.gyp:test_support_main', '<(webrtc_root)/../testing/gtest.gyp:gtest', ], - 'include_dirs': [ - '../../../../system_wrappers/interface', - '<(webrtc_root)/common_video/libyuv/include', - '../../../../modules/video_processing/main/source', - ], 'sources': [ # headers 'unit_test/unit_test.h', - # sources 'unit_test/brightness_detection_test.cc', 'unit_test/color_enhancement_test.cc', @@ -32,7 +27,7 @@ 'unit_test/deflickering_test.cc', 'unit_test/denoising_test.cc', 'unit_test/unit_test.cc', - ], # source + ], # sources }, ], }