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

Side by Side 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 stats_file << "frame_0001 0100\n"; 125 stats_file << "frame_0001 0100\n";
126 stats_file << "frame_0002 0101\n"; 126 stats_file << "frame_0002 0101\n";
127 stats_file << "frame_0003 0101\n"; 127 stats_file << "frame_0003 0101\n";
128 stats_file << "frame_0004 0106\n"; 128 stats_file << "frame_0004 0106\n";
129 stats_file.close(); 129 stats_file.close();
130 130
131 PrintMaxRepeatedAndSkippedFrames(logfile_, "NormalStatsFile", 131 PrintMaxRepeatedAndSkippedFrames(logfile_, "NormalStatsFile",
132 stats_filename_ref, stats_filename); 132 stats_filename_ref, stats_filename);
133 } 133 }
134 134
135 namespace {
136 void VerifyLogOutput(const std::string& log_filename,
137 const std::vector<std::string>& expected_out) {
138 std::ifstream logf(log_filename);
139 std::string line;
140
141 std::size_t i;
142 for (i = 0; i < expected_out.size() && getline(logf, line); ++i) {
143 ASSERT_EQ(expected_out.at(i), line);
144 }
145 ASSERT_TRUE(i == expected_out.size()) << "Not enough input data";
146 }
147 } // unnamed namespace
148
149 TEST_F(VideoQualityAnalysisTest,
150 PrintMaxRepeatedAndSkippedFramesSkippedFrames) {
151 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
152 std::string stats_filename = OutputPath() + "stats-2.txt";
153 std::ofstream stats_file;
154
155 std::string log_filename = webrtc::test::OutputPath() + "log.log";
156 FILE* logfile = fopen(log_filename.c_str(), "w");
157 ASSERT_TRUE(logfile_ != NULL);
158 stats_file.open(stats_filename_ref.c_str());
159 stats_file << "frame_0001 0100\n";
160 stats_file << "frame_0002 0101\n";
161 stats_file << "frame_0002 0101\n";
162 stats_file << "frame_0003 0103\n";
163 stats_file << "frame_0004 0103\n";
164 stats_file << "frame_0005 0106\n";
165 stats_file << "frame_0006 0106\n";
166 stats_file << "frame_0007 0108\n";
167 stats_file << "frame_0008 0110\n";
168 stats_file << "frame_0009 0112\n";
169 stats_file.close();
170
171 stats_file.open(stats_filename.c_str());
172 stats_file << "frame_0001 0101\n";
173 stats_file << "frame_0002 0101\n";
174 stats_file << "frame_0003 0101\n";
175 stats_file << "frame_0004 0108\n";
176 stats_file << "frame_0005 0108\n";
177 stats_file << "frame_0006 0112\n";
178 stats_file.close();
179
180 PrintMaxRepeatedAndSkippedFrames(logfile, "NormalStatsFile",
181 stats_filename_ref, stats_filename);
182 ASSERT_EQ(0, fclose(logfile));
183
184 std::vector<std::string> expected_out = {
185 "RESULT Max_repeated: NormalStatsFile= 2",
186 "RESULT Max_skipped: NormalStatsFile= 2",
187 "RESULT Total_skipped: NormalStatsFile= 3",
188 "RESULT Decode_errors_reference: NormalStatsFile= 0",
189 "RESULT Decode_errors_test: NormalStatsFile= 0",
190 "RESULT No_matched: []"};
191 VerifyLogOutput(log_filename, expected_out);
192 }
193
194 TEST_F(VideoQualityAnalysisTest,
195 PrintMaxRepeatedAndSkippedFramesDecodeErrorInRef) {
196 std::string stats_filename_ref = OutputPath() + "stats-1.txt";
197 std::string stats_filename = OutputPath() + "stats-2.txt";
198 std::ofstream stats_file;
199
200 std::string log_filename = webrtc::test::OutputPath() + "log.log";
201 FILE* logfile = fopen(log_filename.c_str(), "w");
202 ASSERT_TRUE(logfile_ != NULL);
203 stats_file.open(stats_filename_ref.c_str());
204 stats_file << "frame_0001 0101\n";
205 stats_file << "frame_0002 0103\n";
206 stats_file << "frame_0002 Barcode error\n";
207 stats_file << "frame_0003 Barcode error\n";
208 stats_file << "frame_0004 0106\n";
209 stats_file << "frame_0005 0106\n";
210 stats_file << "frame_0006 0107\n";
211 stats_file << "frame_0007 0107\n";
212 stats_file << "frame_0008 0110\n";
213 stats_file << "frame_0009 0112\n";
214 stats_file.close();
215
216 stats_file.open(stats_filename.c_str());
217 stats_file << "frame_0001 0101\n";
218 stats_file << "frame_0002 0103\n";
219 stats_file << "frame_0003 0104\n";
220 stats_file << "frame_0004 0105\n";
221 stats_file << "frame_0005 0106\n";
222 stats_file << "frame_0006 0107\n";
223 stats_file.close();
224
225 PrintMaxRepeatedAndSkippedFrames(logfile, "NormalStatsFile",
226 stats_filename_ref, stats_filename);
227 ASSERT_EQ(0, fclose(logfile));
228
229 std::vector<std::string> expected_out = {
230 "RESULT Max_repeated: NormalStatsFile= 1",
231 "RESULT Max_skipped: NormalStatsFile= 0",
232 "RESULT Total_skipped: NormalStatsFile= 0",
233 "RESULT Decode_errors_reference: NormalStatsFile= 2",
234 "RESULT Decode_errors_test: NormalStatsFile= 0",
235 "RESULT No_matched: [104, 105]"};
236 VerifyLogOutput(log_filename, expected_out);
237 }
238
239 TEST_F(VideoQualityAnalysisTest,
240 PrintMaxRepeatedAndSkippedFramesDecodeErrorInTest) {
241 std::string stats_filename_ref = OutputPath() + "stats-1.txt";
242 std::string stats_filename = OutputPath() + "stats-2.txt";
243 std::ofstream stats_file;
244
245 std::string log_filename = webrtc::test::OutputPath() + "log.log";
246 FILE* logfile = fopen(log_filename.c_str(), "w");
247 ASSERT_TRUE(logfile_ != NULL);
248 stats_file.open(stats_filename_ref.c_str());
249 stats_file << "frame_0001 0100\n";
250 stats_file << "frame_0002 0100\n";
251 stats_file << "frame_0002 0101\n";
252 stats_file << "frame_0003 0103\n";
253 stats_file << "frame_0004 0103\n";
254 stats_file << "frame_0005 0106\n";
255 stats_file << "frame_0006 0107\n";
256 stats_file << "frame_0007 0107\n";
257 stats_file << "frame_0008 0110\n";
258 stats_file << "frame_0009 0112\n";
259 stats_file.close();
260
261 stats_file.open(stats_filename.c_str());
262 stats_file << "frame_0001 0101\n";
263 stats_file << "frame_0002 Barcode error\n";
264 stats_file << "frame_0003 Barcode error\n";
265 stats_file << "frame_0004 Barcode error\n";
266 stats_file << "frame_0005 0107\n";
267 stats_file << "frame_0006 0110\n";
268 stats_file.close();
269
270 PrintMaxRepeatedAndSkippedFrames(logfile, "NormalStatsFile",
271 stats_filename_ref, stats_filename);
272 ASSERT_EQ(0, fclose(logfile));
273
274 std::vector<std::string> expected_out = {
275 "RESULT Max_repeated: NormalStatsFile= 1",
276 "RESULT Max_skipped: NormalStatsFile= 0",
277 "RESULT Total_skipped: NormalStatsFile= 0",
278 "RESULT Decode_errors_reference: NormalStatsFile= 0",
279 "RESULT Decode_errors_test: NormalStatsFile= 3",
280 "RESULT No_matched: []"};
281 VerifyLogOutput(log_filename, expected_out);
282 }
135 283
136 } // namespace test 284 } // namespace test
137 } // namespace webrtc 285 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698