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

Side by Side Diff: cc/animation/animation_timeline_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_timeline.cc ('k') | cc/animation/element_animations.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_timeline.h"
6
7 #include "cc/animation/animation_host.h"
8 #include "cc/animation/animation_id_provider.h"
9 #include "cc/animation/animation_player.h"
10 #include "cc/test/animation_test_common.h"
11 #include "testing/gmock/include/gmock/gmock.h"
12 #include "testing/gtest/include/gtest/gtest.h"
13
14 namespace cc {
15 namespace {
16
17 TEST(AnimationTimelineTest, SyncPlayersAttachDetach) {
18 scoped_ptr<AnimationHost> host(AnimationHost::Create(ThreadInstance::MAIN));
19 scoped_ptr<AnimationHost> host_impl(
20 AnimationHost::Create(ThreadInstance::IMPL));
21
22 const int timeline_id = AnimationIdProvider::NextTimelineId();
23 const int player_id = AnimationIdProvider::NextPlayerId();
24
25 scoped_refptr<AnimationTimeline> timeline_impl(
26 AnimationTimeline::Create(timeline_id));
27 scoped_refptr<AnimationTimeline> timeline(
28 AnimationTimeline::Create(timeline_id));
29
30 host->AddAnimationTimeline(timeline.get());
31 EXPECT_TRUE(timeline->animation_host());
32
33 host_impl->AddAnimationTimeline(timeline_impl.get());
34 EXPECT_TRUE(timeline_impl->animation_host());
35
36 scoped_refptr<AnimationPlayer> player(AnimationPlayer::Create(player_id));
37 timeline->AttachPlayer(player.get());
38 EXPECT_TRUE(player->animation_timeline());
39
40 EXPECT_FALSE(timeline_impl->GetPlayerById(player_id));
41
42 timeline->PushPropertiesTo(timeline_impl.get());
43
44 scoped_refptr<AnimationPlayer> player_impl =
45 timeline_impl->GetPlayerById(player_id);
46 EXPECT_TRUE(player_impl);
47 EXPECT_EQ(player_impl->id(), player_id);
48 EXPECT_TRUE(player_impl->animation_timeline());
49
50 timeline->PushPropertiesTo(timeline_impl.get());
51 EXPECT_EQ(player_impl, timeline_impl->GetPlayerById(player_id));
52
53 timeline->DetachPlayer(player.get());
54 EXPECT_FALSE(player->animation_timeline());
55
56 timeline->PushPropertiesTo(timeline_impl.get());
57 EXPECT_FALSE(timeline_impl->GetPlayerById(player_id));
58
59 EXPECT_FALSE(player_impl->animation_timeline());
60 }
61
62 TEST(AnimationTimelineTest, ClearPlayers) {
63 scoped_ptr<AnimationHost> host(AnimationHost::Create(ThreadInstance::MAIN));
64 scoped_ptr<AnimationHost> host_impl(
65 AnimationHost::Create(ThreadInstance::IMPL));
66
67 const int timeline_id = AnimationIdProvider::NextTimelineId();
68 const int player_id1 = AnimationIdProvider::NextPlayerId();
69 const int player_id2 = AnimationIdProvider::NextPlayerId();
70
71 scoped_refptr<AnimationTimeline> timeline_impl(
72 AnimationTimeline::Create(timeline_id));
73 scoped_refptr<AnimationTimeline> timeline(
74 AnimationTimeline::Create(timeline_id));
75
76 host->AddAnimationTimeline(timeline.get());
77 host_impl->AddAnimationTimeline(timeline_impl.get());
78
79 scoped_refptr<AnimationPlayer> player1(AnimationPlayer::Create(player_id1));
80 timeline->AttachPlayer(player1.get());
81 scoped_refptr<AnimationPlayer> player2(AnimationPlayer::Create(player_id2));
82 timeline->AttachPlayer(player2.get());
83
84 timeline->PushPropertiesTo(timeline_impl.get());
85
86 EXPECT_TRUE(timeline_impl->GetPlayerById(player_id1));
87 EXPECT_TRUE(timeline_impl->GetPlayerById(player_id2));
88
89 timeline->ClearPlayers();
90 EXPECT_FALSE(timeline->GetPlayerById(player_id1));
91 EXPECT_FALSE(timeline->GetPlayerById(player_id2));
92
93 timeline_impl->ClearPlayers();
94 EXPECT_FALSE(timeline_impl->GetPlayerById(player_id1));
95 EXPECT_FALSE(timeline_impl->GetPlayerById(player_id2));
96 }
97
98 } // namespace
99 } // namespace cc
OLDNEW
« no previous file with comments | « cc/animation/animation_timeline.cc ('k') | cc/animation/element_animations.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698