Index: cc/animation/animation_host_unittest.cc |
diff --git a/cc/animation/animation_host_unittest.cc b/cc/animation/animation_host_unittest.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..6228f41ae4f10b75a2326cfc54d341c682957123 |
--- /dev/null |
+++ b/cc/animation/animation_host_unittest.cc |
@@ -0,0 +1,70 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "cc/animation/animation_host.h" |
+ |
+#include "cc/animation/animation_id_provider.h" |
+#include "cc/animation/animation_timeline.h" |
+#include "cc/test/animation_test_common.h" |
+#include "testing/gmock/include/gmock/gmock.h" |
+#include "testing/gtest/include/gtest/gtest.h" |
+ |
+namespace cc { |
+namespace { |
+ |
+TEST(AnimationHostTest, SyncTimelinesAddRemove) { |
Ian Vollick
2015/05/05 03:52:06
Is layer/player registration and unregistration te
loyso (OOO)
2015/05/05 06:51:18
Yeah, that's in animation_player_unittest.cc
Ian Vollick
2015/05/07 13:58:42
k, great. Please add a comment to this effect here
loyso (OOO)
2015/05/08 01:04:34
Acknowledged.
loyso (OOO)
2015/06/22 07:48:51
Done.
|
+ scoped_ptr<AnimationHost> host(AnimationHost::Create(false)); |
+ scoped_ptr<AnimationHost> host_impl(AnimationHost::Create(true)); |
+ |
+ const int timeline_id = AnimationIdProvider::NextTimelineId(); |
+ scoped_refptr<AnimationTimeline> timeline( |
+ AnimationTimeline::Create(timeline_id)); |
+ host->AddAnimationTimeline(timeline.get()); |
+ EXPECT_TRUE(timeline->animation_host()); |
+ |
+ EXPECT_FALSE(host_impl->GetTimelineById(timeline_id)); |
+ |
+ host->PushPropertiesTo(host_impl.get()); |
+ |
+ scoped_refptr<AnimationTimeline> timeline_impl = |
+ host_impl->GetTimelineById(timeline_id); |
+ EXPECT_TRUE(timeline_impl); |
+ EXPECT_EQ(timeline_impl->id(), timeline_id); |
+ |
+ host->PushPropertiesTo(host_impl.get()); |
+ EXPECT_EQ(timeline_impl, host_impl->GetTimelineById(timeline_id)); |
+ |
+ host->RemoveAnimationTimeline(timeline.get()); |
+ EXPECT_FALSE(timeline->animation_host()); |
+ |
+ host->PushPropertiesTo(host_impl.get()); |
+ EXPECT_FALSE(host_impl->GetTimelineById(timeline_id)); |
+ |
+ EXPECT_FALSE(timeline_impl->animation_host()); |
+} |
+ |
+TEST(AnimationHostTest, ImplOnlyTimeline) { |
+ scoped_ptr<AnimationHost> host(AnimationHost::Create(false)); |
+ scoped_ptr<AnimationHost> host_impl(AnimationHost::Create(true)); |
+ |
+ const int timeline_id1 = AnimationIdProvider::NextTimelineId(); |
+ const int timeline_id2 = AnimationIdProvider::NextTimelineId(); |
+ |
+ scoped_refptr<AnimationTimeline> timeline( |
+ AnimationTimeline::Create(timeline_id1)); |
+ scoped_refptr<AnimationTimeline> timeline_impl( |
+ AnimationTimeline::Create(timeline_id2)); |
+ timeline_impl->set_is_impl_only(true); |
+ |
+ host->AddAnimationTimeline(timeline.get()); |
+ host_impl->AddAnimationTimeline(timeline_impl.get()); |
+ |
+ host->PushPropertiesTo(host_impl.get()); |
+ |
+ EXPECT_TRUE(host->GetTimelineById(timeline_id1)); |
+ EXPECT_TRUE(host_impl->GetTimelineById(timeline_id2)); |
+} |
+ |
+} // namespace |
+} // namespace cc |