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

Unified Diff: media/gpu/video_decode_accelerator_unittest.cc

Issue 2753773002: Fix failed to write thumbnail png issue (Closed)
Patch Set: Fix failed to write thumbnail png issue Created 3 years, 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/gpu/video_decode_accelerator_unittest.cc
diff --git a/media/gpu/video_decode_accelerator_unittest.cc b/media/gpu/video_decode_accelerator_unittest.cc
index 16f528e93d469753863e73d1c45a9279546442a5..a896d828c8fed8ed5e9f7bf7d96d9071c70607c9 100644
--- a/media/gpu/video_decode_accelerator_unittest.cc
+++ b/media/gpu/video_decode_accelerator_unittest.cc
@@ -143,6 +143,10 @@ bool g_test_import = false;
// working directory.
base::FilePath g_test_file_path;
+// The location to output bad thumbnail image. If empty or invalid, fallback to
+// the original location.
+base::FilePath g_test_output_dir;
Owen Lin 2017/03/16 09:26:58 nit: How about naming it g_thumbnail_output_dir?
johnylin1 2017/03/17 03:01:07 Done.
+
// Environment to store rendering thread.
class VideoDecodeAcceleratorTestEnvironment;
VideoDecodeAcceleratorTestEnvironment* g_env;
@@ -199,7 +203,14 @@ const int kMD5StringLength = 32;
base::FilePath GetTestDataFile(const base::FilePath& input_file) {
if (input_file.IsAbsolute())
return input_file;
- return base::MakeAbsoluteFilePath(g_test_file_path.Append(input_file));
+ // input_file needs to be existed, otherwise base::MakeAbsoluteFilePath will
+ // return an empty base::FilePath.
+ base::FilePath abs_path =
+ base::MakeAbsoluteFilePath(g_test_file_path.Append(input_file));
+ LOG_IF(FATAL, abs_path.empty())
+ << g_test_file_path.Append(input_file).value().c_str()
+ << " is not an existing path.";
+ return abs_path;
}
// Read in golden MD5s for the thumbnailed rendering of this video
@@ -1540,11 +1551,19 @@ TEST_P(VideoDecodeAcceleratorParamTest, TestSimpleDecode) {
LOG(ERROR) << "Unknown thumbnails MD5: " << md5_string;
base::FilePath filepath(test_video_files_[0]->file_name);
+ if (!g_test_output_dir.empty() &&
+ base::DirectoryExists(g_test_output_dir))
+ // Write bad thumbnails image to where --thumbnail_output_dir assigned.
+ filepath = g_test_output_dir.Append(filepath);
+ else
+ // Fallback to write to test data directory.
+ filepath = GetTestDataFile(filepath);
filepath = filepath.AddExtension(FILE_PATH_LITERAL(".bad_thumbnails"));
filepath = filepath.AddExtension(FILE_PATH_LITERAL(".png"));
- int num_bytes =
- base::WriteFile(GetTestDataFile(filepath),
- reinterpret_cast<char*>(&png[0]), png.size());
+ LOG(INFO) << "Write bad thumbnails image to: "
+ << filepath.value().c_str();
+ int num_bytes = base::WriteFile(
+ filepath, reinterpret_cast<char*>(&png[0]), png.size());
EXPECT_EQ(num_bytes, static_cast<int>(png.size()));
}
EXPECT_NE(match, golden_md5s.end());
@@ -1888,6 +1907,9 @@ int main(int argc, char** argv) {
media::g_test_file_path = media::GetTestDataFilePath("");
continue;
}
+ if (it->first == "thumbnail_output_dir") {
+ media::g_test_output_dir = base::FilePath(it->second.c_str());
+ }
}
base::ShadowingAtExitManager at_exit_manager;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698