Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(196)

Side by Side Diff: cc/animation/animation_host_unittest.cc

Issue 947033002: CC Animations: Establish AnimationHost, AnimationTimeline and AnimationPlayer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Implement test helpers. Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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_timeline.h"
8 #include "cc/test/animation_test_common.h"
9 #include "testing/gmock/include/gmock/gmock.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11
12 namespace cc {
13 namespace {
14
15 TEST(AnimationHostTest, SyncTimelinesAddRemove) {
16 scoped_ptr<AnimationHost> host(AnimationHost::Create(false));
17 scoped_ptr<AnimationHost> host_impl(AnimationHost::Create(true));
18
19 const int timeline_id = 1;
20 scoped_refptr<AnimationTimeline> timeline(
21 AnimationTimeline::Create(timeline_id));
22 host->AddAnimationTimeline(timeline.get());
23 EXPECT_TRUE(timeline->animation_host());
24
25 EXPECT_FALSE(host_impl->GetTimelineById(timeline_id));
26
27 host->PushPropertiesTo(host_impl.get());
28
29 scoped_refptr<AnimationTimeline> timeline_impl =
30 host_impl->GetTimelineById(timeline_id);
31 EXPECT_TRUE(timeline_impl);
32 EXPECT_EQ(timeline_impl->id(), timeline_id);
33
34 host->PushPropertiesTo(host_impl.get());
35 EXPECT_EQ(timeline_impl, host_impl->GetTimelineById(timeline_id));
36
37 host->RemoveAnimationTimeline(timeline.get());
38 EXPECT_FALSE(timeline->animation_host());
39
40 host->PushPropertiesTo(host_impl.get());
41 EXPECT_FALSE(host_impl->GetTimelineById(timeline_id));
42
43 EXPECT_FALSE(timeline_impl->animation_host());
44 }
45
46 TEST(AnimationHostTest, ImplOnlyTimeline) {
47 scoped_ptr<AnimationHost> host(AnimationHost::Create(false));
48 scoped_ptr<AnimationHost> host_impl(AnimationHost::Create(true));
49
50 const int timeline_id1 = 1;
51 const int timeline_id2 = 2;
52
53 scoped_refptr<AnimationTimeline> timeline(
54 AnimationTimeline::Create(timeline_id1));
55 scoped_refptr<AnimationTimeline> timeline_impl(
56 AnimationTimeline::Create(timeline_id2));
57 timeline_impl->set_is_impl_only(true);
58
59 host->AddAnimationTimeline(timeline.get());
60 host_impl->AddAnimationTimeline(timeline_impl.get());
61
62 host->PushPropertiesTo(host_impl.get());
63
64 EXPECT_TRUE(host->GetTimelineById(timeline_id1));
65 EXPECT_TRUE(host_impl->GetTimelineById(timeline_id2));
66 }
67
68 } // namespace
69 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698