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

Unified Diff: webrtc/tools/frame_analyzer/video_quality_analysis_unittest.cc

Issue 2666333003: Better comparison for frame analyzer (Closed)
Patch Set: Better handling of decoding errors Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/tools/frame_analyzer/video_quality_analysis_unittest.cc
diff --git a/webrtc/tools/frame_analyzer/video_quality_analysis_unittest.cc b/webrtc/tools/frame_analyzer/video_quality_analysis_unittest.cc
index 85d0b46e79f72879db7fa0f7053888d7fe19fc2a..10675f32d82bb8a87f0abd218d325af7c2f93267 100644
--- a/webrtc/tools/frame_analyzer/video_quality_analysis_unittest.cc
+++ b/webrtc/tools/frame_analyzer/video_quality_analysis_unittest.cc
@@ -132,6 +132,154 @@ TEST_F(VideoQualityAnalysisTest, PrintMaxRepeatedAndSkippedFramesNormalFile) {
stats_filename_ref, stats_filename);
}
+namespace {
+void VerifyLogOutput(const std::string& log_filename,
+ const std::vector<std::string>& expected_out) {
+ std::ifstream logf(log_filename);
+ std::string line;
+
+ std::size_t i;
+ for (i = 0; i < expected_out.size() && getline(logf, line); ++i) {
+ ASSERT_EQ(expected_out.at(i), line);
+ }
+ ASSERT_TRUE(i == expected_out.size()) << "Not enough input data";
+}
+} // unnamed namespace
+
+TEST_F(VideoQualityAnalysisTest,
+ PrintMaxRepeatedAndSkippedFramesSkippedFrames) {
+ std::string stats_filename_ref = OutputPath() + "stats-1.txt";
kjellander_webrtc 2017/02/08 10:00:29 Please utilize a temporary directory or unique fil
mandermo 2017/02/13 17:04:11 Done.
mandermo 2017/02/15 11:52:15 I am using the unittest library to get unique file
+ std::string stats_filename = OutputPath() + "stats-2.txt";
+ std::ofstream stats_file;
+
+ std::string log_filename = webrtc::test::OutputPath() + "log.log";
+ FILE* logfile = fopen(log_filename.c_str(), "w");
+ ASSERT_TRUE(logfile_ != NULL);
+ stats_file.open(stats_filename_ref.c_str());
+ stats_file << "frame_0001 0100\n";
+ stats_file << "frame_0002 0101\n";
+ stats_file << "frame_0002 0101\n";
+ stats_file << "frame_0003 0103\n";
+ stats_file << "frame_0004 0103\n";
+ stats_file << "frame_0005 0106\n";
+ stats_file << "frame_0006 0106\n";
+ stats_file << "frame_0007 0108\n";
+ stats_file << "frame_0008 0110\n";
+ stats_file << "frame_0009 0112\n";
+ stats_file.close();
+
+ stats_file.open(stats_filename.c_str());
+ stats_file << "frame_0001 0101\n";
+ stats_file << "frame_0002 0101\n";
+ stats_file << "frame_0003 0101\n";
+ stats_file << "frame_0004 0108\n";
+ stats_file << "frame_0005 0108\n";
+ stats_file << "frame_0006 0112\n";
+ stats_file.close();
+
+ PrintMaxRepeatedAndSkippedFrames(logfile, "NormalStatsFile",
+ stats_filename_ref, stats_filename);
+ ASSERT_EQ(0, fclose(logfile));
+
+ std::vector<std::string> expected_out = {
+ "RESULT Max_repeated: NormalStatsFile= 2",
+ "RESULT Max_skipped: NormalStatsFile= 2",
+ "RESULT Total_skipped: NormalStatsFile= 3",
+ "RESULT Decode_errors_reference: NormalStatsFile= 0",
+ "RESULT Decode_errors_test: NormalStatsFile= 0",
+ "RESULT No_matched: []"};
+ VerifyLogOutput(log_filename, expected_out);
+}
+
+TEST_F(VideoQualityAnalysisTest,
+ PrintMaxRepeatedAndSkippedFramesDecodeErrorInRef) {
+ std::string stats_filename_ref = OutputPath() + "stats-1.txt";
+ std::string stats_filename = OutputPath() + "stats-2.txt";
+ std::ofstream stats_file;
+
+ std::string log_filename = webrtc::test::OutputPath() + "log.log";
+ FILE* logfile = fopen(log_filename.c_str(), "w");
+ ASSERT_TRUE(logfile_ != NULL);
+ stats_file.open(stats_filename_ref.c_str());
+ stats_file << "frame_0001 0101\n";
+ stats_file << "frame_0002 0103\n";
+ stats_file << "frame_0002 Barcode error\n";
+ stats_file << "frame_0003 Barcode error\n";
+ stats_file << "frame_0004 0106\n";
+ stats_file << "frame_0005 0106\n";
+ stats_file << "frame_0006 0107\n";
+ stats_file << "frame_0007 0107\n";
+ stats_file << "frame_0008 0110\n";
+ stats_file << "frame_0009 0112\n";
+ stats_file.close();
+
+ stats_file.open(stats_filename.c_str());
+ stats_file << "frame_0001 0101\n";
+ stats_file << "frame_0002 0103\n";
+ stats_file << "frame_0003 0104\n";
+ stats_file << "frame_0004 0105\n";
+ stats_file << "frame_0005 0106\n";
+ stats_file << "frame_0006 0107\n";
+ stats_file.close();
+
+ PrintMaxRepeatedAndSkippedFrames(logfile, "NormalStatsFile",
+ stats_filename_ref, stats_filename);
+ ASSERT_EQ(0, fclose(logfile));
+
+ std::vector<std::string> expected_out = {
+ "RESULT Max_repeated: NormalStatsFile= 1",
+ "RESULT Max_skipped: NormalStatsFile= 0",
+ "RESULT Total_skipped: NormalStatsFile= 0",
+ "RESULT Decode_errors_reference: NormalStatsFile= 2",
+ "RESULT Decode_errors_test: NormalStatsFile= 0",
+ "RESULT No_matched: [104, 105]"};
+ VerifyLogOutput(log_filename, expected_out);
+}
+
+TEST_F(VideoQualityAnalysisTest,
+ PrintMaxRepeatedAndSkippedFramesDecodeErrorInTest) {
+ std::string stats_filename_ref = OutputPath() + "stats-1.txt";
+ std::string stats_filename = OutputPath() + "stats-2.txt";
+ std::ofstream stats_file;
+
+ std::string log_filename = webrtc::test::OutputPath() + "log.log";
+ FILE* logfile = fopen(log_filename.c_str(), "w");
+ ASSERT_TRUE(logfile_ != NULL);
+ stats_file.open(stats_filename_ref.c_str());
+ stats_file << "frame_0001 0100\n";
+ stats_file << "frame_0002 0100\n";
+ stats_file << "frame_0002 0101\n";
+ stats_file << "frame_0003 0103\n";
+ stats_file << "frame_0004 0103\n";
+ stats_file << "frame_0005 0106\n";
+ stats_file << "frame_0006 0107\n";
+ stats_file << "frame_0007 0107\n";
+ stats_file << "frame_0008 0110\n";
+ stats_file << "frame_0009 0112\n";
+ stats_file.close();
+
+ stats_file.open(stats_filename.c_str());
+ stats_file << "frame_0001 0101\n";
+ stats_file << "frame_0002 Barcode error\n";
+ stats_file << "frame_0003 Barcode error\n";
+ stats_file << "frame_0004 Barcode error\n";
+ stats_file << "frame_0005 0107\n";
+ stats_file << "frame_0006 0110\n";
+ stats_file.close();
+
+ PrintMaxRepeatedAndSkippedFrames(logfile, "NormalStatsFile",
+ stats_filename_ref, stats_filename);
+ ASSERT_EQ(0, fclose(logfile));
+
+ std::vector<std::string> expected_out = {
+ "RESULT Max_repeated: NormalStatsFile= 1",
+ "RESULT Max_skipped: NormalStatsFile= 0",
+ "RESULT Total_skipped: NormalStatsFile= 0",
+ "RESULT Decode_errors_reference: NormalStatsFile= 0",
+ "RESULT Decode_errors_test: NormalStatsFile= 3",
+ "RESULT No_matched: []"};
+ VerifyLogOutput(log_filename, expected_out);
+}
} // namespace test
} // namespace webrtc

Powered by Google App Engine
This is Rietveld 408576698