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

Unified Diff: components/exo/display_unittest.cc

Issue 2443823002: exo: Fix CreateLinuxFence test. (Closed)
Patch Set: exo: Fix CreateLinuxFence test. 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
« no previous file with comments | « components/exo/display.cc ('k') | components/exo/wayland/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/exo/display_unittest.cc
diff --git a/components/exo/display_unittest.cc b/components/exo/display_unittest.cc
index 675e21f3f4536042583f1e434e7ff23c38d60e30..62217c7d3580064b1098ea096a76e048a4c29ac0 100644
--- a/components/exo/display_unittest.cc
+++ b/components/exo/display_unittest.cc
@@ -12,6 +12,11 @@
#include "components/exo/test/exo_test_base.h"
#include "testing/gtest/include/gtest/gtest.h"
+#if defined(OS_LINUX)
+#include "third_party/libsync/include/sw_sync.h"
+#include "ui/gfx/gpu_fence.h"
+#endif
+
#if defined(USE_OZONE)
#include "ui/ozone/public/native_pixmap.h"
#include "ui/ozone/public/ozone_platform.h"
@@ -86,39 +91,47 @@ TEST_F(DisplayTest, DISABLED_CreateLinuxDMABufBuffer) {
EXPECT_FALSE(buffer2);
}
+// TODO(dcastagna): Add YV12 unittest once we can allocate the buffer
+// via Ozone. crbug.com/618516
+#endif // defined(USE_OZONE)
+
+#if defined(OS_LINUX)
TEST_F(DisplayTest, CreateLinuxFence) {
- int sockets_unscoped[2];
+ std::unique_ptr<Display> display(new Display);
- ASSERT_EQ(0, socketpair(AF_UNIX, SOCK_STREAM, 0, fds));
+ // Skip test if sw sync device doesn't exist.
+ if (!base::PathExists(base::FilePath(FILE_PATH_LITERAL("/dev/sw_sync"))))
+ return;
- // Emulate the behaviour of a fence FD (returns POLLIN when signaled) using
- // a socket pair.
- Base::ScopedFD socket_waitee(sockets_unscoped[0]);
+ // Initial position for timeline is 0.
+ base::ScopedFD timeline_fd(sw_sync_timeline_create());
+ ASSERT_TRUE(timeline_fd.is_valid());
+
+ int sync_point = 1;
+ // Create a fence for |sync_point|.
+ base::ScopedFD fence_fd(
+ sw_sync_fence_create(timeline_fd.get(), "cr-test-fence", sync_point));
std::unique_ptr<gfx::GpuFence> fence1 =
- display->CreateLinuxFence(sockets_unscoped[1]);
+ display->CreateLinuxFence(std::move(fence_fd));
ASSERT_TRUE(fence1);
- close(sockets_unscoped[1]);
// The fence must be unsignaled when we start.
- EXPECT_FALSE(fence1->Wait(TimeDelta::FromMilliseconds(50)));
+ EXPECT_FALSE(fence1->IsSignaled());
- // 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));
+ // Increment timeline to 1 to signal fence.
+ int rv = sw_sync_timeline_inc(timeline_fd.get(), 1);
+ EXPECT_EQ(0, rv);
- EXPECT_TRUE(fence1->Wait(TimeDelta::FromMilliseconds(50)));
+ EXPECT_TRUE(fence1->Wait(base::TimeDelta::FromMilliseconds(50)));
+ base::ScopedFD invalid_fd;
// Check that invalid file descriptors are rejected.
- std::unique_ptr<gfx::GpuFence> fence2 = display->CreateLinuxFence(-1);
+ std::unique_ptr<gfx::GpuFence> fence2 =
+ display->CreateLinuxFence(std::move(invalid_fd));
EXPECT_FALSE(fence2);
}
-
-// TODO(dcastagna): Add YV12 unittest once we can allocate the buffer
-// via Ozone. crbug.com/618516
-
-#endif
+#endif // defined(OS_LINUX)
TEST_F(DisplayTest, CreateShellSurface) {
std::unique_ptr<Display> display(new Display);
« no previous file with comments | « components/exo/display.cc ('k') | components/exo/wayland/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698