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

Side by Side Diff: third_party/WebKit/Source/platform/animation/CompositorAnimationPlayerTest.cpp

Issue 2189813002: ElementAnimations should hold an ObservableList of AnimationPlayers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: apply loyso's comment Created 4 years, 4 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "platform/animation/CompositorAnimationPlayer.h" 5 #include "platform/animation/CompositorAnimationPlayer.h"
6 6
7 #include "base/time/time.h" 7 #include "base/time/time.h"
8 #include "platform/animation/CompositorAnimationDelegate.h" 8 #include "platform/animation/CompositorAnimationDelegate.h"
9 #include "platform/animation/CompositorAnimationPlayerClient.h" 9 #include "platform/animation/CompositorAnimationPlayerClient.h"
10 #include "platform/animation/CompositorAnimationTimeline.h" 10 #include "platform/animation/CompositorAnimationTimeline.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 TEST_F(CompositorAnimationPlayerTest, NullDelegate) 55 TEST_F(CompositorAnimationPlayerTest, NullDelegate)
56 { 56 {
57 std::unique_ptr<CompositorAnimationDelegateForTesting> delegate(new Composit orAnimationDelegateForTesting); 57 std::unique_ptr<CompositorAnimationDelegateForTesting> delegate(new Composit orAnimationDelegateForTesting);
58 58
59 std::unique_ptr<CompositorAnimationPlayer> player = CompositorAnimationPlaye r::create(); 59 std::unique_ptr<CompositorAnimationPlayer> player = CompositorAnimationPlaye r::create();
60 cc::AnimationPlayer* ccPlayer = player->animationPlayer(); 60 cc::AnimationPlayer* ccPlayer = player->animationPlayer();
61 61
62 player->setAnimationDelegate(delegate.get()); 62 player->setAnimationDelegate(delegate.get());
63 EXPECT_FALSE(delegate->m_finished); 63 EXPECT_FALSE(delegate->m_finished);
64 64
65 ccPlayer->NotifyAnimationFinished(base::TimeTicks(), CompositorTargetPropert y::SCROLL_OFFSET, 0); 65 ccPlayer->OnAnimationFinished(base::TimeTicks(), CompositorTargetProperty::S CROLL_OFFSET, 0);
66 EXPECT_TRUE(delegate->m_finished); 66 EXPECT_TRUE(delegate->m_finished);
67 67
68 delegate->resetFlags(); 68 delegate->resetFlags();
69 69
70 player->setAnimationDelegate(nullptr); 70 player->setAnimationDelegate(nullptr);
71 ccPlayer->NotifyAnimationFinished(base::TimeTicks(), CompositorTargetPropert y::SCROLL_OFFSET, 0); 71 ccPlayer->OnAnimationFinished(base::TimeTicks(), CompositorTargetProperty::S CROLL_OFFSET, 0);
72 EXPECT_FALSE(delegate->m_finished); 72 EXPECT_FALSE(delegate->m_finished);
73 } 73 }
74 74
75 TEST_F(CompositorAnimationPlayerTest, NotifyFromCCAfterCompositorPlayerDeletion) 75 TEST_F(CompositorAnimationPlayerTest, NotifyFromCCAfterCompositorPlayerDeletion)
76 { 76 {
77 std::unique_ptr<CompositorAnimationDelegateForTesting> delegate(new Composit orAnimationDelegateForTesting); 77 std::unique_ptr<CompositorAnimationDelegateForTesting> delegate(new Composit orAnimationDelegateForTesting);
78 78
79 std::unique_ptr<CompositorAnimationPlayer> player = CompositorAnimationPlaye r::create(); 79 std::unique_ptr<CompositorAnimationPlayer> player = CompositorAnimationPlaye r::create();
80 scoped_refptr<cc::AnimationPlayer> ccPlayer = player->animationPlayer(); 80 scoped_refptr<cc::AnimationPlayer> ccPlayer = player->animationPlayer();
81 81
82 player->setAnimationDelegate(delegate.get()); 82 player->setAnimationDelegate(delegate.get());
83 EXPECT_FALSE(delegate->m_finished); 83 EXPECT_FALSE(delegate->m_finished);
84 84
85 // Delete CompositorAnimationPlayer. ccPlayer stays alive. 85 // Delete CompositorAnimationPlayer. ccPlayer stays alive.
86 player = nullptr; 86 player = nullptr;
87 87
88 // No notifications. Doesn't crash. 88 // No notifications. Doesn't crash.
89 ccPlayer->NotifyAnimationFinished(base::TimeTicks(), CompositorTargetPropert y::OPACITY, 0); 89 ccPlayer->OnAnimationFinished(base::TimeTicks(), CompositorTargetProperty::O PACITY, 0);
90 EXPECT_FALSE(delegate->m_finished); 90 EXPECT_FALSE(delegate->m_finished);
91 } 91 }
92 92
93 TEST_F(CompositorAnimationPlayerTest, CompositorPlayerDeletionDetachesFromCCTime line) 93 TEST_F(CompositorAnimationPlayerTest, CompositorPlayerDeletionDetachesFromCCTime line)
94 { 94 {
95 std::unique_ptr<CompositorAnimationTimeline> timeline = CompositorAnimationT imeline::create(); 95 std::unique_ptr<CompositorAnimationTimeline> timeline = CompositorAnimationT imeline::create();
96 std::unique_ptr<CompositorAnimationPlayerTestClient> client(new CompositorAn imationPlayerTestClient); 96 std::unique_ptr<CompositorAnimationPlayerTestClient> client(new CompositorAn imationPlayerTestClient);
97 97
98 scoped_refptr<cc::AnimationTimeline> ccTimeline = timeline->animationTimelin e(); 98 scoped_refptr<cc::AnimationTimeline> ccTimeline = timeline->animationTimelin e();
99 scoped_refptr<cc::AnimationPlayer> ccPlayer = client->m_player->animationPla yer(); 99 scoped_refptr<cc::AnimationPlayer> ccPlayer = client->m_player->animationPla yer();
100 EXPECT_FALSE(ccPlayer->animation_timeline()); 100 EXPECT_FALSE(ccPlayer->animation_timeline());
101 101
102 timeline->playerAttached(*client); 102 timeline->playerAttached(*client);
103 EXPECT_TRUE(ccPlayer->animation_timeline()); 103 EXPECT_TRUE(ccPlayer->animation_timeline());
104 EXPECT_TRUE(ccTimeline->GetPlayerById(ccPlayer->id())); 104 EXPECT_TRUE(ccTimeline->GetPlayerById(ccPlayer->id()));
105 105
106 // Delete client and CompositorAnimationPlayer while attached to timeline. 106 // Delete client and CompositorAnimationPlayer while attached to timeline.
107 client = nullptr; 107 client = nullptr;
108 108
109 EXPECT_FALSE(ccPlayer->animation_timeline()); 109 EXPECT_FALSE(ccPlayer->animation_timeline());
110 EXPECT_FALSE(ccTimeline->GetPlayerById(ccPlayer->id())); 110 EXPECT_FALSE(ccTimeline->GetPlayerById(ccPlayer->id()));
111 } 111 }
112 112
113 } // namespace blink 113 } // namespace blink
OLDNEW
« cc/test/animation_timelines_test_common.cc ('K') | « cc/test/animation_timelines_test_common.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698