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

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

Issue 1782433002: CC Animation: Erase old animation system. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@erasetests
Patch Set: Remove vtbl in LayerAnimationController. Fix formatting. Created 4 years, 9 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
« no previous file with comments | « cc/trees/layer_tree_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <set> 10 #include <set>
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 private: 75 private:
76 explicit MockLayer(const LayerSettings& settings, 76 explicit MockLayer(const LayerSettings& settings,
77 std::vector<int>* layer_impl_destruction_list) 77 std::vector<int>* layer_impl_destruction_list)
78 : Layer(settings), 78 : Layer(settings),
79 layer_impl_destruction_list_(layer_impl_destruction_list) {} 79 layer_impl_destruction_list_(layer_impl_destruction_list) {}
80 ~MockLayer() override {} 80 ~MockLayer() override {}
81 81
82 std::vector<int>* layer_impl_destruction_list_; 82 std::vector<int>* layer_impl_destruction_list_;
83 }; 83 };
84 84
85 class FakeLayerAnimationController : public LayerAnimationController {
86 public:
87 static scoped_refptr<LayerAnimationController> Create() {
88 return static_cast<LayerAnimationController*>(
89 new FakeLayerAnimationController);
90 }
91
92 bool SynchronizedAnimations() const { return synchronized_animations_; }
93
94 private:
95 FakeLayerAnimationController()
96 : LayerAnimationController(1),
97 synchronized_animations_(false) {}
98
99 ~FakeLayerAnimationController() override {}
100
101 void PushAnimationUpdatesTo(
102 LayerAnimationController* controller_impl) override {
103 LayerAnimationController::PushAnimationUpdatesTo(controller_impl);
104 synchronized_animations_ = true;
105 }
106
107 bool synchronized_animations_;
108 };
109
110 void ExpectTreesAreIdentical(Layer* layer, 85 void ExpectTreesAreIdentical(Layer* layer,
111 LayerImpl* layer_impl, 86 LayerImpl* layer_impl,
112 LayerTreeImpl* tree_impl) { 87 LayerTreeImpl* tree_impl) {
113 ASSERT_TRUE(layer); 88 ASSERT_TRUE(layer);
114 ASSERT_TRUE(layer_impl); 89 ASSERT_TRUE(layer_impl);
115 90
116 EXPECT_EQ(layer->id(), layer_impl->id()); 91 EXPECT_EQ(layer->id(), layer_impl->id());
117 EXPECT_EQ(layer_impl->layer_tree_impl(), tree_impl); 92 EXPECT_EQ(layer_impl->layer_tree_impl(), tree_impl);
118 93
119 EXPECT_EQ(layer->non_fast_scrollable_region(), 94 EXPECT_EQ(layer->non_fast_scrollable_region(),
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 // Remove the replica mask. 558 // Remove the replica mask.
584 replica_layer_with_mask->SetMaskLayer(NULL); 559 replica_layer_with_mask->SetMaskLayer(NULL);
585 layer_impl_tree_root = TreeSynchronizer::SynchronizeTrees( 560 layer_impl_tree_root = TreeSynchronizer::SynchronizeTrees(
586 layer_tree_root.get(), std::move(layer_impl_tree_root), 561 layer_tree_root.get(), std::move(layer_impl_tree_root),
587 host_->active_tree()); 562 host_->active_tree());
588 ExpectTreesAreIdentical(layer_tree_root.get(), 563 ExpectTreesAreIdentical(layer_tree_root.get(),
589 layer_impl_tree_root.get(), 564 layer_impl_tree_root.get(),
590 host_->active_tree()); 565 host_->active_tree());
591 } 566 }
592 567
593 TEST_F(TreeSynchronizerTest, SynchronizeAnimations) {
594 LayerTreeSettingsForTreeSynchronizerTest settings;
595 // This test is meaningless in new use_compositor_animation_timelines mode.
596 // TODO(loyso): Delete FakeLayerAnimationController and related stuff.
597 if (settings.use_compositor_animation_timelines)
598 return;
599
600 FakeImplTaskRunnerProvider task_runner_provider;
601 FakeRenderingStatsInstrumentation stats_instrumentation;
602 TestSharedBitmapManager shared_bitmap_manager;
603 TestTaskGraphRunner task_graph_runner;
604 scoped_ptr<LayerTreeHostImpl> host_impl = LayerTreeHostImpl::Create(
605 settings, nullptr, &task_runner_provider, &stats_instrumentation,
606 &shared_bitmap_manager, nullptr, &task_graph_runner, 0);
607
608 scoped_refptr<Layer> layer_tree_root = Layer::Create(layer_settings_);
609 host_->SetRootLayer(layer_tree_root);
610
611 layer_tree_root->SetLayerAnimationControllerForTest(
612 FakeLayerAnimationController::Create());
613
614 EXPECT_FALSE(static_cast<FakeLayerAnimationController*>(
615 layer_tree_root->layer_animation_controller())->SynchronizedAnimations());
616
617 scoped_ptr<LayerImpl> layer_impl_tree_root =
618 TreeSynchronizer::SynchronizeTrees(
619 layer_tree_root.get(), nullptr, host_->active_tree());
620 TreeSynchronizer::PushProperties(layer_tree_root.get(),
621 layer_impl_tree_root.get());
622 layer_impl_tree_root = TreeSynchronizer::SynchronizeTrees(
623 layer_tree_root.get(), std::move(layer_impl_tree_root),
624 host_->active_tree());
625
626 EXPECT_TRUE(static_cast<FakeLayerAnimationController*>(
627 layer_tree_root->layer_animation_controller())->SynchronizedAnimations());
628 }
629
630 TEST_F(TreeSynchronizerTest, SynchronizeScrollParent) { 568 TEST_F(TreeSynchronizerTest, SynchronizeScrollParent) {
631 LayerTreeSettings settings; 569 LayerTreeSettings settings;
632 FakeImplTaskRunnerProvider task_runner_provider; 570 FakeImplTaskRunnerProvider task_runner_provider;
633 FakeRenderingStatsInstrumentation stats_instrumentation; 571 FakeRenderingStatsInstrumentation stats_instrumentation;
634 TestSharedBitmapManager shared_bitmap_manager; 572 TestSharedBitmapManager shared_bitmap_manager;
635 TestTaskGraphRunner task_graph_runner; 573 TestTaskGraphRunner task_graph_runner;
636 scoped_ptr<LayerTreeHostImpl> host_impl = LayerTreeHostImpl::Create( 574 scoped_ptr<LayerTreeHostImpl> host_impl = LayerTreeHostImpl::Create(
637 settings, nullptr, &task_runner_provider, &stats_instrumentation, 575 settings, nullptr, &task_runner_provider, &stats_instrumentation,
638 &shared_bitmap_manager, nullptr, &task_graph_runner, 0); 576 &shared_bitmap_manager, nullptr, &task_graph_runner, 0);
639 577
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
910 scroll_offset_map[scroll_layer->id()]->PullDeltaForMainThread(); 848 scroll_offset_map[scroll_layer->id()]->PullDeltaForMainThread();
911 scroll_offset_map[scroll_layer->id()]->SetCurrent(gfx::ScrollOffset(40, 50)); 849 scroll_offset_map[scroll_layer->id()]->SetCurrent(gfx::ScrollOffset(40, 50));
912 scroll_offset_map[scroll_layer->id()]->PushFromMainThread( 850 scroll_offset_map[scroll_layer->id()]->PushFromMainThread(
913 gfx::ScrollOffset(100, 100)); 851 gfx::ScrollOffset(100, 100));
914 scroll_offset_map[scroll_layer->id()]->PushPendingToActive(); 852 scroll_offset_map[scroll_layer->id()]->PushPendingToActive();
915 EXPECT_TRUE(is_equal(scroll_offset_map, scroll_tree.scroll_offset_map())); 853 EXPECT_TRUE(is_equal(scroll_offset_map, scroll_tree.scroll_offset_map()));
916 } 854 }
917 855
918 } // namespace 856 } // namespace
919 } // namespace cc 857 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698