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