| 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/animation/layer_animation_controller.h" | 5 #include "cc/animation/layer_animation_controller.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "cc/animation/animation.h" | 9 #include "cc/animation/animation.h" |
| 10 #include "cc/animation/animation_curve.h" | 10 #include "cc/animation/animation_curve.h" |
| (...skipping 1012 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1023 EXPECT_FALSE(controller_impl->scroll_offset_animation_was_interrupted()); | 1023 EXPECT_FALSE(controller_impl->scroll_offset_animation_was_interrupted()); |
| 1024 EXPECT_FALSE(controller->scroll_offset_animation_was_interrupted()); | 1024 EXPECT_FALSE(controller->scroll_offset_animation_was_interrupted()); |
| 1025 | 1025 |
| 1026 controller_impl->ActivateAnimations(); | 1026 controller_impl->ActivateAnimations(); |
| 1027 EXPECT_FALSE(controller_impl->scroll_offset_animation_was_interrupted()); | 1027 EXPECT_FALSE(controller_impl->scroll_offset_animation_was_interrupted()); |
| 1028 } | 1028 } |
| 1029 | 1029 |
| 1030 class FakeAnimationDelegate : public AnimationDelegate { | 1030 class FakeAnimationDelegate : public AnimationDelegate { |
| 1031 public: | 1031 public: |
| 1032 FakeAnimationDelegate() | 1032 FakeAnimationDelegate() |
| 1033 : started_(false), finished_(false), start_time_(base::TimeTicks()) {} | 1033 : started_(false), |
| 1034 finished_(false), |
| 1035 aborted_(false), |
| 1036 start_time_(base::TimeTicks()) {} |
| 1034 | 1037 |
| 1035 void NotifyAnimationStarted(TimeTicks monotonic_time, | 1038 void NotifyAnimationStarted(TimeTicks monotonic_time, |
| 1036 Animation::TargetProperty target_property, | 1039 Animation::TargetProperty target_property, |
| 1037 int group) override { | 1040 int group) override { |
| 1038 started_ = true; | 1041 started_ = true; |
| 1039 start_time_ = monotonic_time; | 1042 start_time_ = monotonic_time; |
| 1040 } | 1043 } |
| 1041 | 1044 |
| 1042 void NotifyAnimationFinished(TimeTicks monotonic_time, | 1045 void NotifyAnimationFinished(TimeTicks monotonic_time, |
| 1043 Animation::TargetProperty target_property, | 1046 Animation::TargetProperty target_property, |
| 1044 int group) override { | 1047 int group) override { |
| 1045 finished_ = true; | 1048 finished_ = true; |
| 1046 } | 1049 } |
| 1047 | 1050 |
| 1051 void NotifyAnimationAborted(TimeTicks monotonic_time, |
| 1052 Animation::TargetProperty target_property, |
| 1053 int group) override { |
| 1054 aborted_ = true; |
| 1055 } |
| 1056 |
| 1048 bool started() { return started_; } | 1057 bool started() { return started_; } |
| 1049 | 1058 |
| 1050 bool finished() { return finished_; } | 1059 bool finished() { return finished_; } |
| 1051 | 1060 |
| 1061 bool aborted() { return aborted_; } |
| 1062 |
| 1052 TimeTicks start_time() { return start_time_; } | 1063 TimeTicks start_time() { return start_time_; } |
| 1053 | 1064 |
| 1054 private: | 1065 private: |
| 1055 bool started_; | 1066 bool started_; |
| 1056 bool finished_; | 1067 bool finished_; |
| 1068 bool aborted_; |
| 1057 TimeTicks start_time_; | 1069 TimeTicks start_time_; |
| 1058 }; | 1070 }; |
| 1059 | 1071 |
| 1060 // Tests that impl-only animations lead to start and finished notifications | 1072 // Tests that impl-only animations lead to start and finished notifications |
| 1061 // on the impl thread controller's animation delegate. | 1073 // on the impl thread controller's animation delegate. |
| 1062 TEST(LayerAnimationControllerTest, | 1074 TEST(LayerAnimationControllerTest, |
| 1063 NotificationsForImplOnlyAnimationsAreSentToImplThreadDelegate) { | 1075 NotificationsForImplOnlyAnimationsAreSentToImplThreadDelegate) { |
| 1064 FakeLayerAnimationValueObserver dummy_impl; | 1076 FakeLayerAnimationValueObserver dummy_impl; |
| 1065 scoped_refptr<LayerAnimationController> controller_impl( | 1077 scoped_refptr<LayerAnimationController> controller_impl( |
| 1066 LayerAnimationController::Create(0)); | 1078 LayerAnimationController::Create(0)); |
| (...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1861 // An animation aborted on the impl thread should get deleted on both threads. | 1873 // An animation aborted on the impl thread should get deleted on both threads. |
| 1862 TEST(LayerAnimationControllerTest, ImplThreadAbortedAnimationGetsDeleted) { | 1874 TEST(LayerAnimationControllerTest, ImplThreadAbortedAnimationGetsDeleted) { |
| 1863 FakeLayerAnimationValueObserver dummy_impl; | 1875 FakeLayerAnimationValueObserver dummy_impl; |
| 1864 scoped_refptr<LayerAnimationController> controller_impl( | 1876 scoped_refptr<LayerAnimationController> controller_impl( |
| 1865 LayerAnimationController::Create(0)); | 1877 LayerAnimationController::Create(0)); |
| 1866 controller_impl->AddValueObserver(&dummy_impl); | 1878 controller_impl->AddValueObserver(&dummy_impl); |
| 1867 FakeLayerAnimationValueObserver dummy; | 1879 FakeLayerAnimationValueObserver dummy; |
| 1868 scoped_refptr<LayerAnimationController> controller( | 1880 scoped_refptr<LayerAnimationController> controller( |
| 1869 LayerAnimationController::Create(0)); | 1881 LayerAnimationController::Create(0)); |
| 1870 controller->AddValueObserver(&dummy); | 1882 controller->AddValueObserver(&dummy); |
| 1883 FakeAnimationDelegate delegate; |
| 1884 controller->set_layer_animation_delegate(&delegate); |
| 1871 | 1885 |
| 1872 int animation_id = | 1886 int animation_id = |
| 1873 AddOpacityTransitionToController(controller.get(), 1.0, 0.f, 1.f, false); | 1887 AddOpacityTransitionToController(controller.get(), 1.0, 0.f, 1.f, false); |
| 1874 | 1888 |
| 1875 controller->PushAnimationUpdatesTo(controller_impl.get()); | 1889 controller->PushAnimationUpdatesTo(controller_impl.get()); |
| 1876 controller_impl->ActivateAnimations(); | 1890 controller_impl->ActivateAnimations(); |
| 1877 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id)); | 1891 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id)); |
| 1878 | 1892 |
| 1879 controller_impl->AbortAnimations(Animation::OPACITY); | 1893 controller_impl->AbortAnimations(Animation::OPACITY); |
| 1880 EXPECT_EQ(Animation::ABORTED, | 1894 EXPECT_EQ(Animation::ABORTED, |
| 1881 controller_impl->GetAnimation(Animation::OPACITY)->run_state()); | 1895 controller_impl->GetAnimation(Animation::OPACITY)->run_state()); |
| 1882 EXPECT_FALSE(dummy.animation_waiting_for_deletion()); | 1896 EXPECT_FALSE(dummy.animation_waiting_for_deletion()); |
| 1883 EXPECT_FALSE(dummy_impl.animation_waiting_for_deletion()); | 1897 EXPECT_FALSE(dummy_impl.animation_waiting_for_deletion()); |
| 1884 | 1898 |
| 1885 AnimationEventsVector events; | 1899 AnimationEventsVector events; |
| 1886 controller_impl->Animate(kInitialTickTime); | 1900 controller_impl->Animate(kInitialTickTime); |
| 1887 controller_impl->UpdateState(true, &events); | 1901 controller_impl->UpdateState(true, &events); |
| 1888 EXPECT_TRUE(dummy_impl.animation_waiting_for_deletion()); | 1902 EXPECT_TRUE(dummy_impl.animation_waiting_for_deletion()); |
| 1889 EXPECT_EQ(1u, events.size()); | 1903 EXPECT_EQ(1u, events.size()); |
| 1890 EXPECT_EQ(AnimationEvent::ABORTED, events[0].type); | 1904 EXPECT_EQ(AnimationEvent::ABORTED, events[0].type); |
| 1891 EXPECT_EQ(Animation::WAITING_FOR_DELETION, | 1905 EXPECT_EQ(Animation::WAITING_FOR_DELETION, |
| 1892 controller_impl->GetAnimation(Animation::OPACITY)->run_state()); | 1906 controller_impl->GetAnimation(Animation::OPACITY)->run_state()); |
| 1893 | 1907 |
| 1894 controller->NotifyAnimationAborted(events[0]); | 1908 controller->NotifyAnimationAborted(events[0]); |
| 1895 EXPECT_EQ(Animation::ABORTED, | 1909 EXPECT_EQ(Animation::ABORTED, |
| 1896 controller->GetAnimation(Animation::OPACITY)->run_state()); | 1910 controller->GetAnimation(Animation::OPACITY)->run_state()); |
| 1911 EXPECT_TRUE(delegate.aborted()); |
| 1897 | 1912 |
| 1898 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); | 1913 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); |
| 1899 controller->UpdateState(true, nullptr); | 1914 controller->UpdateState(true, nullptr); |
| 1900 EXPECT_TRUE(dummy.animation_waiting_for_deletion()); | 1915 EXPECT_TRUE(dummy.animation_waiting_for_deletion()); |
| 1901 EXPECT_EQ(Animation::WAITING_FOR_DELETION, | 1916 EXPECT_EQ(Animation::WAITING_FOR_DELETION, |
| 1902 controller->GetAnimation(Animation::OPACITY)->run_state()); | 1917 controller->GetAnimation(Animation::OPACITY)->run_state()); |
| 1903 | 1918 |
| 1904 controller->PushAnimationUpdatesTo(controller_impl.get()); | 1919 controller->PushAnimationUpdatesTo(controller_impl.get()); |
| 1905 controller_impl->ActivateAnimations(); | 1920 controller_impl->ActivateAnimations(); |
| 1906 EXPECT_FALSE(controller->GetAnimationById(animation_id)); | 1921 EXPECT_FALSE(controller->GetAnimationById(animation_id)); |
| (...skipping 1096 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3003 EXPECT_FALSE(controller->IsPotentiallyAnimatingProperty( | 3018 EXPECT_FALSE(controller->IsPotentiallyAnimatingProperty( |
| 3004 Animation::OPACITY, LayerAnimationController::ObserverType::ACTIVE)); | 3019 Animation::OPACITY, LayerAnimationController::ObserverType::ACTIVE)); |
| 3005 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty( | 3020 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty( |
| 3006 Animation::OPACITY, LayerAnimationController::ObserverType::PENDING)); | 3021 Animation::OPACITY, LayerAnimationController::ObserverType::PENDING)); |
| 3007 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty( | 3022 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty( |
| 3008 Animation::OPACITY, LayerAnimationController::ObserverType::ACTIVE)); | 3023 Animation::OPACITY, LayerAnimationController::ObserverType::ACTIVE)); |
| 3009 } | 3024 } |
| 3010 | 3025 |
| 3011 } // namespace | 3026 } // namespace |
| 3012 } // namespace cc | 3027 } // namespace cc |
| OLD | NEW |