Chromium Code Reviews| Index: components/exo/display_unittest.cc |
| diff --git a/components/exo/display_unittest.cc b/components/exo/display_unittest.cc |
| index 694915dbf624be1dba91dbfc994756c9c6810081..ac29c755f917bca935f6b892c574f9999519d71b 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]); |
| + EXPECT_TRUE(fence1); |
|
reveman
2016/10/12 19:20:19
nit: ASSERT_TRUE as code below will crash if this
|
| + 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))); |
| + |
| + std::unique_ptr<gfx::GpuFence> fence2 = |
|
reveman
2016/10/12 19:20:19
nit: just a short comment here to explain that thi
|
| + display->CreateLinuxFence(-1); |
| + EXPECT_FALSE(fence2); |
| +} |
| + |
| // TODO(dcastagna): Add YV12 unittest once we can allocate the buffer |
| // via Ozone. crbug.com/618516 |