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 |
184 // In practice, registering and unregistering both parent/child relationships | 221 // In practice, registering and unregistering both parent/child relationships |
185 // and SurfaceFactoryClients can happen in any ordering with respect to | 222 // and SurfaceFactoryClients can happen in any ordering with respect to |
186 // each other. These following tests verify that all the data structures | 223 // 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 | 224 // are properly set up and cleaned up under the four permutations of orderings |
188 // of this nesting. | 225 // of this nesting. |
189 | 226 |
190 class SurfaceManagerOrderingTest : public SurfaceManagerTest { | 227 class SurfaceManagerOrderingTest : public SurfaceManagerTest { |
191 public: | 228 public: |
192 SurfaceManagerOrderingTest() | 229 SurfaceManagerOrderingTest() |
193 : client_a_(FrameSinkId(1, 1)), | 230 : client_a_(FrameSinkId(1, 1)), |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 } | 403 } |
367 | 404 |
368 INSTANTIATE_TEST_CASE_P( | 405 INSTANTIATE_TEST_CASE_P( |
369 SurfaceManagerOrderingParamTestInstantiation, | 406 SurfaceManagerOrderingParamTestInstantiation, |
370 SurfaceManagerOrderingParamTest, | 407 SurfaceManagerOrderingParamTest, |
371 ::testing::Combine(::testing::ValuesIn(kRegisterOrderList), | 408 ::testing::Combine(::testing::ValuesIn(kRegisterOrderList), |
372 ::testing::ValuesIn(kUnregisterOrderList), | 409 ::testing::ValuesIn(kUnregisterOrderList), |
373 ::testing::ValuesIn(kBFSOrderList))); | 410 ::testing::ValuesIn(kBFSOrderList))); |
374 | 411 |
375 } // namespace cc | 412 } // namespace cc |
OLD | NEW |