Commit 4c6003d8 authored by Sadrul Habib Chowdhury's avatar Sadrul Habib Chowdhury Committed by Commit Bot

exo: Add a test for crrev.com/c/1379273

Add a test to make sure that already removed presentation callbacks for
submitted compositor frames do not cause crashes.

BUG=915458

Change-Id: Ia0ae709a6a6792564a01d3086369f32850cf14fb
Reviewed-on: https://chromium-review.googlesource.com/c/1381778
Commit-Queue: Sadrul Chowdhury <sadrul@chromium.org>
Reviewed-by: default avatarDaniele Castagna <dcastagna@chromium.org>
Cr-Commit-Position: refs/heads/master@{#618373}
parent 7204737f
...@@ -285,6 +285,7 @@ TEST_F(MAYBE_PointerTest, SetCursorAndSetCursorType) { ...@@ -285,6 +285,7 @@ TEST_F(MAYBE_PointerTest, SetCursorAndSetCursorType) {
// Set pointer surface. // Set pointer surface.
pointer->SetCursor(pointer_surface.get(), gfx::Point()); pointer->SetCursor(pointer_surface.get(), gfx::Point());
EXPECT_EQ(1u, pointer->GetActivePresentationCallbacksForTesting().size());
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
{ {
...@@ -299,12 +300,22 @@ TEST_F(MAYBE_PointerTest, SetCursorAndSetCursorType) { ...@@ -299,12 +300,22 @@ TEST_F(MAYBE_PointerTest, SetCursorAndSetCursorType) {
// Set the cursor type to the kNone through SetCursorType. // Set the cursor type to the kNone through SetCursorType.
pointer->SetCursorType(ui::CursorType::kNone); pointer->SetCursorType(ui::CursorType::kNone);
EXPECT_TRUE(pointer->GetActivePresentationCallbacksForTesting().empty());
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
EXPECT_EQ(nullptr, pointer->root_surface()); EXPECT_EQ(nullptr, pointer->root_surface());
// Set the same pointer surface again. // Set the same pointer surface again.
pointer->SetCursor(pointer_surface.get(), gfx::Point()); pointer->SetCursor(pointer_surface.get(), gfx::Point());
base::RunLoop().RunUntilIdle(); EXPECT_EQ(1u, pointer->GetActivePresentationCallbacksForTesting().size());
auto& list =
pointer->GetActivePresentationCallbacksForTesting().begin()->second;
base::RunLoop runloop;
list.push_back(base::BindRepeating(
[](base::Closure callback, const gfx::PresentationFeedback&) {
callback.Run();
},
runloop.QuitClosure()));
runloop.Run();
{ {
viz::SurfaceId surface_id = pointer->host_window()->GetSurfaceId(); viz::SurfaceId surface_id = pointer->host_window()->GetSurfaceId();
......
...@@ -65,6 +65,12 @@ class SurfaceTreeHost : public SurfaceDelegate, ...@@ -65,6 +65,12 @@ class SurfaceTreeHost : public SurfaceDelegate,
return layer_tree_frame_sink_holder_.get(); return layer_tree_frame_sink_holder_.get();
} }
using PresentationCallbacks = std::list<Surface::PresentationCallback>;
base::flat_map<uint32_t, PresentationCallbacks>&
GetActivePresentationCallbacksForTesting() {
return active_presentation_callbacks_;
}
// Overridden from SurfaceDelegate: // Overridden from SurfaceDelegate:
void OnSurfaceCommit() override; void OnSurfaceCommit() override;
bool IsSurfaceSynchronized() const override; bool IsSurfaceSynchronized() const override;
...@@ -104,7 +110,6 @@ class SurfaceTreeHost : public SurfaceDelegate, ...@@ -104,7 +110,6 @@ class SurfaceTreeHost : public SurfaceDelegate,
// These lists contains the callbacks to notify the client when surface // These lists contains the callbacks to notify the client when surface
// contents have been presented. // contents have been presented.
using PresentationCallbacks = std::list<Surface::PresentationCallback>;
PresentationCallbacks presentation_callbacks_; PresentationCallbacks presentation_callbacks_;
base::flat_map<uint32_t, PresentationCallbacks> base::flat_map<uint32_t, PresentationCallbacks>
active_presentation_callbacks_; active_presentation_callbacks_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment