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

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

Issue 2521793002: Allow video_decode_accelerator_unittest to be run in an isolate. (Closed)
Patch Set: disable thumbnail test completely Created 4 years 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 | « media/gpu/BUILD.gn ('k') | 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 #include "base/single_thread_task_runner.h" 42 #include "base/single_thread_task_runner.h"
43 #include "base/stl_util.h" 43 #include "base/stl_util.h"
44 #include "base/strings/string_number_conversions.h" 44 #include "base/strings/string_number_conversions.h"
45 #include "base/strings/string_split.h" 45 #include "base/strings/string_split.h"
46 #include "base/strings/stringize_macros.h" 46 #include "base/strings/stringize_macros.h"
47 #include "base/strings/stringprintf.h" 47 #include "base/strings/stringprintf.h"
48 #include "base/strings/utf_string_conversions.h" 48 #include "base/strings/utf_string_conversions.h"
49 #include "base/synchronization/condition_variable.h" 49 #include "base/synchronization/condition_variable.h"
50 #include "base/synchronization/lock.h" 50 #include "base/synchronization/lock.h"
51 #include "base/synchronization/waitable_event.h" 51 #include "base/synchronization/waitable_event.h"
52 #include "base/test/launcher/unit_test_launcher.h"
53 #include "base/test/test_suite.h"
52 #include "base/threading/thread.h" 54 #include "base/threading/thread.h"
53 #include "base/threading/thread_task_runner_handle.h" 55 #include "base/threading/thread_task_runner_handle.h"
54 #include "build/build_config.h" 56 #include "build/build_config.h"
55 #include "gpu/command_buffer/service/gpu_preferences.h" 57 #include "gpu/command_buffer/service/gpu_preferences.h"
56 #include "gpu/config/gpu_driver_bug_workarounds.h" 58 #include "gpu/config/gpu_driver_bug_workarounds.h"
57 #include "media/filters/h264_parser.h" 59 #include "media/filters/h264_parser.h"
58 #include "media/gpu/fake_video_decode_accelerator.h" 60 #include "media/gpu/fake_video_decode_accelerator.h"
59 #include "media/gpu/gpu_video_decode_accelerator_factory.h" 61 #include "media/gpu/gpu_video_decode_accelerator_factory.h"
60 #include "media/gpu/rendering_helper.h" 62 #include "media/gpu/rendering_helper.h"
61 #include "media/gpu/video_accelerator_unittest_helpers.h" 63 #include "media/gpu/video_accelerator_unittest_helpers.h"
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 const gfx::Size kThumbnailsPageSize(1600, 1200); 187 const gfx::Size kThumbnailsPageSize(1600, 1200);
186 const gfx::Size kThumbnailSize(160, 120); 188 const gfx::Size kThumbnailSize(160, 120);
187 const int kMD5StringLength = 32; 189 const int kMD5StringLength = 32;
188 190
189 // Read in golden MD5s for the thumbnailed rendering of this video 191 // Read in golden MD5s for the thumbnailed rendering of this video
190 void ReadGoldenThumbnailMD5s(const TestVideoFile* video_file, 192 void ReadGoldenThumbnailMD5s(const TestVideoFile* video_file,
191 std::vector<std::string>* md5_strings) { 193 std::vector<std::string>* md5_strings) {
192 base::FilePath filepath(video_file->file_name); 194 base::FilePath filepath(video_file->file_name);
193 filepath = filepath.AddExtension(FILE_PATH_LITERAL(".md5")); 195 filepath = filepath.AddExtension(FILE_PATH_LITERAL(".md5"));
194 std::string all_md5s; 196 std::string all_md5s;
195 base::ReadFileToString(filepath, &all_md5s); 197 base::ReadFileToString(base::MakeAbsoluteFilePath(filepath), &all_md5s);
196 *md5_strings = base::SplitString(all_md5s, "\n", base::TRIM_WHITESPACE, 198 *md5_strings = base::SplitString(all_md5s, "\n", base::TRIM_WHITESPACE,
197 base::SPLIT_WANT_ALL); 199 base::SPLIT_WANT_ALL);
198 // Check these are legitimate MD5s. 200 // Check these are legitimate MD5s.
199 for (const std::string& md5_string : *md5_strings) { 201 for (const std::string& md5_string : *md5_strings) {
200 // Ignore the empty string added by SplitString 202 // Ignore the empty string added by SplitString
201 if (!md5_string.length()) 203 if (!md5_string.length())
202 continue; 204 continue;
203 // Ignore comments 205 // Ignore comments
204 if (md5_string.at(0) == '#') 206 if (md5_string.at(0) == '#')
205 continue; 207 continue;
(...skipping 972 matching lines...) Expand 10 before | Expand all | Expand 10 after
1178 LOG_ASSERT(base::StringToInt(fields[5], &video_file->min_fps_render)); 1180 LOG_ASSERT(base::StringToInt(fields[5], &video_file->min_fps_render));
1179 if (!fields[6].empty()) 1181 if (!fields[6].empty())
1180 LOG_ASSERT(base::StringToInt(fields[6], &video_file->min_fps_no_render)); 1182 LOG_ASSERT(base::StringToInt(fields[6], &video_file->min_fps_no_render));
1181 int profile = -1; 1183 int profile = -1;
1182 if (!fields[7].empty()) 1184 if (!fields[7].empty())
1183 LOG_ASSERT(base::StringToInt(fields[7], &profile)); 1185 LOG_ASSERT(base::StringToInt(fields[7], &profile));
1184 video_file->profile = static_cast<VideoCodecProfile>(profile); 1186 video_file->profile = static_cast<VideoCodecProfile>(profile);
1185 1187
1186 // Read in the video data. 1188 // Read in the video data.
1187 base::FilePath filepath(video_file->file_name); 1189 base::FilePath filepath(video_file->file_name);
1188 LOG_ASSERT(base::ReadFileToString(filepath, &video_file->data_str)) 1190 LOG_ASSERT(base::ReadFileToString(base::MakeAbsoluteFilePath(filepath),
1191 &video_file->data_str))
1189 << "test_video_file: " << filepath.MaybeAsASCII(); 1192 << "test_video_file: " << filepath.MaybeAsASCII();
1190 1193
1191 test_video_files->push_back(std::move(video_file)); 1194 test_video_files->push_back(std::move(video_file));
1192 } 1195 }
1193 } 1196 }
1194 1197
1195 void VideoDecodeAcceleratorTest::UpdateTestVideoFileParams( 1198 void VideoDecodeAcceleratorTest::UpdateTestVideoFileParams(
1196 size_t num_concurrent_decoders, 1199 size_t num_concurrent_decoders,
1197 int reset_point, 1200 int reset_point,
1198 TestFilesVector* test_video_files) { 1201 TestFilesVector* test_video_files) {
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
1648 false, 1651 false,
1649 false), 1652 false),
1650 std::make_tuple(kMinSupportedNumConcurrentDecoders + 1, 1653 std::make_tuple(kMinSupportedNumConcurrentDecoders + 1,
1651 1, 1654 1,
1652 1, 1655 1,
1653 END_OF_STREAM_RESET, 1656 END_OF_STREAM_RESET,
1654 CS_RESET, 1657 CS_RESET,
1655 false, 1658 false,
1656 false))); 1659 false)));
1657 1660
1661 // Allow MAYBE macro substitution.
1662 #define WRAPPED_INSTANTIATE_TEST_CASE_P(a, b, c) \
1663 INSTANTIATE_TEST_CASE_P(a, b, c)
1664
1665 #if defined(OS_WIN)
1666 // There are no reference images for windows.
1667 #define MAYBE_Thumbnail DISABLED_Thumbnail
1668 #else
1669 #define MAYBE_Thumbnail Thumbnail
1670 #endif
1658 // Thumbnailing test 1671 // Thumbnailing test
1659 INSTANTIATE_TEST_CASE_P( 1672 WRAPPED_INSTANTIATE_TEST_CASE_P(
1660 Thumbnail, 1673 MAYBE_Thumbnail,
1661 VideoDecodeAcceleratorParamTest, 1674 VideoDecodeAcceleratorParamTest,
1662 ::testing::Values( 1675 ::testing::Values(
1663 std::make_tuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESET, false, true))); 1676 std::make_tuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESET, false, true)));
1664 1677
1665 // Measure the median of the decode time when VDA::Decode is called 30 times per 1678 // Measure the median of the decode time when VDA::Decode is called 30 times per
1666 // second. 1679 // second.
1667 TEST_F(VideoDecodeAcceleratorTest, TestDecodeTimeMedian) { 1680 TEST_F(VideoDecodeAcceleratorTest, TestDecodeTimeMedian) {
1668 RenderingHelperParams helper_params; 1681 RenderingHelperParams helper_params;
1669 1682
1670 // Disable rendering by setting the rendering_fps = 0. 1683 // Disable rendering by setting the rendering_fps = 0.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1710 g_env->GetRenderingTaskRunner()->DeleteSoon(FROM_HERE, note); 1723 g_env->GetRenderingTaskRunner()->DeleteSoon(FROM_HERE, note);
1711 WaitUntilIdle(); 1724 WaitUntilIdle();
1712 }; 1725 };
1713 1726
1714 // TODO(fischman, vrk): add more tests! In particular: 1727 // TODO(fischman, vrk): add more tests! In particular:
1715 // - Test life-cycle: Seek/Stop/Pause/Play for a single decoder. 1728 // - Test life-cycle: Seek/Stop/Pause/Play for a single decoder.
1716 // - Test alternate configurations 1729 // - Test alternate configurations
1717 // - Test failure conditions. 1730 // - Test failure conditions.
1718 // - Test frame size changes mid-stream 1731 // - Test frame size changes mid-stream
1719 1732
1733 class VDATestSuite : public base::TestSuite {
1734 public:
1735 VDATestSuite(int argc, char** argv) : base::TestSuite(argc, argv) {}
1736
1737 int Run() {
1738 #if defined(OS_WIN) || defined(USE_OZONE)
1739 // For windows the decoding thread initializes the media foundation decoder
1740 // which uses COM. We need the thread to be a UI thread.
1741 // On Ozone, the backend initializes the event system using a UI
1742 // thread.
1743 base::MessageLoopForUI main_loop;
1744 #else
1745 base::MessageLoop main_loop;
1746 #endif // OS_WIN || USE_OZONE
1747
1748 #if defined(USE_OZONE)
1749 ui::OzonePlatform::InitializeForUI();
1750 #endif
1751
1752 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)
1753 media::VaapiWrapper::PreSandboxInitialization();
1754 #elif defined(OS_WIN)
1755 media::DXVAVideoDecodeAccelerator::PreSandboxInitialization();
1756 #endif
1757 return base::TestSuite::Run();
1758 }
1759 };
1760
1720 } // namespace 1761 } // namespace
1721 } // namespace media 1762 } // namespace media
1722 1763
1723 int main(int argc, char** argv) { 1764 int main(int argc, char** argv) {
1724 testing::InitGoogleTest(&argc, argv); // Removes gtest-specific args. 1765 media::VDATestSuite test_suite(argc, argv);
1725 #if defined(OS_WIN)
1726 base::CommandLine::InitUsingArgvForTesting(argc, argv);
1727 #else
1728 base::CommandLine::Init(argc, argv);
1729 #endif
1730 1766
1731 // Needed to enable DVLOG through --vmodule. 1767 // Needed to enable DVLOG through --vmodule.
1732 logging::LoggingSettings settings; 1768 logging::LoggingSettings settings;
1733 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; 1769 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
1734 LOG_ASSERT(logging::InitLogging(settings)); 1770 LOG_ASSERT(logging::InitLogging(settings));
1735 1771
1736 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); 1772 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess();
1737 DCHECK(cmd_line); 1773 DCHECK(cmd_line);
1738 1774
1739 base::CommandLine::SwitchMap switches = cmd_line->GetSwitches(); 1775 base::CommandLine::SwitchMap switches = cmd_line->GetSwitches();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1776 continue; 1812 continue;
1777 } 1813 }
1778 if (it->first == "v" || it->first == "vmodule") 1814 if (it->first == "v" || it->first == "vmodule")
1779 continue; 1815 continue;
1780 if (it->first == "ozone-platform" || it->first == "ozone-use-surfaceless") 1816 if (it->first == "ozone-platform" || it->first == "ozone-use-surfaceless")
1781 continue; 1817 continue;
1782 if (it->first == "test_import") { 1818 if (it->first == "test_import") {
1783 media::g_test_import = true; 1819 media::g_test_import = true;
1784 continue; 1820 continue;
1785 } 1821 }
1786 LOG(FATAL) << "Unexpected switch: " << it->first << ":" << it->second;
1787 } 1822 }
1788 1823
1789 base::ShadowingAtExitManager at_exit_manager; 1824 base::ShadowingAtExitManager at_exit_manager;
1790 #if defined(OS_WIN) || defined(USE_OZONE)
1791 // For windows the decoding thread initializes the media foundation decoder
1792 // which uses COM. We need the thread to be a UI thread.
1793 // On Ozone, the backend initializes the event system using a UI
1794 // thread.
1795 base::MessageLoopForUI main_loop;
1796 #else
1797 base::MessageLoop main_loop;
1798 #endif // OS_WIN || USE_OZONE
1799
1800 #if defined(USE_OZONE)
1801 ui::OzonePlatform::InitializeForUI();
1802 #endif
1803
1804 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)
1805 media::VaapiWrapper::PreSandboxInitialization();
1806 #elif defined(OS_WIN)
1807 media::DXVAVideoDecodeAccelerator::PreSandboxInitialization();
1808 #endif
1809 1825
1810 media::g_env = 1826 media::g_env =
1811 reinterpret_cast<media::VideoDecodeAcceleratorTestEnvironment*>( 1827 reinterpret_cast<media::VideoDecodeAcceleratorTestEnvironment*>(
1812 testing::AddGlobalTestEnvironment( 1828 testing::AddGlobalTestEnvironment(
1813 new media::VideoDecodeAcceleratorTestEnvironment())); 1829 new media::VideoDecodeAcceleratorTestEnvironment()));
1814 1830
1815 return RUN_ALL_TESTS(); 1831 return base::LaunchUnitTestsSerially(
1832 argc, argv,
1833 base::Bind(&media::VDATestSuite::Run, base::Unretained(&test_suite)));
1816 } 1834 }
OLDNEW
« no previous file with comments | « media/gpu/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698