OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "config.h" | 5 #include "config.h" |
6 #include <gtest/gtest.h> | 6 #include <gtest/gtest.h> |
7 | 7 |
8 #include "platform/geometry/IntPoint.h" | 8 #include "platform/geometry/IntPoint.h" |
9 #include "platform/geometry/IntSize.h" | 9 #include "platform/geometry/IntSize.h" |
10 #include "platform/mac/ScrollElasticityController.h" | 10 #include "platform/mac/ScrollElasticityController.h" |
11 #include "platform/PlatformWheelEvent.h" | 11 #include "platform/PlatformWheelEvent.h" |
12 | 12 |
13 namespace blink { | 13 namespace blink { |
14 | 14 |
15 class MockScrollElasticityControllerClient : public ScrollElasticityControllerCl
ient { | 15 class MockScrollElasticityControllerClient : public ScrollElasticityControllerCl
ient { |
16 public: | 16 public: |
17 MockScrollElasticityControllerClient() : m_pinned(true), m_stretchX(0.0f) {} | 17 MockScrollElasticityControllerClient() : m_pinned(true), m_stretchX(0.0f) {} |
18 | 18 |
19 virtual bool allowsHorizontalStretching() OVERRIDE { return true; } | 19 virtual bool allowsHorizontalStretching() override { return true; } |
20 virtual bool allowsVerticalStretching() OVERRIDE { return true; } | 20 virtual bool allowsVerticalStretching() override { return true; } |
21 // The amount that the view is stretched past the normal allowable bounds. | 21 // The amount that the view is stretched past the normal allowable bounds. |
22 // The "overhang" amount. | 22 // The "overhang" amount. |
23 virtual IntSize stretchAmount() OVERRIDE { return IntSize(m_stretchX, 0); } | 23 virtual IntSize stretchAmount() override { return IntSize(m_stretchX, 0); } |
24 virtual bool pinnedInDirection(const FloatSize&) OVERRIDE { return m_pinned;
} | 24 virtual bool pinnedInDirection(const FloatSize&) override { return m_pinned;
} |
25 virtual bool canScrollHorizontally() OVERRIDE { return true; } | 25 virtual bool canScrollHorizontally() override { return true; } |
26 virtual bool canScrollVertically() OVERRIDE { return true; } | 26 virtual bool canScrollVertically() override { return true; } |
27 | 27 |
28 // Return the absolute scroll position, not relative to the scroll origin. | 28 // Return the absolute scroll position, not relative to the scroll origin. |
29 virtual blink::IntPoint absoluteScrollPosition() OVERRIDE { return IntPoint(
m_stretchX, 0); } | 29 virtual blink::IntPoint absoluteScrollPosition() override { return IntPoint(
m_stretchX, 0); } |
30 | 30 |
31 virtual void immediateScrollBy(const FloatSize& size) OVERRIDE { m_stretchX
+= size.width(); } | 31 virtual void immediateScrollBy(const FloatSize& size) override { m_stretchX
+= size.width(); } |
32 virtual void immediateScrollByWithoutContentEdgeConstraints(const FloatSize&
size) OVERRIDE { m_stretchX += size.width(); } | 32 virtual void immediateScrollByWithoutContentEdgeConstraints(const FloatSize&
size) override { m_stretchX += size.width(); } |
33 virtual void startSnapRubberbandTimer() OVERRIDE {} | 33 virtual void startSnapRubberbandTimer() override {} |
34 virtual void stopSnapRubberbandTimer() OVERRIDE {} | 34 virtual void stopSnapRubberbandTimer() override {} |
35 virtual void adjustScrollPositionToBoundsIfNecessary() OVERRIDE {} | 35 virtual void adjustScrollPositionToBoundsIfNecessary() override {} |
36 | 36 |
37 void reset() { m_stretchX = 0; } | 37 void reset() { m_stretchX = 0; } |
38 | 38 |
39 bool m_pinned; | 39 bool m_pinned; |
40 | 40 |
41 private: | 41 private: |
42 float m_stretchX; | 42 float m_stretchX; |
43 }; | 43 }; |
44 | 44 |
45 class MockPlatformWheelEvent : public PlatformWheelEvent { | 45 class MockPlatformWheelEvent : public PlatformWheelEvent { |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 EXPECT_FALSE(handleWheelEvent(AllowRubberband, DisallowScroll, PlatformWheel
EventPhaseMayBegin, deltaNone)); | 164 EXPECT_FALSE(handleWheelEvent(AllowRubberband, DisallowScroll, PlatformWheel
EventPhaseMayBegin, deltaNone)); |
165 | 165 |
166 // TODO(erikchen): This logic is incorrect. The zero delta event should not
have been handled. crbug.com/375512 | 166 // TODO(erikchen): This logic is incorrect. The zero delta event should not
have been handled. crbug.com/375512 |
167 EXPECT_TRUE(handleWheelEvent(AllowRubberband, DisallowScroll, PlatformWheelE
ventPhaseBegan, deltaNone)); | 167 EXPECT_TRUE(handleWheelEvent(AllowRubberband, DisallowScroll, PlatformWheelE
ventPhaseBegan, deltaNone)); |
168 EXPECT_FALSE(handleWheelEvent(AllowRubberband, DisallowScroll, PlatformWheel
EventPhaseChanged, deltaNone)); | 168 EXPECT_FALSE(handleWheelEvent(AllowRubberband, DisallowScroll, PlatformWheel
EventPhaseChanged, deltaNone)); |
169 EXPECT_TRUE(handleWheelEvent(AllowRubberband, DisallowScroll, PlatformWheelE
ventPhaseChanged, deltaLeft)); | 169 EXPECT_TRUE(handleWheelEvent(AllowRubberband, DisallowScroll, PlatformWheelE
ventPhaseChanged, deltaLeft)); |
170 EXPECT_TRUE(handleWheelEvent(AllowRubberband, DisallowScroll, PlatformWheelE
ventPhaseEnded, deltaNone)); | 170 EXPECT_TRUE(handleWheelEvent(AllowRubberband, DisallowScroll, PlatformWheelE
ventPhaseEnded, deltaNone)); |
171 } | 171 } |
172 | 172 |
173 } // namespace blink | 173 } // namespace blink |
OLD | NEW |