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