| Index: components/exo/display_unittest.cc
|
| diff --git a/components/exo/display_unittest.cc b/components/exo/display_unittest.cc
|
| index a27d0d6398ced5bc7f690d9e4edf4554f5cf8917..675e21f3f4536042583f1e434e7ff23c38d60e30 100644
|
| --- a/components/exo/display_unittest.cc
|
| +++ b/components/exo/display_unittest.cc
|
| @@ -86,6 +86,35 @@ TEST_F(DisplayTest, DISABLED_CreateLinuxDMABufBuffer) {
|
| EXPECT_FALSE(buffer2);
|
| }
|
|
|
| +TEST_F(DisplayTest, CreateLinuxFence) {
|
| + int sockets_unscoped[2];
|
| +
|
| + ASSERT_EQ(0, socketpair(AF_UNIX, SOCK_STREAM, 0, fds));
|
| +
|
| + // Emulate the behaviour of a fence FD (returns POLLIN when signaled) using
|
| + // a socket pair.
|
| + Base::ScopedFD socket_waitee(sockets_unscoped[0]);
|
| +
|
| + std::unique_ptr<gfx::GpuFence> fence1 =
|
| + display->CreateLinuxFence(sockets_unscoped[1]);
|
| + ASSERT_TRUE(fence1);
|
| + close(sockets_unscoped[1]);
|
| +
|
| + // The fence must be unsignaled when we start.
|
| + EXPECT_FALSE(fence1->Wait(TimeDelta::FromMilliseconds(50)));
|
| +
|
| + // Unblock the fence, and make sure this signals success.
|
| + uint32_t dummy = 1;
|
| + ASSERT_EQ(sizeof(dummy), UnixDomainSocket::SendMsg(socket_waitee, &dummy,
|
| + sizeof(dummy), nullptr));
|
| +
|
| + EXPECT_TRUE(fence1->Wait(TimeDelta::FromMilliseconds(50)));
|
| +
|
| + // Check that invalid file descriptors are rejected.
|
| + std::unique_ptr<gfx::GpuFence> fence2 = display->CreateLinuxFence(-1);
|
| + EXPECT_FALSE(fence2);
|
| +}
|
| +
|
| // TODO(dcastagna): Add YV12 unittest once we can allocate the buffer
|
| // via Ozone. crbug.com/618516
|
|
|
|
|