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" |
(...skipping 19 matching lines...) Expand all Loading... |
30 AnimationHost::Create(ThreadInstance::IMPL)); | 30 AnimationHost::Create(ThreadInstance::IMPL)); |
31 | 31 |
32 const int timeline_id = AnimationIdProvider::NextTimelineId(); | 32 const int timeline_id = AnimationIdProvider::NextTimelineId(); |
33 scoped_refptr<AnimationTimeline> timeline( | 33 scoped_refptr<AnimationTimeline> timeline( |
34 AnimationTimeline::Create(timeline_id)); | 34 AnimationTimeline::Create(timeline_id)); |
35 host->AddAnimationTimeline(timeline.get()); | 35 host->AddAnimationTimeline(timeline.get()); |
36 EXPECT_TRUE(timeline->animation_host()); | 36 EXPECT_TRUE(timeline->animation_host()); |
37 | 37 |
38 EXPECT_FALSE(host_impl->GetTimelineById(timeline_id)); | 38 EXPECT_FALSE(host_impl->GetTimelineById(timeline_id)); |
39 | 39 |
40 host->PushPropertiesTo(host_impl.get()); | 40 host->PushPropertiesTo(host_impl.get(), base::TimeTicks()); |
41 | 41 |
42 scoped_refptr<AnimationTimeline> timeline_impl = | 42 scoped_refptr<AnimationTimeline> timeline_impl = |
43 host_impl->GetTimelineById(timeline_id); | 43 host_impl->GetTimelineById(timeline_id); |
44 EXPECT_TRUE(timeline_impl); | 44 EXPECT_TRUE(timeline_impl); |
45 EXPECT_EQ(timeline_impl->id(), timeline_id); | 45 EXPECT_EQ(timeline_impl->id(), timeline_id); |
46 | 46 |
47 host->PushPropertiesTo(host_impl.get()); | 47 host->PushPropertiesTo(host_impl.get(), base::TimeTicks()); |
48 EXPECT_EQ(timeline_impl, host_impl->GetTimelineById(timeline_id)); | 48 EXPECT_EQ(timeline_impl, host_impl->GetTimelineById(timeline_id)); |
49 | 49 |
50 host->RemoveAnimationTimeline(timeline.get()); | 50 host->RemoveAnimationTimeline(timeline.get()); |
51 EXPECT_FALSE(timeline->animation_host()); | 51 EXPECT_FALSE(timeline->animation_host()); |
52 | 52 |
53 host->PushPropertiesTo(host_impl.get()); | 53 host->PushPropertiesTo(host_impl.get(), base::TimeTicks()); |
54 EXPECT_FALSE(host_impl->GetTimelineById(timeline_id)); | 54 EXPECT_FALSE(host_impl->GetTimelineById(timeline_id)); |
55 | 55 |
56 EXPECT_FALSE(timeline_impl->animation_host()); | 56 EXPECT_FALSE(timeline_impl->animation_host()); |
57 } | 57 } |
58 | 58 |
59 TEST_F(AnimationHostTest, ImplOnlyTimeline) { | 59 TEST_F(AnimationHostTest, ImplOnlyTimeline) { |
60 std::unique_ptr<AnimationHost> host( | 60 std::unique_ptr<AnimationHost> host( |
61 AnimationHost::Create(ThreadInstance::MAIN)); | 61 AnimationHost::Create(ThreadInstance::MAIN)); |
62 std::unique_ptr<AnimationHost> host_impl( | 62 std::unique_ptr<AnimationHost> host_impl( |
63 AnimationHost::Create(ThreadInstance::IMPL)); | 63 AnimationHost::Create(ThreadInstance::IMPL)); |
64 | 64 |
65 const int timeline_id1 = AnimationIdProvider::NextTimelineId(); | 65 const int timeline_id1 = AnimationIdProvider::NextTimelineId(); |
66 const int timeline_id2 = AnimationIdProvider::NextTimelineId(); | 66 const int timeline_id2 = AnimationIdProvider::NextTimelineId(); |
67 | 67 |
68 scoped_refptr<AnimationTimeline> timeline( | 68 scoped_refptr<AnimationTimeline> timeline( |
69 AnimationTimeline::Create(timeline_id1)); | 69 AnimationTimeline::Create(timeline_id1)); |
70 scoped_refptr<AnimationTimeline> timeline_impl( | 70 scoped_refptr<AnimationTimeline> timeline_impl( |
71 AnimationTimeline::Create(timeline_id2)); | 71 AnimationTimeline::Create(timeline_id2)); |
72 timeline_impl->set_is_impl_only(true); | 72 timeline_impl->set_is_impl_only(true); |
73 | 73 |
74 host->AddAnimationTimeline(timeline.get()); | 74 host->AddAnimationTimeline(timeline.get()); |
75 host_impl->AddAnimationTimeline(timeline_impl.get()); | 75 host_impl->AddAnimationTimeline(timeline_impl.get()); |
76 | 76 |
77 host->PushPropertiesTo(host_impl.get()); | 77 host->PushPropertiesTo(host_impl.get(), base::TimeTicks()); |
78 | 78 |
79 EXPECT_TRUE(host->GetTimelineById(timeline_id1)); | 79 EXPECT_TRUE(host->GetTimelineById(timeline_id1)); |
80 EXPECT_TRUE(host_impl->GetTimelineById(timeline_id2)); | 80 EXPECT_TRUE(host_impl->GetTimelineById(timeline_id2)); |
81 } | 81 } |
82 | 82 |
83 TEST_F(AnimationHostTest, ImplOnlyScrollAnimationUpdateTargetIfDetached) { | 83 TEST_F(AnimationHostTest, ImplOnlyScrollAnimationUpdateTargetIfDetached) { |
84 client_.RegisterElement(element_id_, ElementListType::ACTIVE); | 84 client_.RegisterElement(element_id_, ElementListType::ACTIVE); |
85 client_impl_.RegisterElement(element_id_, ElementListType::PENDING); | 85 client_impl_.RegisterElement(element_id_, ElementListType::PENDING); |
86 | 86 |
87 gfx::ScrollOffset target_offset(0., 2.); | 87 gfx::ScrollOffset target_offset(0., 2.); |
(...skipping 13 matching lines...) Expand all Loading... |
101 // Detach all players from layers and timelines. | 101 // Detach all players from layers and timelines. |
102 host_impl_->ClearTimelines(); | 102 host_impl_->ClearTimelines(); |
103 | 103 |
104 time += base::TimeDelta::FromSecondsD(0.1); | 104 time += base::TimeDelta::FromSecondsD(0.1); |
105 EXPECT_FALSE(host_impl_->ImplOnlyScrollAnimationUpdateTarget( | 105 EXPECT_FALSE(host_impl_->ImplOnlyScrollAnimationUpdateTarget( |
106 element_id_, scroll_delta, max_scroll_offset, time)); | 106 element_id_, scroll_delta, max_scroll_offset, time)); |
107 } | 107 } |
108 | 108 |
109 } // namespace | 109 } // namespace |
110 } // namespace cc | 110 } // namespace cc |
OLD | NEW |