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

Unified Diff: gpu/ipc/service/direct_composition_surface_win_unittest.cc

Issue 2729073002: Fix DirectCompositionSurfaceTest.TestMakeCurrent flakiness. (Closed)
Patch Set: Created 3 years, 10 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 | « gpu/ipc/service/direct_composition_surface_win.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
}
« no previous file with comments | « gpu/ipc/service/direct_composition_surface_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698