| 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/scroll_offset_animation_curve.h" | 9 #include "cc/animation/scroll_offset_animation_curve.h" |
| 10 #include "cc/animation/timing_function.h" | 10 #include "cc/animation/timing_function.h" |
| (...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 715 base::TimeTicks monotonic_time) OVERRIDE { | 715 base::TimeTicks monotonic_time) OVERRIDE { |
| 716 EndTest(); | 716 EndTest(); |
| 717 } | 717 } |
| 718 | 718 |
| 719 virtual void AfterTest() OVERRIDE {} | 719 virtual void AfterTest() OVERRIDE {} |
| 720 }; | 720 }; |
| 721 | 721 |
| 722 SINGLE_AND_MULTI_THREAD_TEST_F( | 722 SINGLE_AND_MULTI_THREAD_TEST_F( |
| 723 LayerTreeHostAnimationTestLayerAddedWithAnimation); | 723 LayerTreeHostAnimationTestLayerAddedWithAnimation); |
| 724 | 724 |
| 725 class LayerTreeHostAnimationTestContinuousAnimate | |
| 726 : public LayerTreeHostAnimationTest { | |
| 727 public: | |
| 728 LayerTreeHostAnimationTestContinuousAnimate() | |
| 729 : num_commit_complete_(0), | |
| 730 num_draw_layers_(0) { | |
| 731 } | |
| 732 | |
| 733 virtual void SetupTree() OVERRIDE { | |
| 734 LayerTreeHostAnimationTest::SetupTree(); | |
| 735 // Create a fake content layer so we actually produce new content for every | |
| 736 // animation frame. | |
| 737 content_ = FakeContentLayer::Create(&client_); | |
| 738 content_->set_always_update_resources(true); | |
| 739 layer_tree_host()->root_layer()->AddChild(content_); | |
| 740 } | |
| 741 | |
| 742 virtual void BeginTest() OVERRIDE { | |
| 743 PostSetNeedsCommitToMainThread(); | |
| 744 } | |
| 745 | |
| 746 virtual void Animate(base::TimeTicks) OVERRIDE { | |
| 747 if (num_draw_layers_ == 2) | |
| 748 return; | |
| 749 layer_tree_host()->SetNeedsAnimate(); | |
| 750 } | |
| 751 | |
| 752 virtual void Layout() OVERRIDE { | |
| 753 layer_tree_host()->root_layer()->SetNeedsDisplay(); | |
| 754 } | |
| 755 | |
| 756 virtual void CommitCompleteOnThread(LayerTreeHostImpl* tree_impl) OVERRIDE { | |
| 757 if (num_draw_layers_ == 1) | |
| 758 num_commit_complete_++; | |
| 759 } | |
| 760 | |
| 761 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { | |
| 762 num_draw_layers_++; | |
| 763 if (num_draw_layers_ == 2) | |
| 764 EndTest(); | |
| 765 } | |
| 766 | |
| 767 virtual void AfterTest() OVERRIDE { | |
| 768 // Check that we didn't commit twice between first and second draw. | |
| 769 EXPECT_EQ(1, num_commit_complete_); | |
| 770 } | |
| 771 | |
| 772 private: | |
| 773 int num_commit_complete_; | |
| 774 int num_draw_layers_; | |
| 775 FakeContentLayerClient client_; | |
| 776 scoped_refptr<FakeContentLayer> content_; | |
| 777 }; | |
| 778 | |
| 779 MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestContinuousAnimate); | |
| 780 | |
| 781 class LayerTreeHostAnimationTestCancelAnimateCommit | 725 class LayerTreeHostAnimationTestCancelAnimateCommit |
| 782 : public LayerTreeHostAnimationTest { | 726 : public LayerTreeHostAnimationTest { |
| 783 public: | 727 public: |
| 784 LayerTreeHostAnimationTestCancelAnimateCommit() | 728 LayerTreeHostAnimationTestCancelAnimateCommit() |
| 785 : num_animate_calls_(0), num_commit_calls_(0), num_draw_calls_(0) {} | 729 : num_animate_calls_(0), num_commit_calls_(0), num_draw_calls_(0) {} |
| 786 | 730 |
| 787 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } | 731 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } |
| 788 | 732 |
| 789 virtual void Animate(base::TimeTicks) OVERRIDE { | 733 virtual void Animate(base::TimeTicks) OVERRIDE { |
| 790 num_animate_calls_++; | 734 num_animate_calls_++; |
| (...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1342 private: | 1286 private: |
| 1343 scoped_refptr<Layer> content_; | 1287 scoped_refptr<Layer> content_; |
| 1344 int num_swap_buffers_; | 1288 int num_swap_buffers_; |
| 1345 }; | 1289 }; |
| 1346 | 1290 |
| 1347 SINGLE_AND_MULTI_THREAD_TEST_F( | 1291 SINGLE_AND_MULTI_THREAD_TEST_F( |
| 1348 LayerTreeHostAnimationTestAddAnimationAfterAnimating); | 1292 LayerTreeHostAnimationTestAddAnimationAfterAnimating); |
| 1349 | 1293 |
| 1350 } // namespace | 1294 } // namespace |
| 1351 } // namespace cc | 1295 } // namespace cc |
| OLD | NEW |