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 "cc/layers/layer_list_iterator.h" | 5 #include "cc/layers/layer_list_iterator.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/containers/adapters.h" | 9 #include "base/containers/adapters.h" |
10 #include "cc/test/fake_compositor_frame_sink.h" | 10 #include "cc/test/fake_compositor_frame_sink.h" |
11 #include "cc/test/fake_impl_task_runner_provider.h" | 11 #include "cc/test/fake_impl_task_runner_provider.h" |
12 #include "cc/test/fake_layer_tree_host.h" | 12 #include "cc/test/fake_layer_tree_host.h" |
13 #include "cc/test/fake_layer_tree_host_impl.h" | 13 #include "cc/test/fake_layer_tree_host_impl.h" |
14 #include "cc/test/test_shared_bitmap_manager.h" | |
15 #include "cc/test/test_task_graph_runner.h" | 14 #include "cc/test/test_task_graph_runner.h" |
16 #include "cc/trees/layer_tree_impl.h" | 15 #include "cc/trees/layer_tree_impl.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
18 | 17 |
19 namespace cc { | 18 namespace cc { |
20 namespace { | 19 namespace { |
21 | 20 |
22 // Layer version unit tests | 21 // Layer version unit tests |
23 | 22 |
24 TEST(LayerListIteratorTest, VerifyTraversalOrder) { | 23 TEST(LayerListIteratorTest, VerifyTraversalOrder) { |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 EXPECT_EQ(it, end); | 190 EXPECT_EQ(it, end); |
192 ++it; | 191 ++it; |
193 EXPECT_EQ(it, end); | 192 EXPECT_EQ(it, end); |
194 } | 193 } |
195 | 194 |
196 // LayerImpl version unit tests | 195 // LayerImpl version unit tests |
197 | 196 |
198 TEST(LayerListIteratorTest, VerifyTraversalOrderImpl) { | 197 TEST(LayerListIteratorTest, VerifyTraversalOrderImpl) { |
199 // Unfortunate preamble. | 198 // Unfortunate preamble. |
200 FakeImplTaskRunnerProvider task_runner_provider; | 199 FakeImplTaskRunnerProvider task_runner_provider; |
201 TestSharedBitmapManager shared_bitmap_manager; | |
202 TestTaskGraphRunner task_graph_runner; | 200 TestTaskGraphRunner task_graph_runner; |
203 std::unique_ptr<CompositorFrameSink> compositor_frame_sink = | 201 std::unique_ptr<CompositorFrameSink> compositor_frame_sink = |
204 FakeCompositorFrameSink::Create3d(); | 202 FakeCompositorFrameSink::Create3d(); |
205 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, | 203 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner); |
206 &task_graph_runner); | |
207 host_impl.SetVisible(true); | 204 host_impl.SetVisible(true); |
208 EXPECT_TRUE(host_impl.InitializeRenderer(compositor_frame_sink.get())); | 205 EXPECT_TRUE(host_impl.InitializeRenderer(compositor_frame_sink.get())); |
209 | 206 |
210 // This test constructs the following tree. | 207 // This test constructs the following tree. |
211 // 1 | 208 // 1 |
212 // +-2 | 209 // +-2 |
213 // | +-3 | 210 // | +-3 |
214 // | +-4 | 211 // | +-4 |
215 // + 5 | 212 // + 5 |
216 // +-6 | 213 // +-6 |
(...skipping 29 matching lines...) Expand all Loading... |
246 int i = 1; | 243 int i = 1; |
247 for (auto* layer : *host_impl.active_tree()) { | 244 for (auto* layer : *host_impl.active_tree()) { |
248 EXPECT_EQ(i++, layer->id()); | 245 EXPECT_EQ(i++, layer->id()); |
249 } | 246 } |
250 EXPECT_EQ(8, i); | 247 EXPECT_EQ(8, i); |
251 } | 248 } |
252 | 249 |
253 TEST(LayerListIteratorTest, VerifySingleLayerImpl) { | 250 TEST(LayerListIteratorTest, VerifySingleLayerImpl) { |
254 // Unfortunate preamble. | 251 // Unfortunate preamble. |
255 FakeImplTaskRunnerProvider task_runner_provider; | 252 FakeImplTaskRunnerProvider task_runner_provider; |
256 TestSharedBitmapManager shared_bitmap_manager; | |
257 TestTaskGraphRunner task_graph_runner; | 253 TestTaskGraphRunner task_graph_runner; |
258 std::unique_ptr<CompositorFrameSink> compositor_frame_sink = | 254 std::unique_ptr<CompositorFrameSink> compositor_frame_sink = |
259 FakeCompositorFrameSink::Create3d(); | 255 FakeCompositorFrameSink::Create3d(); |
260 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, | 256 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner); |
261 &task_graph_runner); | |
262 host_impl.SetVisible(true); | 257 host_impl.SetVisible(true); |
263 EXPECT_TRUE(host_impl.InitializeRenderer(compositor_frame_sink.get())); | 258 EXPECT_TRUE(host_impl.InitializeRenderer(compositor_frame_sink.get())); |
264 | 259 |
265 // This test constructs a tree consisting of a single layer. | 260 // This test constructs a tree consisting of a single layer. |
266 std::unique_ptr<LayerImpl> layer1 = | 261 std::unique_ptr<LayerImpl> layer1 = |
267 LayerImpl::Create(host_impl.active_tree(), 1); | 262 LayerImpl::Create(host_impl.active_tree(), 1); |
268 host_impl.active_tree()->SetRootLayerForTesting(std::move(layer1)); | 263 host_impl.active_tree()->SetRootLayerForTesting(std::move(layer1)); |
269 host_impl.active_tree()->BuildLayerListForTesting(); | 264 host_impl.active_tree()->BuildLayerListForTesting(); |
270 | 265 |
271 int i = 1; | 266 int i = 1; |
(...skipping 11 matching lines...) Expand all Loading... |
283 LayerListIterator<LayerImpl> end(nullptr); | 278 LayerListIterator<LayerImpl> end(nullptr); |
284 | 279 |
285 EXPECT_EQ(it, end); | 280 EXPECT_EQ(it, end); |
286 ++it; | 281 ++it; |
287 EXPECT_EQ(it, end); | 282 EXPECT_EQ(it, end); |
288 } | 283 } |
289 | 284 |
290 TEST(LayerListReverseIteratorTest, VerifyTraversalOrderImpl) { | 285 TEST(LayerListReverseIteratorTest, VerifyTraversalOrderImpl) { |
291 // Unfortunate preamble. | 286 // Unfortunate preamble. |
292 FakeImplTaskRunnerProvider task_runner_provider; | 287 FakeImplTaskRunnerProvider task_runner_provider; |
293 TestSharedBitmapManager shared_bitmap_manager; | |
294 TestTaskGraphRunner task_graph_runner; | 288 TestTaskGraphRunner task_graph_runner; |
295 std::unique_ptr<CompositorFrameSink> compositor_frame_sink = | 289 std::unique_ptr<CompositorFrameSink> compositor_frame_sink = |
296 FakeCompositorFrameSink::Create3d(); | 290 FakeCompositorFrameSink::Create3d(); |
297 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, | 291 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner); |
298 &task_graph_runner); | |
299 host_impl.SetVisible(true); | 292 host_impl.SetVisible(true); |
300 EXPECT_TRUE(host_impl.InitializeRenderer(compositor_frame_sink.get())); | 293 EXPECT_TRUE(host_impl.InitializeRenderer(compositor_frame_sink.get())); |
301 | 294 |
302 // This test constructs the following tree. | 295 // This test constructs the following tree. |
303 // 1 | 296 // 1 |
304 // +-2 | 297 // +-2 |
305 // | +-3 | 298 // | +-3 |
306 // | +-4 | 299 // | +-4 |
307 // + 5 | 300 // + 5 |
308 // +-6 | 301 // +-6 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 for (auto* layer : base::Reversed(*host_impl.active_tree())) { | 333 for (auto* layer : base::Reversed(*host_impl.active_tree())) { |
341 EXPECT_EQ(i--, layer->id()); | 334 EXPECT_EQ(i--, layer->id()); |
342 } | 335 } |
343 | 336 |
344 EXPECT_EQ(0, i); | 337 EXPECT_EQ(0, i); |
345 } | 338 } |
346 | 339 |
347 TEST(LayerListReverseIteratorTest, VerifySingleLayerImpl) { | 340 TEST(LayerListReverseIteratorTest, VerifySingleLayerImpl) { |
348 // Unfortunate preamble. | 341 // Unfortunate preamble. |
349 FakeImplTaskRunnerProvider task_runner_provider; | 342 FakeImplTaskRunnerProvider task_runner_provider; |
350 TestSharedBitmapManager shared_bitmap_manager; | |
351 TestTaskGraphRunner task_graph_runner; | 343 TestTaskGraphRunner task_graph_runner; |
352 std::unique_ptr<CompositorFrameSink> compositor_frame_sink = | 344 std::unique_ptr<CompositorFrameSink> compositor_frame_sink = |
353 FakeCompositorFrameSink::Create3d(); | 345 FakeCompositorFrameSink::Create3d(); |
354 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, | 346 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner); |
355 &task_graph_runner); | |
356 host_impl.SetVisible(true); | 347 host_impl.SetVisible(true); |
357 EXPECT_TRUE(host_impl.InitializeRenderer(compositor_frame_sink.get())); | 348 EXPECT_TRUE(host_impl.InitializeRenderer(compositor_frame_sink.get())); |
358 | 349 |
359 // This test constructs a tree consisting of a single layer. | 350 // This test constructs a tree consisting of a single layer. |
360 std::unique_ptr<LayerImpl> layer1 = | 351 std::unique_ptr<LayerImpl> layer1 = |
361 LayerImpl::Create(host_impl.active_tree(), 1); | 352 LayerImpl::Create(host_impl.active_tree(), 1); |
362 host_impl.active_tree()->SetRootLayerForTesting(std::move(layer1)); | 353 host_impl.active_tree()->SetRootLayerForTesting(std::move(layer1)); |
363 host_impl.active_tree()->BuildLayerListForTesting(); | 354 host_impl.active_tree()->BuildLayerListForTesting(); |
364 | 355 |
365 int i = 1; | 356 int i = 1; |
(...skipping 10 matching lines...) Expand all Loading... |
376 LayerListReverseIterator<LayerImpl> it(nullptr); | 367 LayerListReverseIterator<LayerImpl> it(nullptr); |
377 LayerListReverseIterator<LayerImpl> end(nullptr); | 368 LayerListReverseIterator<LayerImpl> end(nullptr); |
378 | 369 |
379 EXPECT_EQ(it, end); | 370 EXPECT_EQ(it, end); |
380 ++it; | 371 ++it; |
381 EXPECT_EQ(it, end); | 372 EXPECT_EQ(it, end); |
382 } | 373 } |
383 | 374 |
384 } // namespace | 375 } // namespace |
385 } // namespace cc | 376 } // namespace cc |
OLD | NEW |