Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(108)

Side by Side Diff: cc/layers/layer_list_iterator_unittest.cc

Issue 2337913003: Fork cc::OutputSurface into cc::CompositorFrameSink. (Closed)
Patch Set: cfsfork: rebase Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_impl_task_runner_provider.h" 11 #include "cc/test/fake_impl_task_runner_provider.h"
11 #include "cc/test/fake_layer_tree_host.h" 12 #include "cc/test/fake_layer_tree_host.h"
12 #include "cc/test/fake_layer_tree_host_impl.h" 13 #include "cc/test/fake_layer_tree_host_impl.h"
13 #include "cc/test/fake_output_surface.h"
14 #include "cc/test/test_shared_bitmap_manager.h" 14 #include "cc/test/test_shared_bitmap_manager.h"
15 #include "cc/test/test_task_graph_runner.h" 15 #include "cc/test/test_task_graph_runner.h"
16 #include "cc/trees/layer_tree_impl.h" 16 #include "cc/trees/layer_tree_impl.h"
17 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
18 18
19 namespace cc { 19 namespace cc {
20 namespace { 20 namespace {
21 21
22 // Layer version unit tests 22 // Layer version unit tests
23 23
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 EXPECT_EQ(it, end); 193 EXPECT_EQ(it, end);
194 } 194 }
195 195
196 // LayerImpl version unit tests 196 // LayerImpl version unit tests
197 197
198 TEST(LayerListIteratorTest, VerifyTraversalOrderImpl) { 198 TEST(LayerListIteratorTest, VerifyTraversalOrderImpl) {
199 // Unfortunate preamble. 199 // Unfortunate preamble.
200 FakeImplTaskRunnerProvider task_runner_provider; 200 FakeImplTaskRunnerProvider task_runner_provider;
201 TestSharedBitmapManager shared_bitmap_manager; 201 TestSharedBitmapManager shared_bitmap_manager;
202 TestTaskGraphRunner task_graph_runner; 202 TestTaskGraphRunner task_graph_runner;
203 std::unique_ptr<OutputSurface> output_surface = 203 std::unique_ptr<CompositorFrameSink> compositor_frame_sink =
204 FakeOutputSurface::CreateDelegating3d(); 204 FakeCompositorFrameSink::Create3d();
205 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, 205 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager,
206 &task_graph_runner); 206 &task_graph_runner);
207 host_impl.SetVisible(true); 207 host_impl.SetVisible(true);
208 EXPECT_TRUE(host_impl.InitializeRenderer(output_surface.get())); 208 EXPECT_TRUE(host_impl.InitializeRenderer(compositor_frame_sink.get()));
209 209
210 // This test constructs the following tree. 210 // This test constructs the following tree.
211 // 1 211 // 1
212 // +-2 212 // +-2
213 // | +-3 213 // | +-3
214 // | +-4 214 // | +-4
215 // + 5 215 // + 5
216 // +-6 216 // +-6
217 // +-7 217 // +-7
218 // We expect to visit all seven layers in that order. 218 // We expect to visit all seven layers in that order.
(...skipping 29 matching lines...) Expand all
248 EXPECT_EQ(i++, layer->id()); 248 EXPECT_EQ(i++, layer->id());
249 } 249 }
250 EXPECT_EQ(8, i); 250 EXPECT_EQ(8, i);
251 } 251 }
252 252
253 TEST(LayerListIteratorTest, VerifySingleLayerImpl) { 253 TEST(LayerListIteratorTest, VerifySingleLayerImpl) {
254 // Unfortunate preamble. 254 // Unfortunate preamble.
255 FakeImplTaskRunnerProvider task_runner_provider; 255 FakeImplTaskRunnerProvider task_runner_provider;
256 TestSharedBitmapManager shared_bitmap_manager; 256 TestSharedBitmapManager shared_bitmap_manager;
257 TestTaskGraphRunner task_graph_runner; 257 TestTaskGraphRunner task_graph_runner;
258 std::unique_ptr<OutputSurface> output_surface = 258 std::unique_ptr<CompositorFrameSink> compositor_frame_sink =
259 FakeOutputSurface::CreateDelegating3d(); 259 FakeCompositorFrameSink::Create3d();
260 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, 260 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager,
261 &task_graph_runner); 261 &task_graph_runner);
262 host_impl.SetVisible(true); 262 host_impl.SetVisible(true);
263 EXPECT_TRUE(host_impl.InitializeRenderer(output_surface.get())); 263 EXPECT_TRUE(host_impl.InitializeRenderer(compositor_frame_sink.get()));
264 264
265 // This test constructs a tree consisting of a single layer. 265 // This test constructs a tree consisting of a single layer.
266 std::unique_ptr<LayerImpl> layer1 = 266 std::unique_ptr<LayerImpl> layer1 =
267 LayerImpl::Create(host_impl.active_tree(), 1); 267 LayerImpl::Create(host_impl.active_tree(), 1);
268 host_impl.active_tree()->SetRootLayerForTesting(std::move(layer1)); 268 host_impl.active_tree()->SetRootLayerForTesting(std::move(layer1));
269 host_impl.active_tree()->BuildLayerListForTesting(); 269 host_impl.active_tree()->BuildLayerListForTesting();
270 270
271 int i = 1; 271 int i = 1;
272 for (auto* layer : *host_impl.active_tree()) { 272 for (auto* layer : *host_impl.active_tree()) {
273 EXPECT_EQ(i++, layer->id()); 273 EXPECT_EQ(i++, layer->id());
(...skipping 11 matching lines...) Expand all
285 EXPECT_EQ(it, end); 285 EXPECT_EQ(it, end);
286 ++it; 286 ++it;
287 EXPECT_EQ(it, end); 287 EXPECT_EQ(it, end);
288 } 288 }
289 289
290 TEST(LayerListReverseIteratorTest, VerifyTraversalOrderImpl) { 290 TEST(LayerListReverseIteratorTest, VerifyTraversalOrderImpl) {
291 // Unfortunate preamble. 291 // Unfortunate preamble.
292 FakeImplTaskRunnerProvider task_runner_provider; 292 FakeImplTaskRunnerProvider task_runner_provider;
293 TestSharedBitmapManager shared_bitmap_manager; 293 TestSharedBitmapManager shared_bitmap_manager;
294 TestTaskGraphRunner task_graph_runner; 294 TestTaskGraphRunner task_graph_runner;
295 std::unique_ptr<OutputSurface> output_surface = 295 std::unique_ptr<CompositorFrameSink> compositor_frame_sink =
296 FakeOutputSurface::CreateDelegating3d(); 296 FakeCompositorFrameSink::Create3d();
297 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, 297 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager,
298 &task_graph_runner); 298 &task_graph_runner);
299 host_impl.SetVisible(true); 299 host_impl.SetVisible(true);
300 EXPECT_TRUE(host_impl.InitializeRenderer(output_surface.get())); 300 EXPECT_TRUE(host_impl.InitializeRenderer(compositor_frame_sink.get()));
301 301
302 // This test constructs the following tree. 302 // This test constructs the following tree.
303 // 1 303 // 1
304 // +-2 304 // +-2
305 // | +-3 305 // | +-3
306 // | +-4 306 // | +-4
307 // + 5 307 // + 5
308 // +-6 308 // +-6
309 // +-7 309 // +-7
310 // We expect to visit all seven layers in reverse order. 310 // We expect to visit all seven layers in reverse order.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 } 342 }
343 343
344 EXPECT_EQ(0, i); 344 EXPECT_EQ(0, i);
345 } 345 }
346 346
347 TEST(LayerListReverseIteratorTest, VerifySingleLayerImpl) { 347 TEST(LayerListReverseIteratorTest, VerifySingleLayerImpl) {
348 // Unfortunate preamble. 348 // Unfortunate preamble.
349 FakeImplTaskRunnerProvider task_runner_provider; 349 FakeImplTaskRunnerProvider task_runner_provider;
350 TestSharedBitmapManager shared_bitmap_manager; 350 TestSharedBitmapManager shared_bitmap_manager;
351 TestTaskGraphRunner task_graph_runner; 351 TestTaskGraphRunner task_graph_runner;
352 std::unique_ptr<OutputSurface> output_surface = 352 std::unique_ptr<CompositorFrameSink> compositor_frame_sink =
353 FakeOutputSurface::CreateDelegating3d(); 353 FakeCompositorFrameSink::Create3d();
354 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, 354 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager,
355 &task_graph_runner); 355 &task_graph_runner);
356 host_impl.SetVisible(true); 356 host_impl.SetVisible(true);
357 EXPECT_TRUE(host_impl.InitializeRenderer(output_surface.get())); 357 EXPECT_TRUE(host_impl.InitializeRenderer(compositor_frame_sink.get()));
358 358
359 // This test constructs a tree consisting of a single layer. 359 // This test constructs a tree consisting of a single layer.
360 std::unique_ptr<LayerImpl> layer1 = 360 std::unique_ptr<LayerImpl> layer1 =
361 LayerImpl::Create(host_impl.active_tree(), 1); 361 LayerImpl::Create(host_impl.active_tree(), 1);
362 host_impl.active_tree()->SetRootLayerForTesting(std::move(layer1)); 362 host_impl.active_tree()->SetRootLayerForTesting(std::move(layer1));
363 host_impl.active_tree()->BuildLayerListForTesting(); 363 host_impl.active_tree()->BuildLayerListForTesting();
364 364
365 int i = 1; 365 int i = 1;
366 for (auto* layer : base::Reversed(*host_impl.active_tree())) { 366 for (auto* layer : base::Reversed(*host_impl.active_tree())) {
367 EXPECT_EQ(i--, layer->id()); 367 EXPECT_EQ(i--, layer->id());
368 } 368 }
369 EXPECT_EQ(0, i); 369 EXPECT_EQ(0, i);
370 } 370 }
371 371
372 TEST(LayerListReverseIteratorTest, VerifyNullFirstLayerImpl) { 372 TEST(LayerListReverseIteratorTest, VerifyNullFirstLayerImpl) {
373 // Ensures that if an iterator is constructed with a nullptr, that it can be 373 // Ensures that if an iterator is constructed with a nullptr, that it can be
374 // iterated without issue and that it remains equal to any other 374 // iterated without issue and that it remains equal to any other
375 // null-initialized iterator. 375 // null-initialized iterator.
376 LayerListReverseIterator<LayerImpl> it(nullptr); 376 LayerListReverseIterator<LayerImpl> it(nullptr);
377 LayerListReverseIterator<LayerImpl> end(nullptr); 377 LayerListReverseIterator<LayerImpl> end(nullptr);
378 378
379 EXPECT_EQ(it, end); 379 EXPECT_EQ(it, end);
380 ++it; 380 ++it;
381 EXPECT_EQ(it, end); 381 EXPECT_EQ(it, end);
382 } 382 }
383 383
384 } // namespace 384 } // namespace
385 } // namespace cc 385 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698