OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "platform/animation/CompositorAnimationPlayer.h" |
| 6 |
| 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/time/time.h" |
| 9 #include "public/platform/WebCompositorAnimationDelegate.h" |
| 10 #include "testing/gmock/include/gmock/gmock.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 |
| 13 using base::TimeTicks; |
| 14 using blink::WebCompositorAnimationDelegate; |
| 15 using cc::Animation; |
| 16 using testing::_; |
| 17 |
| 18 namespace blink { |
| 19 |
| 20 class MockWebCompositorAnimationDelegate : public WebCompositorAnimationDelegate
{ |
| 21 public: |
| 22 MockWebCompositorAnimationDelegate() {} |
| 23 |
| 24 MOCK_METHOD2(notifyAnimationStarted, void(double, int)); |
| 25 MOCK_METHOD2(notifyAnimationFinished, void(double, int)); |
| 26 MOCK_METHOD2(notifyAnimationAborted, void(double, int)); |
| 27 }; |
| 28 |
| 29 // Test that when the animation delegate is null, the animation player |
| 30 // doesn't forward the finish notification. |
| 31 TEST(WebCompositorAnimationPlayerTest, NullDelegate) |
| 32 { |
| 33 scoped_ptr<WebCompositorAnimationDelegate> delegate( |
| 34 new MockWebCompositorAnimationDelegate); |
| 35 EXPECT_CALL(*static_cast<MockWebCompositorAnimationDelegate*>(delegate.get()
), |
| 36 notifyAnimationFinished(_, _)) |
| 37 .Times(1); |
| 38 |
| 39 scoped_ptr<CompositorAnimationPlayer> webPlayer(new CompositorAnimationPlaye
r); |
| 40 cc::AnimationPlayer* player = webPlayer->animationPlayer(); |
| 41 |
| 42 webPlayer->setAnimationDelegate(delegate.get()); |
| 43 player->NotifyAnimationFinished(TimeTicks(), Animation::SCROLL_OFFSET, 0); |
| 44 |
| 45 webPlayer->setAnimationDelegate(nullptr); |
| 46 player->NotifyAnimationFinished(TimeTicks(), Animation::SCROLL_OFFSET, 0); |
| 47 } |
| 48 |
| 49 } // namespace blink |
OLD | NEW |