| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/animation_host.h" | 5 #include "cc/animation/animation_host.h" |
| 6 | 6 |
| 7 #include "cc/animation/animation_id_provider.h" | 7 #include "cc/animation/animation_id_provider.h" |
| 8 #include "cc/animation/animation_timeline.h" | 8 #include "cc/animation/animation_timeline.h" |
| 9 #include "cc/test/animation_test_common.h" | 9 #include "cc/test/animation_test_common.h" |
| 10 #include "cc/test/animation_timelines_test_common.h" | 10 #include "cc/test/animation_timelines_test_common.h" |
| 11 #include "testing/gmock/include/gmock/gmock.h" | 11 #include "testing/gmock/include/gmock/gmock.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 13 |
| 14 namespace cc { | 14 namespace cc { |
| 15 namespace { | 15 namespace { |
| 16 | 16 |
| 17 class AnimationHostTest : public AnimationTimelinesTest { | 17 class AnimationHostTest : public AnimationTimelinesTest { |
| 18 public: | 18 public: |
| 19 AnimationHostTest() {} | 19 AnimationHostTest() {} |
| 20 ~AnimationHostTest() override {} | 20 ~AnimationHostTest() override {} |
| 21 }; | 21 }; |
| 22 | 22 |
| 23 // See AnimationPlayer tests on layer registration/unregistration in | 23 // See AnimationPlayer tests on layer registration/unregistration in |
| 24 // animation_player_unittest.cc. | 24 // animation_player_unittest.cc. |
| 25 | 25 |
| 26 TEST_F(AnimationHostTest, SyncTimelinesAddRemove) { | 26 TEST_F(AnimationHostTest, SyncTimelinesAddRemove) { |
| 27 scoped_ptr<AnimationHost> host(AnimationHost::Create(ThreadInstance::MAIN)); | 27 std::unique_ptr<AnimationHost> host( |
| 28 scoped_ptr<AnimationHost> host_impl( | 28 AnimationHost::Create(ThreadInstance::MAIN)); |
| 29 std::unique_ptr<AnimationHost> host_impl( |
| 29 AnimationHost::Create(ThreadInstance::IMPL)); | 30 AnimationHost::Create(ThreadInstance::IMPL)); |
| 30 | 31 |
| 31 const int timeline_id = AnimationIdProvider::NextTimelineId(); | 32 const int timeline_id = AnimationIdProvider::NextTimelineId(); |
| 32 scoped_refptr<AnimationTimeline> timeline( | 33 scoped_refptr<AnimationTimeline> timeline( |
| 33 AnimationTimeline::Create(timeline_id)); | 34 AnimationTimeline::Create(timeline_id)); |
| 34 host->AddAnimationTimeline(timeline.get()); | 35 host->AddAnimationTimeline(timeline.get()); |
| 35 EXPECT_TRUE(timeline->animation_host()); | 36 EXPECT_TRUE(timeline->animation_host()); |
| 36 | 37 |
| 37 EXPECT_FALSE(host_impl->GetTimelineById(timeline_id)); | 38 EXPECT_FALSE(host_impl->GetTimelineById(timeline_id)); |
| 38 | 39 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 49 host->RemoveAnimationTimeline(timeline.get()); | 50 host->RemoveAnimationTimeline(timeline.get()); |
| 50 EXPECT_FALSE(timeline->animation_host()); | 51 EXPECT_FALSE(timeline->animation_host()); |
| 51 | 52 |
| 52 host->PushPropertiesTo(host_impl.get()); | 53 host->PushPropertiesTo(host_impl.get()); |
| 53 EXPECT_FALSE(host_impl->GetTimelineById(timeline_id)); | 54 EXPECT_FALSE(host_impl->GetTimelineById(timeline_id)); |
| 54 | 55 |
| 55 EXPECT_FALSE(timeline_impl->animation_host()); | 56 EXPECT_FALSE(timeline_impl->animation_host()); |
| 56 } | 57 } |
| 57 | 58 |
| 58 TEST_F(AnimationHostTest, ImplOnlyTimeline) { | 59 TEST_F(AnimationHostTest, ImplOnlyTimeline) { |
| 59 scoped_ptr<AnimationHost> host(AnimationHost::Create(ThreadInstance::MAIN)); | 60 std::unique_ptr<AnimationHost> host( |
| 60 scoped_ptr<AnimationHost> host_impl( | 61 AnimationHost::Create(ThreadInstance::MAIN)); |
| 62 std::unique_ptr<AnimationHost> host_impl( |
| 61 AnimationHost::Create(ThreadInstance::IMPL)); | 63 AnimationHost::Create(ThreadInstance::IMPL)); |
| 62 | 64 |
| 63 const int timeline_id1 = AnimationIdProvider::NextTimelineId(); | 65 const int timeline_id1 = AnimationIdProvider::NextTimelineId(); |
| 64 const int timeline_id2 = AnimationIdProvider::NextTimelineId(); | 66 const int timeline_id2 = AnimationIdProvider::NextTimelineId(); |
| 65 | 67 |
| 66 scoped_refptr<AnimationTimeline> timeline( | 68 scoped_refptr<AnimationTimeline> timeline( |
| 67 AnimationTimeline::Create(timeline_id1)); | 69 AnimationTimeline::Create(timeline_id1)); |
| 68 scoped_refptr<AnimationTimeline> timeline_impl( | 70 scoped_refptr<AnimationTimeline> timeline_impl( |
| 69 AnimationTimeline::Create(timeline_id2)); | 71 AnimationTimeline::Create(timeline_id2)); |
| 70 timeline_impl->set_is_impl_only(true); | 72 timeline_impl->set_is_impl_only(true); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 99 // Detach all players from layers and timelines. | 101 // Detach all players from layers and timelines. |
| 100 host_impl_->ClearTimelines(); | 102 host_impl_->ClearTimelines(); |
| 101 | 103 |
| 102 time += base::TimeDelta::FromSecondsD(0.1); | 104 time += base::TimeDelta::FromSecondsD(0.1); |
| 103 EXPECT_FALSE(host_impl_->ImplOnlyScrollAnimationUpdateTarget( | 105 EXPECT_FALSE(host_impl_->ImplOnlyScrollAnimationUpdateTarget( |
| 104 layer_id_, scroll_delta, max_scroll_offset, time)); | 106 layer_id_, scroll_delta, max_scroll_offset, time)); |
| 105 } | 107 } |
| 106 | 108 |
| 107 } // namespace | 109 } // namespace |
| 108 } // namespace cc | 110 } // namespace cc |
| OLD | NEW |