OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include "cc/scheduler/begin_frame_source.h" | 7 #include "cc/scheduler/begin_frame_source.h" |
8 #include "cc/surfaces/frame_sink_manager_client.h" | 8 #include "cc/surfaces/frame_sink_manager_client.h" |
9 #include "cc/surfaces/surface_factory_client.h" | |
10 #include "cc/surfaces/surface_manager.h" | 9 #include "cc/surfaces/surface_manager.h" |
11 #include "cc/surfaces/surface_resource_holder_client.h" | |
12 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
13 | 11 |
14 namespace cc { | 12 namespace cc { |
15 | 13 |
16 class FakeFrameSinkManagerClient : public FrameSinkManagerClient { | 14 class FakeFrameSinkManagerClient : public FrameSinkManagerClient { |
17 public: | 15 public: |
18 explicit FakeFrameSinkManagerClient(const FrameSinkId& frame_sink_id) | 16 explicit FakeFrameSinkManagerClient(const FrameSinkId& frame_sink_id) |
19 : source_(nullptr), manager_(nullptr), frame_sink_id_(frame_sink_id) {} | 17 : source_(nullptr), manager_(nullptr), frame_sink_id_(frame_sink_id) {} |
20 | 18 |
21 FakeFrameSinkManagerClient(const FrameSinkId& frame_sink_id, | 19 FakeFrameSinkManagerClient(const FrameSinkId& frame_sink_id, |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 manager_.UnregisterFrameSinkHierarchy(root2.frame_sink_id(), | 175 manager_.UnregisterFrameSinkHierarchy(root2.frame_sink_id(), |
178 client_c.frame_sink_id()); | 176 client_c.frame_sink_id()); |
179 manager_.UnregisterFrameSinkHierarchy(client_c.frame_sink_id(), | 177 manager_.UnregisterFrameSinkHierarchy(client_c.frame_sink_id(), |
180 client_a.frame_sink_id()); | 178 client_a.frame_sink_id()); |
181 manager_.UnregisterFrameSinkHierarchy(client_a.frame_sink_id(), | 179 manager_.UnregisterFrameSinkHierarchy(client_a.frame_sink_id(), |
182 client_b.frame_sink_id()); | 180 client_b.frame_sink_id()); |
183 } | 181 } |
184 | 182 |
185 // This test verifies that a BeginFrameSource path to the root from a | 183 // This test verifies that a BeginFrameSource path to the root from a |
186 // FrameSinkId is preserved even if that FrameSinkId has no children | 184 // FrameSinkId is preserved even if that FrameSinkId has no children |
187 // and does not have a corresponding SurfaceFactoryClient. | 185 // and does not have a corresponding FrameSinkManagerClient. |
188 TEST_F(SurfaceManagerTest, ParentWithoutClientRetained) { | 186 TEST_F(SurfaceManagerTest, ParentWithoutClientRetained) { |
189 StubBeginFrameSource root_source; | 187 StubBeginFrameSource root_source; |
190 | 188 |
191 constexpr FrameSinkId kFrameSinkIdRoot(1, 1); | 189 constexpr FrameSinkId kFrameSinkIdRoot(1, 1); |
192 constexpr FrameSinkId kFrameSinkIdA(2, 2); | 190 constexpr FrameSinkId kFrameSinkIdA(2, 2); |
193 constexpr FrameSinkId kFrameSinkIdB(3, 3); | 191 constexpr FrameSinkId kFrameSinkIdB(3, 3); |
194 constexpr FrameSinkId kFrameSinkIdC(4, 4); | 192 constexpr FrameSinkId kFrameSinkIdC(4, 4); |
195 | 193 |
196 FakeFrameSinkManagerClient root(kFrameSinkIdRoot, &manager_); | 194 FakeFrameSinkManagerClient root(kFrameSinkIdRoot, &manager_); |
197 FakeFrameSinkManagerClient client_b(kFrameSinkIdB, &manager_); | 195 FakeFrameSinkManagerClient client_b(kFrameSinkIdB, &manager_); |
198 FakeFrameSinkManagerClient client_c(kFrameSinkIdC, &manager_); | 196 FakeFrameSinkManagerClient client_c(kFrameSinkIdC, &manager_); |
199 | 197 |
200 manager_.RegisterBeginFrameSource(&root_source, root.frame_sink_id()); | 198 manager_.RegisterBeginFrameSource(&root_source, root.frame_sink_id()); |
201 EXPECT_EQ(&root_source, root.source()); | 199 EXPECT_EQ(&root_source, root.source()); |
202 | 200 |
203 // Set up initial hierarchy: root -> A -> B. | 201 // Set up initial hierarchy: root -> A -> B. |
204 // Note that A does not have a SurfaceFactoryClient. | 202 // Note that A does not have a FrameSinkManagerClient. |
205 manager_.RegisterFrameSinkHierarchy(kFrameSinkIdRoot, kFrameSinkIdA); | 203 manager_.RegisterFrameSinkHierarchy(kFrameSinkIdRoot, kFrameSinkIdA); |
206 manager_.RegisterFrameSinkHierarchy(kFrameSinkIdA, kFrameSinkIdB); | 204 manager_.RegisterFrameSinkHierarchy(kFrameSinkIdA, kFrameSinkIdB); |
207 // The root's BeginFrameSource should propagate to B. | 205 // The root's BeginFrameSource should propagate to B. |
208 EXPECT_EQ(root.source(), client_b.source()); | 206 EXPECT_EQ(root.source(), client_b.source()); |
209 | 207 |
210 // Unregister B, and attach C to A: root -> A -> C | 208 // Unregister B, and attach C to A: root -> A -> C |
211 manager_.UnregisterFrameSinkHierarchy(kFrameSinkIdA, kFrameSinkIdB); | 209 manager_.UnregisterFrameSinkHierarchy(kFrameSinkIdA, kFrameSinkIdB); |
212 EXPECT_EQ(nullptr, client_b.source()); | 210 EXPECT_EQ(nullptr, client_b.source()); |
213 manager_.RegisterFrameSinkHierarchy(kFrameSinkIdA, kFrameSinkIdC); | 211 manager_.RegisterFrameSinkHierarchy(kFrameSinkIdA, kFrameSinkIdC); |
214 // The root's BeginFrameSource should propagate to C. | 212 // The root's BeginFrameSource should propagate to C. |
(...skipping 15 matching lines...) Expand all Loading... |
230 constexpr FrameSinkId kFrameSinkIdRoot(1, 1); | 228 constexpr FrameSinkId kFrameSinkIdRoot(1, 1); |
231 constexpr FrameSinkId kFrameSinkIdA(2, 2); | 229 constexpr FrameSinkId kFrameSinkIdA(2, 2); |
232 constexpr FrameSinkId kFrameSinkIdB(3, 3); | 230 constexpr FrameSinkId kFrameSinkIdB(3, 3); |
233 constexpr FrameSinkId kFrameSinkIdC(4, 4); | 231 constexpr FrameSinkId kFrameSinkIdC(4, 4); |
234 | 232 |
235 FakeFrameSinkManagerClient root(kFrameSinkIdRoot, &manager_); | 233 FakeFrameSinkManagerClient root(kFrameSinkIdRoot, &manager_); |
236 FakeFrameSinkManagerClient client_b(kFrameSinkIdB, &manager_); | 234 FakeFrameSinkManagerClient client_b(kFrameSinkIdB, &manager_); |
237 FakeFrameSinkManagerClient client_c(kFrameSinkIdC, &manager_); | 235 FakeFrameSinkManagerClient client_c(kFrameSinkIdC, &manager_); |
238 | 236 |
239 // Set up initial hierarchy: root -> A -> B. | 237 // Set up initial hierarchy: root -> A -> B. |
240 // Note that A does not have a SurfaceFactoryClient. | 238 // Note that A does not have a FrameSinkManagerClient. |
241 manager_.RegisterFrameSinkHierarchy(kFrameSinkIdRoot, kFrameSinkIdA); | 239 manager_.RegisterFrameSinkHierarchy(kFrameSinkIdRoot, kFrameSinkIdA); |
242 manager_.RegisterFrameSinkHierarchy(kFrameSinkIdA, kFrameSinkIdB); | 240 manager_.RegisterFrameSinkHierarchy(kFrameSinkIdA, kFrameSinkIdB); |
243 // The root does not yet have a BeginFrameSource so client B should not have | 241 // The root does not yet have a BeginFrameSource so client B should not have |
244 // one either. | 242 // one either. |
245 EXPECT_EQ(nullptr, client_b.source()); | 243 EXPECT_EQ(nullptr, client_b.source()); |
246 | 244 |
247 // Unregister B, and attach C to A: root -> A -> C | 245 // Unregister B, and attach C to A: root -> A -> C |
248 manager_.UnregisterFrameSinkHierarchy(kFrameSinkIdA, kFrameSinkIdB); | 246 manager_.UnregisterFrameSinkHierarchy(kFrameSinkIdA, kFrameSinkIdB); |
249 manager_.RegisterFrameSinkHierarchy(kFrameSinkIdA, kFrameSinkIdC); | 247 manager_.RegisterFrameSinkHierarchy(kFrameSinkIdA, kFrameSinkIdC); |
250 | 248 |
251 // Registering a BeginFrameSource at the root should propagate it to C. | 249 // Registering a BeginFrameSource at the root should propagate it to C. |
252 manager_.RegisterBeginFrameSource(&root_source, root.frame_sink_id()); | 250 manager_.RegisterBeginFrameSource(&root_source, root.frame_sink_id()); |
253 // The root's BeginFrameSource should propagate to C. | 251 // The root's BeginFrameSource should propagate to C. |
254 EXPECT_EQ(&root_source, root.source()); | 252 EXPECT_EQ(&root_source, root.source()); |
255 EXPECT_EQ(root.source(), client_c.source()); | 253 EXPECT_EQ(root.source(), client_c.source()); |
256 | 254 |
257 manager_.UnregisterBeginFrameSource(&root_source); | 255 manager_.UnregisterBeginFrameSource(&root_source); |
258 EXPECT_EQ(nullptr, root.source()); | 256 EXPECT_EQ(nullptr, root.source()); |
259 EXPECT_EQ(nullptr, client_c.source()); | 257 EXPECT_EQ(nullptr, client_c.source()); |
260 } | 258 } |
261 | 259 |
262 // In practice, registering and unregistering both parent/child relationships | 260 // In practice, registering and unregistering both parent/child relationships |
263 // and SurfaceFactoryClients can happen in any ordering with respect to | 261 // and FrameSinkManagerClients can happen in any ordering with respect to |
264 // each other. These following tests verify that all the data structures | 262 // each other. These following tests verify that all the data structures |
265 // are properly set up and cleaned up under the four permutations of orderings | 263 // are properly set up and cleaned up under the four permutations of orderings |
266 // of this nesting. | 264 // of this nesting. |
267 | 265 |
268 class SurfaceManagerOrderingTest : public SurfaceManagerTest { | 266 class SurfaceManagerOrderingTest : public SurfaceManagerTest { |
269 public: | 267 public: |
270 SurfaceManagerOrderingTest() | 268 SurfaceManagerOrderingTest() |
271 : client_a_(FrameSinkId(1, 1)), | 269 : client_a_(FrameSinkId(1, 1)), |
272 client_b_(FrameSinkId(2, 2)), | 270 client_b_(FrameSinkId(2, 2)), |
273 client_c_(FrameSinkId(3, 3)), | 271 client_c_(FrameSinkId(3, 3)), |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 } | 442 } |
445 | 443 |
446 INSTANTIATE_TEST_CASE_P( | 444 INSTANTIATE_TEST_CASE_P( |
447 SurfaceManagerOrderingParamTestInstantiation, | 445 SurfaceManagerOrderingParamTestInstantiation, |
448 SurfaceManagerOrderingParamTest, | 446 SurfaceManagerOrderingParamTest, |
449 ::testing::Combine(::testing::ValuesIn(kRegisterOrderList), | 447 ::testing::Combine(::testing::ValuesIn(kRegisterOrderList), |
450 ::testing::ValuesIn(kUnregisterOrderList), | 448 ::testing::ValuesIn(kUnregisterOrderList), |
451 ::testing::ValuesIn(kBFSOrderList))); | 449 ::testing::ValuesIn(kBFSOrderList))); |
452 | 450 |
453 } // namespace cc | 451 } // namespace cc |
OLD | NEW |