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

Unified Diff: components/exo/display_unittest.cc

Issue 2404513002: exo: Implement zcr_linux_explicit_synchronization_v1
Patch Set: remove stray aura/env include Created 4 years, 2 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
Index: components/exo/display_unittest.cc
diff --git a/components/exo/display_unittest.cc b/components/exo/display_unittest.cc
index 694915dbf624be1dba91dbfc994756c9c6810081..a4c161711a0e6ec5e63a6552776d97e8396a4f7f 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

Powered by Google App Engine
This is Rietveld 408576698