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

Unified Diff: components/exo/display_unittest.cc

Issue 2404513002: exo: Implement zcr_linux_explicit_synchronization_v1
Patch Set: rebase, pull in cl 2443823002 Created 4 years, 1 month 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/surface.h » ('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 a27d0d6398ced5bc7f690d9e4edf4554f5cf8917..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"
@@ -88,8 +93,45 @@ TEST_F(DisplayTest, DISABLED_CreateLinuxDMABufBuffer) {
// TODO(dcastagna): Add YV12 unittest once we can allocate the buffer
// via Ozone. crbug.com/618516
+#endif // defined(USE_OZONE)
-#endif
+#if defined(OS_LINUX)
+TEST_F(DisplayTest, CreateLinuxFence) {
+ std::unique_ptr<Display> display(new Display);
+
+ // Skip test if sw sync device doesn't exist.
+ if (!base::PathExists(base::FilePath(FILE_PATH_LITERAL("/dev/sw_sync"))))
+ return;
+
+ // 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(std::move(fence_fd));
+ ASSERT_TRUE(fence1);
+
+ // The fence must be unsignaled when we start.
+ EXPECT_FALSE(fence1->IsSignaled());
+
+ // 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(base::TimeDelta::FromMilliseconds(50)));
+
+ base::ScopedFD invalid_fd;
+ // Check that invalid file descriptors are rejected.
+ std::unique_ptr<gfx::GpuFence> fence2 =
+ display->CreateLinuxFence(std::move(invalid_fd));
+ EXPECT_FALSE(fence2);
+}
+#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/surface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698