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

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: Fix MSVC warning. Created 5 years, 5 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
« no previous file with comments | « cc/animation/animation_host.cc ('k') | cc/animation/animation_id_provider.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_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 // See AnimationPlayer tests on layer registration/unregistration in
17 // animation_player_unittest.cc.
18
19 TEST(AnimationHostTest, SyncTimelinesAddRemove) {
20 scoped_ptr<AnimationHost> host(AnimationHost::Create(ThreadInstance::MAIN));
21 scoped_ptr<AnimationHost> host_impl(
22 AnimationHost::Create(ThreadInstance::IMPL));
23
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());
29
30 EXPECT_FALSE(host_impl->GetTimelineById(timeline_id));
31
32 host->PushPropertiesTo(host_impl.get());
33
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);
38
39 host->PushPropertiesTo(host_impl.get());
40 EXPECT_EQ(timeline_impl, host_impl->GetTimelineById(timeline_id));
41
42 host->RemoveAnimationTimeline(timeline.get());
43 EXPECT_FALSE(timeline->animation_host());
44
45 host->PushPropertiesTo(host_impl.get());
46 EXPECT_FALSE(host_impl->GetTimelineById(timeline_id));
47
48 EXPECT_FALSE(timeline_impl->animation_host());
49 }
50
51 TEST(AnimationHostTest, ImplOnlyTimeline) {
52 scoped_ptr<AnimationHost> host(AnimationHost::Create(ThreadInstance::MAIN));
53 scoped_ptr<AnimationHost> host_impl(
54 AnimationHost::Create(ThreadInstance::IMPL));
55
56 const int timeline_id1 = AnimationIdProvider::NextTimelineId();
57 const int timeline_id2 = AnimationIdProvider::NextTimelineId();
58
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);
64
65 host->AddAnimationTimeline(timeline.get());
66 host_impl->AddAnimationTimeline(timeline_impl.get());
67
68 host->PushPropertiesTo(host_impl.get());
69
70 EXPECT_TRUE(host->GetTimelineById(timeline_id1));
71 EXPECT_TRUE(host_impl->GetTimelineById(timeline_id2));
72 }
73
74 } // namespace
75 } // namespace cc
OLDNEW
« no previous file with comments | « cc/animation/animation_host.cc ('k') | cc/animation/animation_id_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698