OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/layer_tree_host.h" | 5 #include "cc/trees/layer_tree_host.h" |
6 | 6 |
7 #include "cc/animation/animation_curve.h" | 7 #include "cc/animation/animation_curve.h" |
8 #include "cc/animation/layer_animation_controller.h" | 8 #include "cc/animation/layer_animation_controller.h" |
9 #include "cc/animation/timing_function.h" | 9 #include "cc/animation/timing_function.h" |
10 #include "cc/layers/layer.h" | 10 #include "cc/layers/layer.h" |
(...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
758 int added_animations_; | 758 int added_animations_; |
759 int started_times_; | 759 int started_times_; |
760 int finished_times_; | 760 int finished_times_; |
761 FakeContentLayerClient client_; | 761 FakeContentLayerClient client_; |
762 scoped_refptr<FakeContentLayer> content_; | 762 scoped_refptr<FakeContentLayer> content_; |
763 }; | 763 }; |
764 | 764 |
765 MULTI_THREAD_TEST_F( | 765 MULTI_THREAD_TEST_F( |
766 LayerTreeHostAnimationTestCheckerboardDoesntStartAnimations); | 766 LayerTreeHostAnimationTestCheckerboardDoesntStartAnimations); |
767 | 767 |
| 768 // Test that creating a pinch-zoom scrollbar animation leads to AnimateLayers |
| 769 // being called. |
| 770 class LayerTreeHostAnimationTestPinchZoomScrollbars |
| 771 : public LayerTreeHostAnimationTest { |
| 772 public: |
| 773 LayerTreeHostAnimationTestPinchZoomScrollbars() |
| 774 : root_layer_(FakeContentLayer::Create(&client_)), |
| 775 started_times_(0), |
| 776 num_commit_complete_(0) {} |
| 777 |
| 778 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { |
| 779 settings->use_pinch_zoom_scrollbars = true; |
| 780 } |
| 781 |
| 782 virtual void SetupTree() OVERRIDE { |
| 783 root_layer_->SetBounds(gfx::Size(100, 100)); |
| 784 layer_tree_host()->SetRootLayer(root_layer_); |
| 785 LayerTreeHostAnimationTest::SetupTree(); |
| 786 } |
| 787 |
| 788 virtual void BeginTest() OVERRIDE { |
| 789 layer_tree_host()->SetPageScaleFactorAndLimits(1.55f, 1.f, 4.f); |
| 790 PostSetNeedsCommitToMainThread(); |
| 791 } |
| 792 |
| 793 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
| 794 num_commit_complete_++; |
| 795 } |
| 796 |
| 797 virtual void AnimateLayers(LayerTreeHostImpl* host_impl, |
| 798 base::TimeTicks monotonic_time) OVERRIDE { |
| 799 // Two commits are required for the creation of pinch-zoom scrollbars. |
| 800 // Wait for these to finish. |
| 801 if (num_commit_complete_ < 2) |
| 802 return; |
| 803 |
| 804 EXPECT_NE(host_impl->active_tree()->page_scale_factor(), 1.f); |
| 805 |
| 806 switch (started_times_) { |
| 807 case 0: |
| 808 host_impl->active_tree()->DidBeginScroll(); |
| 809 started_times_++; |
| 810 break; |
| 811 case 1: |
| 812 host_impl->active_tree()->DidEndScroll(); |
| 813 started_times_++; |
| 814 break; |
| 815 case 2: |
| 816 EndTest(); |
| 817 } |
| 818 } |
| 819 |
| 820 virtual void AfterTest() OVERRIDE {} |
| 821 |
| 822 private: |
| 823 FakeContentLayerClient client_; |
| 824 scoped_refptr<FakeContentLayer> root_layer_; |
| 825 int started_times_; |
| 826 int num_commit_complete_; |
| 827 }; |
| 828 |
| 829 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestPinchZoomScrollbars); |
| 830 |
768 } // namespace | 831 } // namespace |
769 } // namespace cc | 832 } // namespace cc |
OLD | NEW |