Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/common/shell_window_ids.h" | 5 #include "ash/common/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" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 79 | 79 |
| 80 std::vector<base::ScopedFD> invalid_fds; | 80 std::vector<base::ScopedFD> invalid_fds; |
| 81 invalid_fds.push_back(base::ScopedFD()); | 81 invalid_fds.push_back(base::ScopedFD()); |
| 82 // Creating a prime buffer using an invalid fd should fail. | 82 // Creating a prime buffer using an invalid fd should fail. |
| 83 std::unique_ptr<Buffer> buffer2 = display->CreateLinuxDMABufBuffer( | 83 std::unique_ptr<Buffer> buffer2 = display->CreateLinuxDMABufBuffer( |
| 84 buffer_size, gfx::BufferFormat::RGBA_8888, planes, | 84 buffer_size, gfx::BufferFormat::RGBA_8888, planes, |
| 85 std::move(invalid_fds)); | 85 std::move(invalid_fds)); |
| 86 EXPECT_FALSE(buffer2); | 86 EXPECT_FALSE(buffer2); |
| 87 } | 87 } |
| 88 | 88 |
| 89 TEST_F(DisplayTest, CreateLinuxFence) { | |
| 90 int sockets_unscoped[2]; | |
| 91 | |
| 92 ASSERT_EQ(0, socketpair(AF_UNIX, SOCK_STREAM, 0, fds)); | |
| 93 | |
| 94 // Emulate the behaviour of a fence FD (returns POLLIN when signaled) using | |
| 95 // a socket pair. | |
| 96 Base::ScopedFD socket_waitee(sockets_unscoped[0]); | |
| 97 | |
| 98 std::unique_ptr<gfx::GpuFence> fence1 = | |
| 99 display->CreateLinuxFence(sockets_unscoped[1]); | |
| 100 EXPECT_TRUE(fence1); | |
|
reveman
2016/10/12 19:20:19
nit: ASSERT_TRUE as code below will crash if this
| |
| 101 close(sockets_unscoped[1]); | |
| 102 | |
| 103 // The fence must be unsignaled when we start. | |
| 104 EXPECT_FALSE(fence1->Wait(TimeDelta::FromMilliseconds(50))); | |
| 105 | |
| 106 // Unblock the fence, and make sure this signals success. | |
| 107 uint32_t dummy = 1; | |
| 108 ASSERT_EQ(sizeof(dummy), UnixDomainSocket::SendMsg(socket_waitee, &dummy, | |
| 109 sizeof(dummy), nullptr)); | |
| 110 | |
| 111 EXPECT_TRUE(fence1->Wait(TimeDelta::FromMilliseconds(50))); | |
| 112 | |
| 113 std::unique_ptr<gfx::GpuFence> fence2 = | |
|
reveman
2016/10/12 19:20:19
nit: just a short comment here to explain that thi
| |
| 114 display->CreateLinuxFence(-1); | |
| 115 EXPECT_FALSE(fence2); | |
| 116 } | |
| 117 | |
| 89 // TODO(dcastagna): Add YV12 unittest once we can allocate the buffer | 118 // TODO(dcastagna): Add YV12 unittest once we can allocate the buffer |
| 90 // via Ozone. crbug.com/618516 | 119 // via Ozone. crbug.com/618516 |
| 91 | 120 |
| 92 #endif | 121 #endif |
| 93 | 122 |
| 94 TEST_F(DisplayTest, CreateShellSurface) { | 123 TEST_F(DisplayTest, CreateShellSurface) { |
| 95 std::unique_ptr<Display> display(new Display); | 124 std::unique_ptr<Display> display(new Display); |
| 96 | 125 |
| 97 // Create two surfaces. | 126 // Create two surfaces. |
| 98 std::unique_ptr<Surface> surface1 = display->CreateSurface(); | 127 std::unique_ptr<Surface> surface1 = display->CreateSurface(); |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 217 // Attempting to create a sub surface for parent with grandchild as its parent | 246 // Attempting to create a sub surface for parent with grandchild as its parent |
| 218 // should fail. | 247 // should fail. |
| 219 EXPECT_FALSE(display->CreateSubSurface(parent.get(), grandchild.get())); | 248 EXPECT_FALSE(display->CreateSubSurface(parent.get(), grandchild.get())); |
| 220 | 249 |
| 221 // Create a sub surface for parent. | 250 // Create a sub surface for parent. |
| 222 EXPECT_TRUE(display->CreateSubSurface(parent.get(), toplevel.get())); | 251 EXPECT_TRUE(display->CreateSubSurface(parent.get(), toplevel.get())); |
| 223 } | 252 } |
| 224 | 253 |
| 225 } // namespace | 254 } // namespace |
| 226 } // namespace exo | 255 } // namespace exo |
| OLD | NEW |