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

Unified Diff: media/gpu/jpeg_decode_accelerator_unittest.cc

Issue 2922323003: JDA unittest: don't require the test file in /media/test/data/. (Closed)
Patch Set: JDA unittest: don't require the test file in /media/test/data/. Created 3 years, 6 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/jpeg_decode_accelerator_unittest.cc
diff --git a/media/gpu/jpeg_decode_accelerator_unittest.cc b/media/gpu/jpeg_decode_accelerator_unittest.cc
index 93c9934ecb079c58be5ded329c84c3032bc767d1..8ef7f45842a273c44125faebd43a7e769bca07bf 100644
--- a/media/gpu/jpeg_decode_accelerator_unittest.cc
+++ b/media/gpu/jpeg_decode_accelerator_unittest.cc
@@ -313,6 +313,10 @@ class JpegDecodeAcceleratorTestEnvironment : public ::testing::Environment {
// Read image from |filename| to |image_data|.
void ReadTestJpegImage(base::FilePath& filename, TestImageFile* image_data);
+ // Returns a file path for a file in what name specified or media/test/data
+ // directory. If the original file path is existed, returns it first.
+ base::FilePath GetOriginalOrTestDataFilePath(const std::string& name);
+
// Parsed data of |test_1280x720_jpeg_file_|.
std::unique_ptr<TestImageFile> image_data_1280x720_black_;
// Parsed data of |test_640x368_jpeg_file_|.
@@ -359,7 +363,8 @@ void JpegDecodeAcceleratorTestEnvironment::SetUp() {
ASSERT_NO_FATAL_FAILURE(ReadTestJpegImage(test_640x360_jpeg_file_,
image_data_640x360_black_.get()));
- base::FilePath default_jpeg_file = GetTestDataFilePath(kDefaultJpegFilename);
+ base::FilePath default_jpeg_file =
+ GetOriginalOrTestDataFilePath(kDefaultJpegFilename);
image_data_1280x720_default_.reset(new TestImageFile(kDefaultJpegFilename));
ASSERT_NO_FATAL_FAILURE(
ReadTestJpegImage(default_jpeg_file, image_data_1280x720_default_.get()));
@@ -375,7 +380,7 @@ void JpegDecodeAcceleratorTestEnvironment::SetUp() {
user_jpeg_filenames_, base::FilePath::StringType(1, ';'),
base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
for (const auto& filename : filenames) {
- base::FilePath input_file = GetTestDataFilePath(filename);
+ base::FilePath input_file = GetOriginalOrTestDataFilePath(filename);
auto image_data = base::MakeUnique<TestImageFile>(filename);
ASSERT_NO_FATAL_FAILURE(ReadTestJpegImage(input_file, image_data.get()));
image_data_user_.push_back(std::move(image_data));
@@ -423,6 +428,19 @@ void JpegDecodeAcceleratorTestEnvironment::ReadTestJpegImage(
VideoFrame::AllocationSize(PIXEL_FORMAT_I420, image_data->visible_size);
}
+base::FilePath
+JpegDecodeAcceleratorTestEnvironment::GetOriginalOrTestDataFilePath(
+ const std::string& name) {
+ base::FilePath original_file_path = base::FilePath(name);
+ base::FilePath return_file_path = GetTestDataFilePath(name);
+
+ if (PathExists(original_file_path))
+ return_file_path = original_file_path;
+
+ VLOG(3) << "Use file path " << return_file_path.value();
+ return return_file_path;
+}
+
class JpegDecodeAcceleratorTest : public ::testing::Test {
protected:
JpegDecodeAcceleratorTest() {}
« 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