OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "cc/animation/animation_host.h" |
| 6 |
| 7 #include "cc/animation/animation_id_provider.h" |
| 8 #include "cc/animation/animation_timeline.h" |
| 9 #include "cc/test/animation_test_common.h" |
| 10 #include "testing/gmock/include/gmock/gmock.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 |
| 13 namespace cc { |
| 14 namespace { |
| 15 |
| 16 TEST(AnimationHostTest, SyncTimelinesAddRemove) { |
| 17 scoped_ptr<AnimationHost> host(AnimationHost::Create(false)); |
| 18 scoped_ptr<AnimationHost> host_impl(AnimationHost::Create(true)); |
| 19 |
| 20 const int timeline_id = AnimationIdProvider::NextTimelineId(); |
| 21 scoped_refptr<AnimationTimeline> timeline( |
| 22 AnimationTimeline::Create(timeline_id)); |
| 23 host->AddAnimationTimeline(timeline.get()); |
| 24 EXPECT_TRUE(timeline->animation_host()); |
| 25 |
| 26 EXPECT_FALSE(host_impl->GetTimelineById(timeline_id)); |
| 27 |
| 28 host->PushPropertiesTo(host_impl.get()); |
| 29 |
| 30 scoped_refptr<AnimationTimeline> timeline_impl = |
| 31 host_impl->GetTimelineById(timeline_id); |
| 32 EXPECT_TRUE(timeline_impl); |
| 33 EXPECT_EQ(timeline_impl->id(), timeline_id); |
| 34 |
| 35 host->PushPropertiesTo(host_impl.get()); |
| 36 EXPECT_EQ(timeline_impl, host_impl->GetTimelineById(timeline_id)); |
| 37 |
| 38 host->RemoveAnimationTimeline(timeline.get()); |
| 39 EXPECT_FALSE(timeline->animation_host()); |
| 40 |
| 41 host->PushPropertiesTo(host_impl.get()); |
| 42 EXPECT_FALSE(host_impl->GetTimelineById(timeline_id)); |
| 43 |
| 44 EXPECT_FALSE(timeline_impl->animation_host()); |
| 45 } |
| 46 |
| 47 TEST(AnimationHostTest, ImplOnlyTimeline) { |
| 48 scoped_ptr<AnimationHost> host(AnimationHost::Create(false)); |
| 49 scoped_ptr<AnimationHost> host_impl(AnimationHost::Create(true)); |
| 50 |
| 51 const int timeline_id1 = AnimationIdProvider::NextTimelineId(); |
| 52 const int timeline_id2 = AnimationIdProvider::NextTimelineId(); |
| 53 |
| 54 scoped_refptr<AnimationTimeline> timeline( |
| 55 AnimationTimeline::Create(timeline_id1)); |
| 56 scoped_refptr<AnimationTimeline> timeline_impl( |
| 57 AnimationTimeline::Create(timeline_id2)); |
| 58 timeline_impl->set_is_impl_only(true); |
| 59 |
| 60 host->AddAnimationTimeline(timeline.get()); |
| 61 host_impl->AddAnimationTimeline(timeline_impl.get()); |
| 62 |
| 63 host->PushPropertiesTo(host_impl.get()); |
| 64 |
| 65 EXPECT_TRUE(host->GetTimelineById(timeline_id1)); |
| 66 EXPECT_TRUE(host_impl->GetTimelineById(timeline_id2)); |
| 67 } |
| 68 |
| 69 } // namespace |
| 70 } // namespace cc |
OLD | NEW |