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

Side by Side Diff: cc/trees/tree_synchronizer_unittest.cc

Issue 640203002: [C++11 Allowed Features] Declares a type-safe null pointer converting from NULL to nullptr [part-… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: format fix. Created 6 years, 2 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 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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/trees/tree_synchronizer.h" 5 #include "cc/trees/tree_synchronizer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 23 matching lines...) Expand all
34 if (layer_impl_destruction_list_) 34 if (layer_impl_destruction_list_)
35 layer_impl_destruction_list_->push_back(id()); 35 layer_impl_destruction_list_->push_back(id());
36 } 36 }
37 37
38 void SetLayerImplDestructionList(std::vector<int>* list) { 38 void SetLayerImplDestructionList(std::vector<int>* list) {
39 layer_impl_destruction_list_ = list; 39 layer_impl_destruction_list_ = list;
40 } 40 }
41 41
42 private: 42 private:
43 MockLayerImpl(LayerTreeImpl* tree_impl, int layer_id) 43 MockLayerImpl(LayerTreeImpl* tree_impl, int layer_id)
44 : LayerImpl(tree_impl, layer_id), 44 : LayerImpl(tree_impl, layer_id), layer_impl_destruction_list_(nullptr) {}
45 layer_impl_destruction_list_(NULL) {}
46 45
47 std::vector<int>* layer_impl_destruction_list_; 46 std::vector<int>* layer_impl_destruction_list_;
48 }; 47 };
49 48
50 class MockLayer : public Layer { 49 class MockLayer : public Layer {
51 public: 50 public:
52 static scoped_refptr<MockLayer> Create( 51 static scoped_refptr<MockLayer> Create(
53 std::vector<int>* layer_impl_destruction_list) { 52 std::vector<int>* layer_impl_destruction_list) {
54 return make_scoped_refptr(new MockLayer(layer_impl_destruction_list)); 53 return make_scoped_refptr(new MockLayer(layer_impl_destruction_list));
55 } 54 }
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 194
196 protected: 195 protected:
197 FakeLayerTreeHostClient client_; 196 FakeLayerTreeHostClient client_;
198 scoped_ptr<FakeLayerTreeHost> host_; 197 scoped_ptr<FakeLayerTreeHost> host_;
199 }; 198 };
200 199
201 // Attempts to synchronizes a null tree. This should not crash, and should 200 // Attempts to synchronizes a null tree. This should not crash, and should
202 // return a null tree. 201 // return a null tree.
203 TEST_F(TreeSynchronizerTest, SyncNullTree) { 202 TEST_F(TreeSynchronizerTest, SyncNullTree) {
204 scoped_ptr<LayerImpl> layer_impl_tree_root = 203 scoped_ptr<LayerImpl> layer_impl_tree_root =
205 TreeSynchronizer::SynchronizeTrees(static_cast<Layer*>(NULL), 204 TreeSynchronizer::SynchronizeTrees(static_cast<Layer*>(nullptr),
danakj 2014/10/10 16:47:12 static cast isn't needed, remove that please
206 scoped_ptr<LayerImpl>(), 205 scoped_ptr<LayerImpl>(),
207 host_->active_tree()); 206 host_->active_tree());
208 207
209 EXPECT_TRUE(!layer_impl_tree_root.get()); 208 EXPECT_TRUE(!layer_impl_tree_root.get());
210 } 209 }
211 210
212 // Constructs a very simple tree and synchronizes it without trying to reuse any 211 // Constructs a very simple tree and synchronizes it without trying to reuse any
213 // preexisting layers. 212 // preexisting layers.
214 TEST_F(TreeSynchronizerTest, SyncSimpleTreeFromEmpty) { 213 TEST_F(TreeSynchronizerTest, SyncSimpleTreeFromEmpty) {
215 scoped_refptr<Layer> layer_tree_root = Layer::Create(); 214 scoped_refptr<Layer> layer_tree_root = Layer::Create();
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 scoped_ptr<LayerImpl> layer_impl_tree_root = 518 scoped_ptr<LayerImpl> layer_impl_tree_root =
520 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(), 519 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(),
521 scoped_ptr<LayerImpl>(), 520 scoped_ptr<LayerImpl>(),
522 host_->active_tree()); 521 host_->active_tree());
523 522
524 ExpectTreesAreIdentical(layer_tree_root.get(), 523 ExpectTreesAreIdentical(layer_tree_root.get(),
525 layer_impl_tree_root.get(), 524 layer_impl_tree_root.get(),
526 host_->active_tree()); 525 host_->active_tree());
527 526
528 // Remove the mask layer. 527 // Remove the mask layer.
529 layer_tree_root->children()[0]->SetMaskLayer(NULL); 528 layer_tree_root->children()[0]->SetMaskLayer(nullptr);
530 layer_impl_tree_root = 529 layer_impl_tree_root =
531 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(), 530 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(),
532 layer_impl_tree_root.Pass(), 531 layer_impl_tree_root.Pass(),
533 host_->active_tree()); 532 host_->active_tree());
534 ExpectTreesAreIdentical(layer_tree_root.get(), 533 ExpectTreesAreIdentical(layer_tree_root.get(),
535 layer_impl_tree_root.get(), 534 layer_impl_tree_root.get(),
536 host_->active_tree()); 535 host_->active_tree());
537 536
538 // Remove the replica layer. 537 // Remove the replica layer.
539 layer_tree_root->children()[1]->SetReplicaLayer(NULL); 538 layer_tree_root->children()[1]->SetReplicaLayer(nullptr);
540 layer_impl_tree_root = 539 layer_impl_tree_root =
541 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(), 540 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(),
542 layer_impl_tree_root.Pass(), 541 layer_impl_tree_root.Pass(),
543 host_->active_tree()); 542 host_->active_tree());
544 ExpectTreesAreIdentical(layer_tree_root.get(), 543 ExpectTreesAreIdentical(layer_tree_root.get(),
545 layer_impl_tree_root.get(), 544 layer_impl_tree_root.get(),
546 host_->active_tree()); 545 host_->active_tree());
547 546
548 // Remove the replica mask. 547 // Remove the replica mask.
549 replica_layer_with_mask->SetMaskLayer(NULL); 548 replica_layer_with_mask->SetMaskLayer(nullptr);
550 layer_impl_tree_root = 549 layer_impl_tree_root =
551 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(), 550 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(),
552 layer_impl_tree_root.Pass(), 551 layer_impl_tree_root.Pass(),
553 host_->active_tree()); 552 host_->active_tree());
554 ExpectTreesAreIdentical(layer_tree_root.get(), 553 ExpectTreesAreIdentical(layer_tree_root.get(),
555 layer_impl_tree_root.get(), 554 layer_impl_tree_root.get(),
556 host_->active_tree()); 555 host_->active_tree());
557 } 556 }
558 557
559 TEST_F(TreeSynchronizerTest, SynchronizeAnimations) { 558 TEST_F(TreeSynchronizerTest, SynchronizeAnimations) {
560 LayerTreeSettings settings; 559 LayerTreeSettings settings;
561 FakeProxy proxy; 560 FakeProxy proxy;
562 DebugScopedSetImplThread impl(&proxy); 561 DebugScopedSetImplThread impl(&proxy);
563 FakeRenderingStatsInstrumentation stats_instrumentation; 562 FakeRenderingStatsInstrumentation stats_instrumentation;
564 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( 563 scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
565 new TestSharedBitmapManager()); 564 new TestSharedBitmapManager());
566 scoped_ptr<LayerTreeHostImpl> host_impl = 565 scoped_ptr<LayerTreeHostImpl> host_impl =
567 LayerTreeHostImpl::Create(settings, 566 LayerTreeHostImpl::Create(settings,
568 NULL, 567 nullptr,
569 &proxy, 568 &proxy,
570 &stats_instrumentation, 569 &stats_instrumentation,
571 shared_bitmap_manager.get(), 570 shared_bitmap_manager.get(),
572 0); 571 0);
573 572
574 scoped_refptr<Layer> layer_tree_root = Layer::Create(); 573 scoped_refptr<Layer> layer_tree_root = Layer::Create();
575 host_->SetRootLayer(layer_tree_root); 574 host_->SetRootLayer(layer_tree_root);
576 575
577 layer_tree_root->SetLayerAnimationControllerForTest( 576 layer_tree_root->SetLayerAnimationControllerForTest(
578 FakeLayerAnimationController::Create()); 577 FakeLayerAnimationController::Create());
(...skipping 18 matching lines...) Expand all
597 596
598 TEST_F(TreeSynchronizerTest, SynchronizeScrollParent) { 597 TEST_F(TreeSynchronizerTest, SynchronizeScrollParent) {
599 LayerTreeSettings settings; 598 LayerTreeSettings settings;
600 FakeProxy proxy; 599 FakeProxy proxy;
601 DebugScopedSetImplThread impl(&proxy); 600 DebugScopedSetImplThread impl(&proxy);
602 FakeRenderingStatsInstrumentation stats_instrumentation; 601 FakeRenderingStatsInstrumentation stats_instrumentation;
603 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( 602 scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
604 new TestSharedBitmapManager()); 603 new TestSharedBitmapManager());
605 scoped_ptr<LayerTreeHostImpl> host_impl = 604 scoped_ptr<LayerTreeHostImpl> host_impl =
606 LayerTreeHostImpl::Create(settings, 605 LayerTreeHostImpl::Create(settings,
607 NULL, 606 nullptr,
608 &proxy, 607 &proxy,
609 &stats_instrumentation, 608 &stats_instrumentation,
610 shared_bitmap_manager.get(), 609 shared_bitmap_manager.get(),
611 0); 610 0);
612 611
613 scoped_refptr<Layer> layer_tree_root = Layer::Create(); 612 scoped_refptr<Layer> layer_tree_root = Layer::Create();
614 scoped_refptr<Layer> scroll_parent = Layer::Create(); 613 scoped_refptr<Layer> scroll_parent = Layer::Create();
615 layer_tree_root->AddChild(scroll_parent); 614 layer_tree_root->AddChild(scroll_parent);
616 layer_tree_root->AddChild(Layer::Create()); 615 layer_tree_root->AddChild(Layer::Create());
617 layer_tree_root->AddChild(Layer::Create()); 616 layer_tree_root->AddChild(Layer::Create());
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 669
671 TEST_F(TreeSynchronizerTest, SynchronizeClipParent) { 670 TEST_F(TreeSynchronizerTest, SynchronizeClipParent) {
672 LayerTreeSettings settings; 671 LayerTreeSettings settings;
673 FakeProxy proxy; 672 FakeProxy proxy;
674 DebugScopedSetImplThread impl(&proxy); 673 DebugScopedSetImplThread impl(&proxy);
675 FakeRenderingStatsInstrumentation stats_instrumentation; 674 FakeRenderingStatsInstrumentation stats_instrumentation;
676 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( 675 scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
677 new TestSharedBitmapManager()); 676 new TestSharedBitmapManager());
678 scoped_ptr<LayerTreeHostImpl> host_impl = 677 scoped_ptr<LayerTreeHostImpl> host_impl =
679 LayerTreeHostImpl::Create(settings, 678 LayerTreeHostImpl::Create(settings,
680 NULL, 679 nullptr,
681 &proxy, 680 &proxy,
682 &stats_instrumentation, 681 &stats_instrumentation,
683 shared_bitmap_manager.get(), 682 shared_bitmap_manager.get(),
684 0); 683 0);
685 684
686 scoped_refptr<Layer> layer_tree_root = Layer::Create(); 685 scoped_refptr<Layer> layer_tree_root = Layer::Create();
687 scoped_refptr<Layer> clip_parent = Layer::Create(); 686 scoped_refptr<Layer> clip_parent = Layer::Create();
688 scoped_refptr<Layer> intervening = Layer::Create(); 687 scoped_refptr<Layer> intervening = Layer::Create();
689 scoped_refptr<Layer> clip_child1 = Layer::Create(); 688 scoped_refptr<Layer> clip_child1 = Layer::Create();
690 scoped_refptr<Layer> clip_child2 = Layer::Create(); 689 scoped_refptr<Layer> clip_child2 = Layer::Create();
(...skipping 13 matching lines...) Expand all
704 scoped_ptr<LayerImpl>(), 703 scoped_ptr<LayerImpl>(),
705 host_impl->active_tree()); 704 host_impl->active_tree());
706 TreeSynchronizer::PushProperties(layer_tree_root.get(), 705 TreeSynchronizer::PushProperties(layer_tree_root.get(),
707 layer_impl_tree_root.get()); 706 layer_impl_tree_root.get());
708 ExpectTreesAreIdentical(layer_tree_root.get(), 707 ExpectTreesAreIdentical(layer_tree_root.get(),
709 layer_impl_tree_root.get(), 708 layer_impl_tree_root.get(),
710 host_impl->active_tree()); 709 host_impl->active_tree());
711 710
712 // Remove the first clip child. 711 // Remove the first clip child.
713 clip_child1->RemoveFromParent(); 712 clip_child1->RemoveFromParent();
714 clip_child1 = NULL; 713 clip_child1 = nullptr;
715 714
716 layer_impl_tree_root = 715 layer_impl_tree_root =
717 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(), 716 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(),
718 layer_impl_tree_root.Pass(), 717 layer_impl_tree_root.Pass(),
719 host_impl->active_tree()); 718 host_impl->active_tree());
720 TreeSynchronizer::PushProperties(layer_tree_root.get(), 719 TreeSynchronizer::PushProperties(layer_tree_root.get(),
721 layer_impl_tree_root.get()); 720 layer_impl_tree_root.get());
722 ExpectTreesAreIdentical(layer_tree_root.get(), 721 ExpectTreesAreIdentical(layer_tree_root.get(),
723 layer_impl_tree_root.get(), 722 layer_impl_tree_root.get(),
724 host_impl->active_tree()); 723 host_impl->active_tree());
725 724
726 // Add an additional clip child. 725 // Add an additional clip child.
727 scoped_refptr<Layer> additional_clip_child = Layer::Create(); 726 scoped_refptr<Layer> additional_clip_child = Layer::Create();
728 intervening->AddChild(additional_clip_child); 727 intervening->AddChild(additional_clip_child);
729 additional_clip_child->SetClipParent(clip_parent.get()); 728 additional_clip_child->SetClipParent(clip_parent.get());
730 layer_impl_tree_root = 729 layer_impl_tree_root =
731 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(), 730 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(),
732 layer_impl_tree_root.Pass(), 731 layer_impl_tree_root.Pass(),
733 host_impl->active_tree()); 732 host_impl->active_tree());
734 TreeSynchronizer::PushProperties(layer_tree_root.get(), 733 TreeSynchronizer::PushProperties(layer_tree_root.get(),
735 layer_impl_tree_root.get()); 734 layer_impl_tree_root.get());
736 ExpectTreesAreIdentical(layer_tree_root.get(), 735 ExpectTreesAreIdentical(layer_tree_root.get(),
737 layer_impl_tree_root.get(), 736 layer_impl_tree_root.get(),
738 host_impl->active_tree()); 737 host_impl->active_tree());
739 738
740 // Remove the nearest clipping ancestor. 739 // Remove the nearest clipping ancestor.
741 clip_parent->RemoveFromParent(); 740 clip_parent->RemoveFromParent();
742 clip_parent = NULL; 741 clip_parent = nullptr;
743 layer_impl_tree_root = 742 layer_impl_tree_root =
744 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(), 743 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(),
745 layer_impl_tree_root.Pass(), 744 layer_impl_tree_root.Pass(),
746 host_impl->active_tree()); 745 host_impl->active_tree());
747 TreeSynchronizer::PushProperties(layer_tree_root.get(), 746 TreeSynchronizer::PushProperties(layer_tree_root.get(),
748 layer_impl_tree_root.get()); 747 layer_impl_tree_root.get());
749 ExpectTreesAreIdentical(layer_tree_root.get(), 748 ExpectTreesAreIdentical(layer_tree_root.get(),
750 layer_impl_tree_root.get(), 749 layer_impl_tree_root.get(),
751 host_impl->active_tree()); 750 host_impl->active_tree());
752 751
753 // The clip children should have been unhooked. 752 // The clip children should have been unhooked.
754 EXPECT_EQ(2u, intervening->children().size()); 753 EXPECT_EQ(2u, intervening->children().size());
755 EXPECT_FALSE(clip_child2->clip_parent()); 754 EXPECT_FALSE(clip_child2->clip_parent());
756 EXPECT_FALSE(additional_clip_child->clip_parent()); 755 EXPECT_FALSE(additional_clip_child->clip_parent());
757 } 756 }
758 757
759 } // namespace 758 } // namespace
760 } // namespace cc 759 } // namespace cc
OLDNEW
« cc/trees/layer_tree_host_impl.h ('K') | « cc/trees/tree_synchronizer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698