Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / cc / animation / animation_host_unittest.cc
blob18d6c9f66f587de32a0c53ec68b3b7e98a826b57
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.
5 #include "cc/animation/animation_host.h"
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"
13 namespace cc {
14 namespace {
16 // See AnimationPlayer tests on layer registration/unregistration in
17 // animation_player_unittest.cc.
19 TEST(AnimationHostTest, SyncTimelinesAddRemove) {
20 scoped_ptr<AnimationHost> host(AnimationHost::Create(ThreadInstance::MAIN));
21 scoped_ptr<AnimationHost> host_impl(
22 AnimationHost::Create(ThreadInstance::IMPL));
24 const int timeline_id = AnimationIdProvider::NextTimelineId();
25 scoped_refptr<AnimationTimeline> timeline(
26 AnimationTimeline::Create(timeline_id));
27 host->AddAnimationTimeline(timeline.get());
28 EXPECT_TRUE(timeline->animation_host());
30 EXPECT_FALSE(host_impl->GetTimelineById(timeline_id));
32 host->PushPropertiesTo(host_impl.get());
34 scoped_refptr<AnimationTimeline> timeline_impl =
35 host_impl->GetTimelineById(timeline_id);
36 EXPECT_TRUE(timeline_impl);
37 EXPECT_EQ(timeline_impl->id(), timeline_id);
39 host->PushPropertiesTo(host_impl.get());
40 EXPECT_EQ(timeline_impl, host_impl->GetTimelineById(timeline_id));
42 host->RemoveAnimationTimeline(timeline.get());
43 EXPECT_FALSE(timeline->animation_host());
45 host->PushPropertiesTo(host_impl.get());
46 EXPECT_FALSE(host_impl->GetTimelineById(timeline_id));
48 EXPECT_FALSE(timeline_impl->animation_host());
51 TEST(AnimationHostTest, ImplOnlyTimeline) {
52 scoped_ptr<AnimationHost> host(AnimationHost::Create(ThreadInstance::MAIN));
53 scoped_ptr<AnimationHost> host_impl(
54 AnimationHost::Create(ThreadInstance::IMPL));
56 const int timeline_id1 = AnimationIdProvider::NextTimelineId();
57 const int timeline_id2 = AnimationIdProvider::NextTimelineId();
59 scoped_refptr<AnimationTimeline> timeline(
60 AnimationTimeline::Create(timeline_id1));
61 scoped_refptr<AnimationTimeline> timeline_impl(
62 AnimationTimeline::Create(timeline_id2));
63 timeline_impl->set_is_impl_only(true);
65 host->AddAnimationTimeline(timeline.get());
66 host_impl->AddAnimationTimeline(timeline_impl.get());
68 host->PushPropertiesTo(host_impl.get());
70 EXPECT_TRUE(host->GetTimelineById(timeline_id1));
71 EXPECT_TRUE(host_impl->GetTimelineById(timeline_id2));
74 } // namespace
75 } // namespace cc