Commit 2765e2b7 authored by Alexandros Frantzis's avatar Alexandros Frantzis Committed by Commit Bot

exo: Add test for buffer release after surface destruction

It's likely that at some point in the past Exo didn't properly emit
release events for buffers that were still attached to a surface when
that surface was destroyed.

Add this test to check that Exo now provides the expected behavior and
ensure we don't regress in the future

Change-Id: Ic73a49aebd9693b701c77580645d49e32dd96aca
Reviewed-on: https://chromium-review.googlesource.com/c/1458258Reviewed-by: default avatarDaniele Castagna <dcastagna@chromium.org>
Commit-Queue: Daniele Castagna <dcastagna@chromium.org>
Cr-Commit-Position: refs/heads/master@{#632364}
parent 5a1980fa
...@@ -904,5 +904,30 @@ TEST_P(SurfaceTest, SetClientSurfaceId) { ...@@ -904,5 +904,30 @@ TEST_P(SurfaceTest, SetClientSurfaceId) {
EXPECT_EQ(kTestId, surface->GetClientSurfaceId()); EXPECT_EQ(kTestId, surface->GetClientSurfaceId());
} }
TEST_P(SurfaceTest, DestroyWithAttachedBufferReleasesBuffer) {
gfx::Size buffer_size(1, 1);
auto buffer = std::make_unique<Buffer>(
exo_test_helper()->CreateGpuMemoryBuffer(buffer_size));
auto surface = std::make_unique<Surface>();
auto shell_surface = std::make_unique<ShellSurface>(surface.get());
int release_buffer_call_count = 0;
buffer->set_release_callback(base::BindRepeating(
&ReleaseBuffer, base::Unretained(&release_buffer_call_count)));
surface->Attach(buffer.get());
surface->Commit();
base::RunLoop().RunUntilIdle();
// Buffer is still attached at this point.
EXPECT_EQ(0, release_buffer_call_count);
// After the surface is destroyed, we should get a release event for the
// attached buffer.
shell_surface.reset();
surface.reset();
base::RunLoop().RunUntilIdle();
ASSERT_EQ(1, release_buffer_call_count);
}
} // namespace } // namespace
} // namespace exo } // namespace exo
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