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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « components/exo/display.cc ('k') | components/exo/surface.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/public/cpp/shell_window_ids.h" 5 #include "ash/public/cpp/shell_window_ids.h"
6 #include "components/exo/buffer.h" 6 #include "components/exo/buffer.h"
7 #include "components/exo/display.h" 7 #include "components/exo/display.h"
8 #include "components/exo/shared_memory.h" 8 #include "components/exo/shared_memory.h"
9 #include "components/exo/shell_surface.h" 9 #include "components/exo/shell_surface.h"
10 #include "components/exo/sub_surface.h" 10 #include "components/exo/sub_surface.h"
11 #include "components/exo/surface.h" 11 #include "components/exo/surface.h"
12 #include "components/exo/test/exo_test_base.h" 12 #include "components/exo/test/exo_test_base.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 14
15 #if defined(OS_LINUX)
16 #include "third_party/libsync/include/sw_sync.h"
17 #include "ui/gfx/gpu_fence.h"
18 #endif
19
15 #if defined(USE_OZONE) 20 #if defined(USE_OZONE)
16 #include "ui/ozone/public/native_pixmap.h" 21 #include "ui/ozone/public/native_pixmap.h"
17 #include "ui/ozone/public/ozone_platform.h" 22 #include "ui/ozone/public/ozone_platform.h"
18 #include "ui/ozone/public/surface_factory_ozone.h" 23 #include "ui/ozone/public/surface_factory_ozone.h"
19 #endif 24 #endif
20 25
21 namespace exo { 26 namespace exo {
22 namespace { 27 namespace {
23 28
24 using DisplayTest = test::ExoTestBase; 29 using DisplayTest = test::ExoTestBase;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 invalid_fds.push_back(base::ScopedFD()); 86 invalid_fds.push_back(base::ScopedFD());
82 // Creating a prime buffer using an invalid fd should fail. 87 // Creating a prime buffer using an invalid fd should fail.
83 std::unique_ptr<Buffer> buffer2 = display->CreateLinuxDMABufBuffer( 88 std::unique_ptr<Buffer> buffer2 = display->CreateLinuxDMABufBuffer(
84 buffer_size, gfx::BufferFormat::RGBA_8888, planes, 89 buffer_size, gfx::BufferFormat::RGBA_8888, planes,
85 std::move(invalid_fds)); 90 std::move(invalid_fds));
86 EXPECT_FALSE(buffer2); 91 EXPECT_FALSE(buffer2);
87 } 92 }
88 93
89 // TODO(dcastagna): Add YV12 unittest once we can allocate the buffer 94 // TODO(dcastagna): Add YV12 unittest once we can allocate the buffer
90 // via Ozone. crbug.com/618516 95 // via Ozone. crbug.com/618516
96 #endif // defined(USE_OZONE)
91 97
92 #endif 98 #if defined(OS_LINUX)
99 TEST_F(DisplayTest, CreateLinuxFence) {
100 std::unique_ptr<Display> display(new Display);
101
102 // Skip test if sw sync device doesn't exist.
103 if (!base::PathExists(base::FilePath(FILE_PATH_LITERAL("/dev/sw_sync"))))
104 return;
105
106 // Initial position for timeline is 0.
107 base::ScopedFD timeline_fd(sw_sync_timeline_create());
108 ASSERT_TRUE(timeline_fd.is_valid());
109
110 int sync_point = 1;
111 // Create a fence for |sync_point|.
112 base::ScopedFD fence_fd(
113 sw_sync_fence_create(timeline_fd.get(), "cr-test-fence", sync_point));
114
115 std::unique_ptr<gfx::GpuFence> fence1 =
116 display->CreateLinuxFence(std::move(fence_fd));
117 ASSERT_TRUE(fence1);
118
119 // The fence must be unsignaled when we start.
120 EXPECT_FALSE(fence1->IsSignaled());
121
122 // Increment timeline to 1 to signal fence.
123 int rv = sw_sync_timeline_inc(timeline_fd.get(), 1);
124 EXPECT_EQ(0, rv);
125
126 EXPECT_TRUE(fence1->Wait(base::TimeDelta::FromMilliseconds(50)));
127
128 base::ScopedFD invalid_fd;
129 // Check that invalid file descriptors are rejected.
130 std::unique_ptr<gfx::GpuFence> fence2 =
131 display->CreateLinuxFence(std::move(invalid_fd));
132 EXPECT_FALSE(fence2);
133 }
134 #endif // defined(OS_LINUX)
93 135
94 TEST_F(DisplayTest, CreateShellSurface) { 136 TEST_F(DisplayTest, CreateShellSurface) {
95 std::unique_ptr<Display> display(new Display); 137 std::unique_ptr<Display> display(new Display);
96 138
97 // Create two surfaces. 139 // Create two surfaces.
98 std::unique_ptr<Surface> surface1 = display->CreateSurface(); 140 std::unique_ptr<Surface> surface1 = display->CreateSurface();
99 ASSERT_TRUE(surface1); 141 ASSERT_TRUE(surface1);
100 std::unique_ptr<Surface> surface2 = display->CreateSurface(); 142 std::unique_ptr<Surface> surface2 = display->CreateSurface();
101 ASSERT_TRUE(surface2); 143 ASSERT_TRUE(surface2);
102 144
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 // Attempting to create a sub surface for parent with grandchild as its parent 259 // Attempting to create a sub surface for parent with grandchild as its parent
218 // should fail. 260 // should fail.
219 EXPECT_FALSE(display->CreateSubSurface(parent.get(), grandchild.get())); 261 EXPECT_FALSE(display->CreateSubSurface(parent.get(), grandchild.get()));
220 262
221 // Create a sub surface for parent. 263 // Create a sub surface for parent.
222 EXPECT_TRUE(display->CreateSubSurface(parent.get(), toplevel.get())); 264 EXPECT_TRUE(display->CreateSubSurface(parent.get(), toplevel.get()));
223 } 265 }
224 266
225 } // namespace 267 } // namespace
226 } // namespace exo 268 } // namespace exo
OLDNEW
« 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