Skip to content

Commit

Permalink
Move video decode accelerator test environment init to Initialize().
Browse files Browse the repository at this point in the history
This allows ScopedTaskEnvironment to take advantage of state initialized
by base::TestSuite::Initialize, such as the TestTimeouts, as required by
https://chromium-review.googlesource.com/c/chromium/src/+/1319344

Bug: 918724
Change-Id: Ic7e811f95581e7d07a26acd3e29e27442a9828b5
Reviewed-on: https://chromium-review.googlesource.com/c/1400346
Reviewed-by: David Staessens <dstaessens@chromium.org>
Reviewed-by: Dan Sanders <sandersd@chromium.org>
Commit-Queue: Wez <wez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#620892}
  • Loading branch information
Wez authored and Commit Bot committed Jan 8, 2019
1 parent 66bc943 commit 83a4b80
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions media/gpu/video_decode_accelerator_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1700,16 +1700,21 @@ class VDATestSuite : public base::TestSuite {
public:
VDATestSuite(int argc, char** argv) : base::TestSuite(argc, argv) {}

int Run() {
private:
void Initialize() override {
base::TestSuite::Initialize();

#if defined(OS_WIN) || defined(OS_CHROMEOS)
// For windows the decoding thread initializes the media foundation decoder
// which uses COM. We need the thread to be a UI thread.
// On Ozone, the backend initializes the event system using a UI
// thread.
base::test::ScopedTaskEnvironment scoped_task_environment(
base::test::ScopedTaskEnvironment::MainThreadType::UI);
scoped_task_environment_ =
std::make_unique<base::test::ScopedTaskEnvironment>(
base::test::ScopedTaskEnvironment::MainThreadType::UI);
#else
base::test::ScopedTaskEnvironment scoped_task_environment;
scoped_task_environment_ =
std::make_unique<base::test::ScopedTaskEnvironment>();
#endif // OS_WIN || OS_CHROMEOS

media::g_env =
Expand All @@ -1729,8 +1734,14 @@ class VDATestSuite : public base::TestSuite {
#elif defined(OS_WIN)
media::DXVAVideoDecodeAccelerator::PreSandboxInitialization();
#endif
return base::TestSuite::Run();
}

void Shutdown() override {
scoped_task_environment_.reset();
base::TestSuite::Shutdown();
}

std::unique_ptr<base::test::ScopedTaskEnvironment> scoped_task_environment_;
};

} // namespace
Expand Down

0 comments on commit 83a4b80

Please sign in to comment.