Add ICU message format support
[chromium-blink-merge.git] / cc / animation / animation_timeline_unittest.cc
blob3b0bc5ab7301b923b71f7d2e20e64c296af37982
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_timeline.h"
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"
14 namespace cc {
15 namespace {
17 TEST(AnimationTimelineTest, SyncPlayersAttachDetach) {
18 scoped_ptr<AnimationHost> host(AnimationHost::Create(ThreadInstance::MAIN));
19 scoped_ptr<AnimationHost> host_impl(
20 AnimationHost::Create(ThreadInstance::IMPL));
22 const int timeline_id = AnimationIdProvider::NextTimelineId();
23 const int player_id = AnimationIdProvider::NextPlayerId();
25 scoped_refptr<AnimationTimeline> timeline_impl(
26 AnimationTimeline::Create(timeline_id));
27 scoped_refptr<AnimationTimeline> timeline(
28 AnimationTimeline::Create(timeline_id));
30 host->AddAnimationTimeline(timeline.get());
31 EXPECT_TRUE(timeline->animation_host());
33 host_impl->AddAnimationTimeline(timeline_impl.get());
34 EXPECT_TRUE(timeline_impl->animation_host());
36 scoped_refptr<AnimationPlayer> player(AnimationPlayer::Create(player_id));
37 timeline->AttachPlayer(player.get());
38 EXPECT_TRUE(player->animation_timeline());
40 EXPECT_FALSE(timeline_impl->GetPlayerById(player_id));
42 timeline->PushPropertiesTo(timeline_impl.get());
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());
50 timeline->PushPropertiesTo(timeline_impl.get());
51 EXPECT_EQ(player_impl, timeline_impl->GetPlayerById(player_id));
53 timeline->DetachPlayer(player.get());
54 EXPECT_FALSE(player->animation_timeline());
56 timeline->PushPropertiesTo(timeline_impl.get());
57 EXPECT_FALSE(timeline_impl->GetPlayerById(player_id));
59 EXPECT_FALSE(player_impl->animation_timeline());
62 TEST(AnimationTimelineTest, ClearPlayers) {
63 scoped_ptr<AnimationHost> host(AnimationHost::Create(ThreadInstance::MAIN));
64 scoped_ptr<AnimationHost> host_impl(
65 AnimationHost::Create(ThreadInstance::IMPL));
67 const int timeline_id = AnimationIdProvider::NextTimelineId();
68 const int player_id1 = AnimationIdProvider::NextPlayerId();
69 const int player_id2 = AnimationIdProvider::NextPlayerId();
71 scoped_refptr<AnimationTimeline> timeline_impl(
72 AnimationTimeline::Create(timeline_id));
73 scoped_refptr<AnimationTimeline> timeline(
74 AnimationTimeline::Create(timeline_id));
76 host->AddAnimationTimeline(timeline.get());
77 host_impl->AddAnimationTimeline(timeline_impl.get());
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());
84 timeline->PushPropertiesTo(timeline_impl.get());
86 EXPECT_TRUE(timeline_impl->GetPlayerById(player_id1));
87 EXPECT_TRUE(timeline_impl->GetPlayerById(player_id2));
89 timeline->ClearPlayers();
90 EXPECT_FALSE(timeline->GetPlayerById(player_id1));
91 EXPECT_FALSE(timeline->GetPlayerById(player_id2));
93 timeline_impl->ClearPlayers();
94 EXPECT_FALSE(timeline_impl->GetPlayerById(player_id1));
95 EXPECT_FALSE(timeline_impl->GetPlayerById(player_id2));
98 } // namespace
99 } // namespace cc