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