| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 // Tests for the ScrollAnimator class. | 26 // Tests for the ScrollAnimator class. |
| 27 | 27 |
| 28 #include "platform/scroll/ScrollAnimator.h" | 28 #include "platform/scroll/ScrollAnimator.h" |
| 29 | 29 |
| 30 #include "platform/geometry/FloatPoint.h" | 30 #include "platform/geometry/FloatPoint.h" |
| 31 #include "platform/geometry/IntRect.h" | 31 #include "platform/geometry/IntRect.h" |
| 32 #include "platform/scroll/ScrollAnimatorBase.h" | 32 #include "platform/scroll/ScrollAnimatorBase.h" |
| 33 #include "platform/scroll/ScrollableArea.h" | 33 #include "platform/scroll/ScrollableArea.h" |
| 34 #include "public/platform/Platform.h" |
| 35 #include "public/platform/WebScheduler.h" |
| 36 #include "public/platform/WebThread.h" |
| 34 #include "testing/gmock/include/gmock/gmock.h" | 37 #include "testing/gmock/include/gmock/gmock.h" |
| 35 #include "testing/gtest/include/gtest/gtest.h" | 38 #include "testing/gtest/include/gtest/gtest.h" |
| 36 | 39 |
| 37 namespace blink { | 40 namespace blink { |
| 38 | 41 |
| 39 using testing::AtLeast; | 42 using testing::AtLeast; |
| 40 using testing::Return; | 43 using testing::Return; |
| 41 using testing::_; | 44 using testing::_; |
| 42 | 45 |
| 43 static double gMockedTime = 0.0; | 46 static double gMockedTime = 0.0; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 } | 104 } |
| 102 | 105 |
| 103 void setScrollOffset(const ScrollOffset& offset, | 106 void setScrollOffset(const ScrollOffset& offset, |
| 104 ScrollType type, | 107 ScrollType type, |
| 105 ScrollBehavior behavior = ScrollBehaviorInstant) { | 108 ScrollBehavior behavior = ScrollBehaviorInstant) { |
| 106 if (animator) | 109 if (animator) |
| 107 animator->setCurrentOffset(offset); | 110 animator->setCurrentOffset(offset); |
| 108 ScrollableArea::setScrollOffset(offset, type, behavior); | 111 ScrollableArea::setScrollOffset(offset, type, behavior); |
| 109 } | 112 } |
| 110 | 113 |
| 114 RefPtr<WebTaskRunner> getTimerTaskRunner() const final { |
| 115 return Platform::current()->currentThread()->scheduler()->timerTaskRunner(); |
| 116 } |
| 117 |
| 111 DEFINE_INLINE_VIRTUAL_TRACE() { | 118 DEFINE_INLINE_VIRTUAL_TRACE() { |
| 112 visitor->trace(animator); | 119 visitor->trace(animator); |
| 113 ScrollableArea::trace(visitor); | 120 ScrollableArea::trace(visitor); |
| 114 } | 121 } |
| 115 | 122 |
| 116 private: | 123 private: |
| 117 explicit MockScrollableArea(bool scrollAnimatorEnabled, | 124 explicit MockScrollableArea(bool scrollAnimatorEnabled, |
| 118 const ScrollOffset& minOffset, | 125 const ScrollOffset& minOffset, |
| 119 const ScrollOffset& maxOffset) | 126 const ScrollOffset& maxOffset) |
| 120 : m_scrollAnimatorEnabled(scrollAnimatorEnabled), | 127 : m_scrollAnimatorEnabled(scrollAnimatorEnabled), |
| (...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 645 ScrollAnimatorCompositorCoordinator::RunState::PostAnimationCleanup); | 652 ScrollAnimatorCompositorCoordinator::RunState::PostAnimationCleanup); |
| 646 EXPECT_EQ(ScrollOffset(110, 90), animator->desiredTargetOffset()); | 653 EXPECT_EQ(ScrollOffset(110, 90), animator->desiredTargetOffset()); |
| 647 | 654 |
| 648 reset(*animator); | 655 reset(*animator); |
| 649 | 656 |
| 650 // Forced GC in order to finalize objects depending on the mock object. | 657 // Forced GC in order to finalize objects depending on the mock object. |
| 651 ThreadState::current()->collectAllGarbage(); | 658 ThreadState::current()->collectAllGarbage(); |
| 652 } | 659 } |
| 653 | 660 |
| 654 } // namespace blink | 661 } // namespace blink |
| OLD | NEW |