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 "testing/gmock/include/gmock/gmock.h" | 10 #include "testing/gmock/include/gmock/gmock.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
12 | 12 |
13 namespace cc { | 13 namespace cc { |
14 namespace { | 14 namespace { |
15 | 15 |
16 // See AnimationPlayer tests on layer registration/unregistration in | 16 // See AnimationPlayer tests on layer registration/unregistration in |
17 // animation_player_unittest.cc. | 17 // animation_player_unittest.cc. |
18 | 18 |
19 TEST(AnimationHostTest, SyncTimelinesAddRemove) { | 19 TEST(AnimationHostTest, SyncTimelinesAddRemove) { |
20 scoped_ptr<AnimationHost> host(AnimationHost::Create(ThreadInstance::MAIN)); | 20 scoped_ptr<AnimationHost> host(AnimationHost::Create()); |
21 scoped_ptr<AnimationHost> host_impl( | 21 scoped_ptr<AnimationHost> host_impl(AnimationHost::Create()); |
22 AnimationHost::Create(ThreadInstance::IMPL)); | |
23 | 22 |
24 const int timeline_id = AnimationIdProvider::NextTimelineId(); | 23 const int timeline_id = AnimationIdProvider::NextTimelineId(); |
25 scoped_refptr<AnimationTimeline> timeline( | 24 scoped_refptr<AnimationTimeline> timeline( |
26 AnimationTimeline::Create(timeline_id)); | 25 AnimationTimeline::Create(timeline_id)); |
27 host->AddAnimationTimeline(timeline.get()); | 26 host->AddAnimationTimeline(timeline.get()); |
28 EXPECT_TRUE(timeline->animation_host()); | 27 EXPECT_TRUE(timeline->animation_host()); |
29 | 28 |
30 EXPECT_FALSE(host_impl->GetTimelineById(timeline_id)); | 29 EXPECT_FALSE(host_impl->GetTimelineById(timeline_id)); |
31 | 30 |
32 host->PushPropertiesTo(host_impl.get()); | 31 host->PushPropertiesTo(host_impl.get()); |
33 | 32 |
34 scoped_refptr<AnimationTimeline> timeline_impl = | 33 scoped_refptr<AnimationTimeline> timeline_impl = |
35 host_impl->GetTimelineById(timeline_id); | 34 host_impl->GetTimelineById(timeline_id); |
36 EXPECT_TRUE(timeline_impl); | 35 EXPECT_TRUE(timeline_impl); |
37 EXPECT_EQ(timeline_impl->id(), timeline_id); | 36 EXPECT_EQ(timeline_impl->id(), timeline_id); |
38 | 37 |
39 host->PushPropertiesTo(host_impl.get()); | 38 host->PushPropertiesTo(host_impl.get()); |
40 EXPECT_EQ(timeline_impl, host_impl->GetTimelineById(timeline_id)); | 39 EXPECT_EQ(timeline_impl, host_impl->GetTimelineById(timeline_id)); |
41 | 40 |
42 host->RemoveAnimationTimeline(timeline.get()); | 41 host->RemoveAnimationTimeline(timeline.get()); |
43 EXPECT_FALSE(timeline->animation_host()); | 42 EXPECT_FALSE(timeline->animation_host()); |
44 | 43 |
45 host->PushPropertiesTo(host_impl.get()); | 44 host->PushPropertiesTo(host_impl.get()); |
46 EXPECT_FALSE(host_impl->GetTimelineById(timeline_id)); | 45 EXPECT_FALSE(host_impl->GetTimelineById(timeline_id)); |
47 | 46 |
48 EXPECT_FALSE(timeline_impl->animation_host()); | 47 EXPECT_FALSE(timeline_impl->animation_host()); |
49 } | 48 } |
50 | 49 |
51 TEST(AnimationHostTest, ImplOnlyTimeline) { | 50 TEST(AnimationHostTest, ImplOnlyTimeline) { |
52 scoped_ptr<AnimationHost> host(AnimationHost::Create(ThreadInstance::MAIN)); | 51 scoped_ptr<AnimationHost> host(AnimationHost::Create()); |
53 scoped_ptr<AnimationHost> host_impl( | 52 scoped_ptr<AnimationHost> host_impl(AnimationHost::Create()); |
54 AnimationHost::Create(ThreadInstance::IMPL)); | |
55 | 53 |
56 const int timeline_id1 = AnimationIdProvider::NextTimelineId(); | 54 const int timeline_id1 = AnimationIdProvider::NextTimelineId(); |
57 const int timeline_id2 = AnimationIdProvider::NextTimelineId(); | 55 const int timeline_id2 = AnimationIdProvider::NextTimelineId(); |
58 | 56 |
59 scoped_refptr<AnimationTimeline> timeline( | 57 scoped_refptr<AnimationTimeline> timeline( |
60 AnimationTimeline::Create(timeline_id1)); | 58 AnimationTimeline::Create(timeline_id1)); |
61 scoped_refptr<AnimationTimeline> timeline_impl( | 59 scoped_refptr<AnimationTimeline> timeline_impl( |
62 AnimationTimeline::Create(timeline_id2)); | 60 AnimationTimeline::Create(timeline_id2)); |
63 timeline_impl->set_is_impl_only(true); | 61 timeline_impl->set_is_impl_only(true); |
64 | 62 |
65 host->AddAnimationTimeline(timeline.get()); | 63 host->AddAnimationTimeline(timeline.get()); |
66 host_impl->AddAnimationTimeline(timeline_impl.get()); | 64 host_impl->AddAnimationTimeline(timeline_impl.get()); |
67 | 65 |
68 host->PushPropertiesTo(host_impl.get()); | 66 host->PushPropertiesTo(host_impl.get()); |
69 | 67 |
70 EXPECT_TRUE(host->GetTimelineById(timeline_id1)); | 68 EXPECT_TRUE(host->GetTimelineById(timeline_id1)); |
71 EXPECT_TRUE(host_impl->GetTimelineById(timeline_id2)); | 69 EXPECT_TRUE(host_impl->GetTimelineById(timeline_id2)); |
72 } | 70 } |
73 | 71 |
74 } // namespace | 72 } // namespace |
75 } // namespace cc | 73 } // namespace cc |
OLD | NEW |