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/surface_factory_client.h" | 8 #include "cc/surfaces/surface_factory_client.h" |
9 #include "cc/surfaces/surface_manager.h" | 9 #include "cc/surfaces/surface_manager.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 | 174 |
175 // Cleanup hierarchy. | 175 // Cleanup hierarchy. |
176 manager_.UnregisterFrameSinkHierarchy(root2.frame_sink_id(), | 176 manager_.UnregisterFrameSinkHierarchy(root2.frame_sink_id(), |
177 client_c.frame_sink_id()); | 177 client_c.frame_sink_id()); |
178 manager_.UnregisterFrameSinkHierarchy(client_c.frame_sink_id(), | 178 manager_.UnregisterFrameSinkHierarchy(client_c.frame_sink_id(), |
179 client_a.frame_sink_id()); | 179 client_a.frame_sink_id()); |
180 manager_.UnregisterFrameSinkHierarchy(client_a.frame_sink_id(), | 180 manager_.UnregisterFrameSinkHierarchy(client_a.frame_sink_id(), |
181 client_b.frame_sink_id()); | 181 client_b.frame_sink_id()); |
182 } | 182 } |
183 | 183 |
| 184 // This test verifies that a BeginFrameSource path to the root from a |
| 185 // FrameSinkId is preserved even if that FrameSinkId has no children |
| 186 // and does not have a corresponding SurfaceFactoryClient. |
| 187 TEST_F(SurfaceManagerTest, ParentWithoutClientRetained) { |
| 188 StubBeginFrameSource root_source; |
| 189 |
| 190 constexpr FrameSinkId kFrameSinkIdRoot(1, 1); |
| 191 constexpr FrameSinkId kFrameSinkIdA(2, 2); |
| 192 constexpr FrameSinkId kFrameSinkIdB(3, 3); |
| 193 constexpr FrameSinkId kFrameSinkIdC(4, 4); |
| 194 |
| 195 FakeSurfaceFactoryClient root(kFrameSinkIdRoot, &manager_); |
| 196 FakeSurfaceFactoryClient client_b(kFrameSinkIdB, &manager_); |
| 197 FakeSurfaceFactoryClient client_c(kFrameSinkIdC, &manager_); |
| 198 |
| 199 manager_.RegisterBeginFrameSource(&root_source, root.frame_sink_id()); |
| 200 EXPECT_EQ(&root_source, root.source()); |
| 201 |
| 202 // Set up initial hierarchy: root -> A -> B. |
| 203 // Note that A does not have a SurfaceFactoryClient. |
| 204 manager_.RegisterFrameSinkHierarchy(kFrameSinkIdRoot, kFrameSinkIdA); |
| 205 manager_.RegisterFrameSinkHierarchy(kFrameSinkIdA, kFrameSinkIdB); |
| 206 // The root's BeginFrameSource should propagate to B. |
| 207 EXPECT_EQ(root.source(), client_b.source()); |
| 208 |
| 209 // Unregister B, and attach C to A: root -> A -> C |
| 210 manager_.UnregisterFrameSinkHierarchy(kFrameSinkIdA, kFrameSinkIdB); |
| 211 EXPECT_EQ(nullptr, client_b.source()); |
| 212 manager_.RegisterFrameSinkHierarchy(kFrameSinkIdA, kFrameSinkIdC); |
| 213 // The root's BeginFrameSource should propagate to C. |
| 214 EXPECT_EQ(root.source(), client_c.source()); |
| 215 |
| 216 manager_.UnregisterBeginFrameSource(&root_source); |
| 217 EXPECT_EQ(nullptr, root.source()); |
| 218 EXPECT_EQ(nullptr, client_c.source()); |
| 219 } |
| 220 |
| 221 // This test sets up the same hierarchy as ParentWithoutClientRetained. |
| 222 // However, this unit test registers the BeginFrameSource AFTER C |
| 223 // has been attached to A. This test verifies that the BeginFrameSource |
| 224 // propagates all the way to C. |
| 225 TEST_F(SurfaceManagerTest, |
| 226 ParentWithoutClientRetained_LateBeginFrameRegistration) { |
| 227 StubBeginFrameSource root_source; |
| 228 |
| 229 constexpr FrameSinkId kFrameSinkIdRoot(1, 1); |
| 230 constexpr FrameSinkId kFrameSinkIdA(2, 2); |
| 231 constexpr FrameSinkId kFrameSinkIdB(3, 3); |
| 232 constexpr FrameSinkId kFrameSinkIdC(4, 4); |
| 233 |
| 234 FakeSurfaceFactoryClient root(kFrameSinkIdRoot, &manager_); |
| 235 FakeSurfaceFactoryClient client_b(kFrameSinkIdB, &manager_); |
| 236 FakeSurfaceFactoryClient client_c(kFrameSinkIdC, &manager_); |
| 237 |
| 238 // Set up initial hierarchy: root -> A -> B. |
| 239 // Note that A does not have a SurfaceFactoryClient. |
| 240 manager_.RegisterFrameSinkHierarchy(kFrameSinkIdRoot, kFrameSinkIdA); |
| 241 manager_.RegisterFrameSinkHierarchy(kFrameSinkIdA, kFrameSinkIdB); |
| 242 // The root does not yet have a BeginFrameSource so client B should not have |
| 243 // one either. |
| 244 EXPECT_EQ(nullptr, client_b.source()); |
| 245 |
| 246 // Unregister B, and attach C to A: root -> A -> C |
| 247 manager_.UnregisterFrameSinkHierarchy(kFrameSinkIdA, kFrameSinkIdB); |
| 248 manager_.RegisterFrameSinkHierarchy(kFrameSinkIdA, kFrameSinkIdC); |
| 249 |
| 250 // Registering a BeginFrameSource at the root should propagate it to C. |
| 251 manager_.RegisterBeginFrameSource(&root_source, root.frame_sink_id()); |
| 252 // The root's BeginFrameSource should propagate to C. |
| 253 EXPECT_EQ(&root_source, root.source()); |
| 254 EXPECT_EQ(root.source(), client_c.source()); |
| 255 |
| 256 manager_.UnregisterBeginFrameSource(&root_source); |
| 257 EXPECT_EQ(nullptr, root.source()); |
| 258 EXPECT_EQ(nullptr, client_c.source()); |
| 259 } |
| 260 |
184 // In practice, registering and unregistering both parent/child relationships | 261 // In practice, registering and unregistering both parent/child relationships |
185 // and SurfaceFactoryClients can happen in any ordering with respect to | 262 // and SurfaceFactoryClients can happen in any ordering with respect to |
186 // each other. These following tests verify that all the data structures | 263 // each other. These following tests verify that all the data structures |
187 // are properly set up and cleaned up under the four permutations of orderings | 264 // are properly set up and cleaned up under the four permutations of orderings |
188 // of this nesting. | 265 // of this nesting. |
189 | 266 |
190 class SurfaceManagerOrderingTest : public SurfaceManagerTest { | 267 class SurfaceManagerOrderingTest : public SurfaceManagerTest { |
191 public: | 268 public: |
192 SurfaceManagerOrderingTest() | 269 SurfaceManagerOrderingTest() |
193 : client_a_(FrameSinkId(1, 1)), | 270 : client_a_(FrameSinkId(1, 1)), |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 } | 443 } |
367 | 444 |
368 INSTANTIATE_TEST_CASE_P( | 445 INSTANTIATE_TEST_CASE_P( |
369 SurfaceManagerOrderingParamTestInstantiation, | 446 SurfaceManagerOrderingParamTestInstantiation, |
370 SurfaceManagerOrderingParamTest, | 447 SurfaceManagerOrderingParamTest, |
371 ::testing::Combine(::testing::ValuesIn(kRegisterOrderList), | 448 ::testing::Combine(::testing::ValuesIn(kRegisterOrderList), |
372 ::testing::ValuesIn(kUnregisterOrderList), | 449 ::testing::ValuesIn(kUnregisterOrderList), |
373 ::testing::ValuesIn(kBFSOrderList))); | 450 ::testing::ValuesIn(kBFSOrderList))); |
374 | 451 |
375 } // namespace cc | 452 } // namespace cc |
OLD | NEW |