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

Side by Side Diff: media/gpu/video_decode_accelerator_unittest.cc

Issue 2753773002: Fix failed to write thumbnail png issue (Closed)
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 // 4 //
5 // The bulk of this file is support code; sorry about that. Here's an overview 5 // The bulk of this file is support code; sorry about that. Here's an overview
6 // to hopefully help readers of this code: 6 // to hopefully help readers of this code:
7 // - RenderingHelper is charged with interacting with X11/{EGL/GLES2,GLX/GL} or 7 // - RenderingHelper is charged with interacting with X11/{EGL/GLES2,GLX/GL} or
8 // Win/EGL. 8 // Win/EGL.
9 // - ClientState is an enum for the state of the decode client used by the test. 9 // - ClientState is an enum for the state of the decode client used by the test.
10 // - ClientStateNotification is a barrier abstraction that allows the test code 10 // - ClientStateNotification is a barrier abstraction that allows the test code
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 std::string data_str; 192 std::string data_str;
193 }; 193 };
194 194
195 const gfx::Size kThumbnailsPageSize(1600, 1200); 195 const gfx::Size kThumbnailsPageSize(1600, 1200);
196 const gfx::Size kThumbnailSize(160, 120); 196 const gfx::Size kThumbnailSize(160, 120);
197 const int kMD5StringLength = 32; 197 const int kMD5StringLength = 32;
198 198
199 base::FilePath GetTestDataFile(const base::FilePath& input_file) { 199 base::FilePath GetTestDataFile(const base::FilePath& input_file) {
200 if (input_file.IsAbsolute()) 200 if (input_file.IsAbsolute())
201 return input_file; 201 return input_file;
202 // input_file needs to be existed, otherwise base::MakeAbsoluteFilePath will
203 // return an empty base::FilePath.
Owen Lin 2017/03/15 08:41:43 Sounds like we should fail the test and LOG(FATAL)
johnylin1 2017/03/15 14:06:16 Done.
202 return base::MakeAbsoluteFilePath(g_test_file_path.Append(input_file)); 204 return base::MakeAbsoluteFilePath(g_test_file_path.Append(input_file));
203 } 205 }
204 206
205 // Read in golden MD5s for the thumbnailed rendering of this video 207 // Read in golden MD5s for the thumbnailed rendering of this video
206 void ReadGoldenThumbnailMD5s(const TestVideoFile* video_file, 208 void ReadGoldenThumbnailMD5s(const TestVideoFile* video_file,
207 std::vector<std::string>* md5_strings) { 209 std::vector<std::string>* md5_strings) {
208 base::FilePath filepath(video_file->file_name); 210 base::FilePath filepath(video_file->file_name);
209 filepath = filepath.AddExtension(FILE_PATH_LITERAL(".md5")); 211 filepath = filepath.AddExtension(FILE_PATH_LITERAL(".md5"));
210 std::string all_md5s; 212 std::string all_md5s;
211 base::ReadFileToString(GetTestDataFile(filepath), &all_md5s); 213 base::ReadFileToString(GetTestDataFile(filepath), &all_md5s);
(...skipping 1321 matching lines...) Expand 10 before | Expand all | Expand 10 after
1533 gfx::PNGCodec::FORMAT_RGB, 1535 gfx::PNGCodec::FORMAT_RGB,
1534 kThumbnailsPageSize, 1536 kThumbnailsPageSize,
1535 kThumbnailsPageSize.width() * 3, 1537 kThumbnailsPageSize.width() * 3,
1536 true, 1538 true,
1537 std::vector<gfx::PNGCodec::Comment>(), 1539 std::vector<gfx::PNGCodec::Comment>(),
1538 &png); 1540 &png);
1539 1541
1540 LOG(ERROR) << "Unknown thumbnails MD5: " << md5_string; 1542 LOG(ERROR) << "Unknown thumbnails MD5: " << md5_string;
1541 1543
1542 base::FilePath filepath(test_video_files_[0]->file_name); 1544 base::FilePath filepath(test_video_files_[0]->file_name);
1545 filepath = GetTestDataFile(filepath);
Owen Lin 2017/03/15 08:41:43 I would suggest to allow user to configure the out
johnylin1 2017/03/15 14:06:15 Done.
1543 filepath = filepath.AddExtension(FILE_PATH_LITERAL(".bad_thumbnails")); 1546 filepath = filepath.AddExtension(FILE_PATH_LITERAL(".bad_thumbnails"));
1544 filepath = filepath.AddExtension(FILE_PATH_LITERAL(".png")); 1547 filepath = filepath.AddExtension(FILE_PATH_LITERAL(".png"));
1545 int num_bytes = 1548 int num_bytes = base::WriteFile(
1546 base::WriteFile(GetTestDataFile(filepath), 1549 filepath, reinterpret_cast<char*>(&png[0]), png.size());
1547 reinterpret_cast<char*>(&png[0]), png.size());
1548 EXPECT_EQ(num_bytes, static_cast<int>(png.size())); 1550 EXPECT_EQ(num_bytes, static_cast<int>(png.size()));
1549 } 1551 }
1550 EXPECT_NE(match, golden_md5s.end()); 1552 EXPECT_NE(match, golden_md5s.end());
1551 EXPECT_EQ(alpha_solid, true) << "RGBA frame had incorrect alpha"; 1553 EXPECT_EQ(alpha_solid, true) << "RGBA frame had incorrect alpha";
1552 } 1554 }
1553 1555
1554 // Output the frame delivery time to file 1556 // Output the frame delivery time to file
1555 // We can only make performance/correctness assertions if the decoder was 1557 // We can only make performance/correctness assertions if the decoder was
1556 // allowed to finish. 1558 // allowed to finish.
1557 if (g_output_log != NULL && delete_decoder_state >= CS_FLUSHED) { 1559 if (g_output_log != NULL && delete_decoder_state >= CS_FLUSHED) {
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
1889 continue; 1891 continue;
1890 } 1892 }
1891 } 1893 }
1892 1894
1893 base::ShadowingAtExitManager at_exit_manager; 1895 base::ShadowingAtExitManager at_exit_manager;
1894 1896
1895 return base::LaunchUnitTestsSerially( 1897 return base::LaunchUnitTestsSerially(
1896 argc, argv, 1898 argc, argv,
1897 base::Bind(&media::VDATestSuite::Run, base::Unretained(&test_suite))); 1899 base::Bind(&media::VDATestSuite::Run, base::Unretained(&test_suite)));
1898 } 1900 }
OLDNEW
« 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