| Index: gpu/ipc/service/direct_composition_surface_win_unittest.cc
|
| diff --git a/gpu/ipc/service/direct_composition_surface_win_unittest.cc b/gpu/ipc/service/direct_composition_surface_win_unittest.cc
|
| index 3e43906403c95328b481d64e1bb9fc141c23bb1b..19a1d2c52bcc3044e4f9446fe009104dbc9ba77b 100644
|
| --- a/gpu/ipc/service/direct_composition_surface_win_unittest.cc
|
| +++ b/gpu/ipc/service/direct_composition_surface_win_unittest.cc
|
| @@ -5,6 +5,7 @@
|
| #include "gpu/ipc/service/direct_composition_surface_win.h"
|
| #include "base/memory/weak_ptr.h"
|
| #include "base/run_loop.h"
|
| +#include "base/synchronization/waitable_event.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
| #include "ui/base/win/hidden_window.h"
|
| #include "ui/gl/gl_angle_util_win.h"
|
| @@ -33,6 +34,14 @@ class TestImageTransportSurfaceDelegate
|
| int32_t GetRouteID() const override { return 0; }
|
| };
|
|
|
| +void RunPendingTasks(scoped_refptr<base::TaskRunner> task_runner) {
|
| + base::WaitableEvent done(base::WaitableEvent::ResetPolicy::AUTOMATIC,
|
| + base::WaitableEvent::InitialState::NOT_SIGNALED);
|
| + task_runner->PostTask(FROM_HERE,
|
| + Bind(&base::WaitableEvent::Signal, Unretained(&done)));
|
| + done.Wait();
|
| +}
|
| +
|
| TEST(DirectCompositionSurfaceTest, TestMakeCurrent) {
|
| if (!gl::QueryDirectCompositionDevice(
|
| gl::QueryD3D11DeviceObjectFromANGLE())) {
|
| @@ -90,11 +99,22 @@ TEST(DirectCompositionSurfaceTest, TestMakeCurrent) {
|
| // It should be possible to switch back to the previous surface and
|
| // unsuspend it.
|
| EXPECT_TRUE(context->MakeCurrent(surface.get()));
|
| + scoped_refptr<base::TaskRunner> task_runner1 =
|
| + surface->GetWindowTaskRunnerForTesting();
|
| + scoped_refptr<base::TaskRunner> task_runner2 =
|
| + surface2->GetWindowTaskRunnerForTesting();
|
|
|
| context2 = nullptr;
|
| surface2 = nullptr;
|
| context = nullptr;
|
| surface = nullptr;
|
| +
|
| + // Ensure that the ChildWindowWin posts the task to delete the thread to the
|
| + // main loop before doing RunUntilIdle. Otherwise the child threads could
|
| + // outlive the main thread.
|
| + RunPendingTasks(task_runner1);
|
| + RunPendingTasks(task_runner2);
|
| +
|
| base::RunLoop().RunUntilIdle();
|
| }
|
|
|
|
|