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

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

Issue 2050123002: Remove OwnPtr from Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: First attempt to land. Created 4 years, 6 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 26 matching lines...) Expand all
37 37
38 class CompositorAnimationPlayerTestClient : public CompositorAnimationPlayerClie nt { 38 class CompositorAnimationPlayerTestClient : public CompositorAnimationPlayerClie nt {
39 public: 39 public:
40 CompositorAnimationPlayerTestClient() : m_player(CompositorAnimationPlayer:: create()) {} 40 CompositorAnimationPlayerTestClient() : m_player(CompositorAnimationPlayer:: create()) {}
41 41
42 CompositorAnimationPlayer* compositorPlayer() const override 42 CompositorAnimationPlayer* compositorPlayer() const override
43 { 43 {
44 return m_player.get(); 44 return m_player.get();
45 } 45 }
46 46
47 OwnPtr<CompositorAnimationPlayer> m_player; 47 std::unique_ptr<CompositorAnimationPlayer> m_player;
48 }; 48 };
49 49
50 class CompositorAnimationPlayerTest : public CompositorTest { 50 class CompositorAnimationPlayerTest : public CompositorTest {
51 }; 51 };
52 52
53 // Test that when the animation delegate is null, the animation player 53 // Test that when the animation delegate is null, the animation player
54 // doesn't forward the finish notification. 54 // doesn't forward the finish notification.
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 OwnPtr<CompositorAnimationPlayer> player = CompositorAnimationPlayer::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->NotifyAnimationFinished(base::TimeTicks(), CompositorTargetPropert y::SCROLL_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->NotifyAnimationFinished(base::TimeTicks(), CompositorTargetPropert y::SCROLL_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 OwnPtr<CompositorAnimationPlayer> player = CompositorAnimationPlayer::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->NotifyAnimationFinished(base::TimeTicks(), CompositorTargetPropert y::OPACITY, 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 OwnPtr<CompositorAnimationTimeline> timeline = CompositorAnimationTimeline:: 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

Powered by Google App Engine
This is Rietveld 408576698