OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
jbroman
2016/05/13 17:35:49
This file is not listed in the build files; please
Bret
2016/05/13 22:11:00
Done. The other test support files like ScrollbarT
| |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef ScrollbarTestSuite_h | |
6 #define ScrollbarTestSuite_h | |
7 | |
8 #include "platform/heap/GarbageCollected.h" | |
9 #include "platform/scroll/ScrollableArea.h" | |
10 #include "platform/scroll/Scrollbar.h" | |
11 #include "platform/scroll/ScrollbarThemeMock.h" | |
12 #include "platform/testing/TestingPlatformSupport.h" | |
13 #include "testing/gmock/include/gmock/gmock.h" | |
14 | |
15 namespace blink { | |
16 | |
17 class MockScrollableArea : public GarbageCollectedFinalized<MockScrollableArea>, public ScrollableArea { | |
18 USING_GARBAGE_COLLECTED_MIXIN(MockScrollableArea); | |
19 | |
20 public: | |
21 static MockScrollableArea* create() | |
22 { | |
23 return new MockScrollableArea(); | |
24 } | |
25 | |
26 static MockScrollableArea* create(const IntPoint& maximumScrollPosition) | |
27 { | |
28 MockScrollableArea* mock = create(); | |
29 mock->setMaximumScrollPosition(maximumScrollPosition); | |
30 return mock; | |
31 } | |
32 | |
33 MOCK_CONST_METHOD0(visualRectForScrollbarParts, LayoutRect()); | |
34 MOCK_CONST_METHOD0(isActive, bool()); | |
35 MOCK_CONST_METHOD1(scrollSize, int(ScrollbarOrientation)); | |
36 MOCK_CONST_METHOD0(isScrollCornerVisible, bool()); | |
37 MOCK_CONST_METHOD0(scrollCornerRect, IntRect()); | |
38 MOCK_CONST_METHOD0(horizontalScrollbar, Scrollbar*()); | |
39 MOCK_CONST_METHOD0(verticalScrollbar, Scrollbar*()); | |
40 MOCK_CONST_METHOD0(enclosingScrollableArea, ScrollableArea*()); | |
41 MOCK_CONST_METHOD1(visibleContentRect, IntRect(IncludeScrollbarsInRect)); | |
42 MOCK_CONST_METHOD0(contentsSize, IntSize()); | |
43 MOCK_CONST_METHOD0(scrollableAreaBoundingBox, IntRect()); | |
44 MOCK_CONST_METHOD0(layerForHorizontalScrollbar, GraphicsLayer*()); | |
45 MOCK_CONST_METHOD0(layerForVerticalScrollbar, GraphicsLayer*()); | |
46 | |
47 bool userInputScrollable(ScrollbarOrientation) const override { return true; } | |
48 bool scrollbarsCanBeActive() const override { return true; } | |
49 bool shouldPlaceVerticalScrollbarOnLeft() const override { return false; } | |
50 void setScrollOffset(const DoublePoint& offset, ScrollType) override { m_scr ollPosition = flooredIntPoint(offset).shrunkTo(m_maximumScrollPosition); } | |
51 IntPoint scrollPosition() const override { return m_scrollPosition; } | |
52 IntPoint minimumScrollPosition() const override { return IntPoint(); } | |
53 IntPoint maximumScrollPosition() const override { return m_maximumScrollPosi tion; } | |
54 int visibleHeight() const override { return 768; } | |
55 int visibleWidth() const override { return 1024; } | |
56 bool scrollAnimatorEnabled() const override { return false; } | |
57 int pageStep(ScrollbarOrientation) const override { return 0; } | |
58 void scrollControlWasSetNeedsPaintInvalidation() {} | |
59 | |
60 using ScrollableArea::horizontalScrollbarNeedsPaintInvalidation; | |
61 using ScrollableArea::verticalScrollbarNeedsPaintInvalidation; | |
62 using ScrollableArea::clearNeedsPaintInvalidationForScrollControls; | |
63 | |
64 DEFINE_INLINE_VIRTUAL_TRACE() | |
65 { | |
66 ScrollableArea::trace(visitor); | |
67 } | |
68 | |
69 private: | |
70 void setMaximumScrollPosition(const IntPoint& maximumScrollPosition) | |
71 { | |
72 m_maximumScrollPosition = maximumScrollPosition; | |
73 } | |
74 | |
75 explicit MockScrollableArea() | |
76 : m_maximumScrollPosition(IntPoint(0, 100)) | |
77 { | |
78 } | |
79 | |
80 IntPoint m_scrollPosition; | |
81 IntPoint m_maximumScrollPosition; | |
82 }; | |
83 | |
84 class ScrollbarTestSuite : public testing::Test { | |
85 public: | |
86 ScrollbarTestSuite() {} | |
87 | |
88 void SetUp() override | |
89 { | |
90 TestingPlatformSupport::Config config; | |
91 config.compositorSupport = Platform::current()->compositorSupport(); | |
92 m_fakePlatform = adoptPtr(new TestingPlatformSupportWithMockScheduler(co nfig)); | |
93 } | |
94 | |
95 void TearDown() override | |
96 { | |
97 m_fakePlatform = nullptr; | |
98 } | |
99 | |
100 private: | |
101 OwnPtr<TestingPlatformSupportWithMockScheduler> m_fakePlatform; | |
102 }; | |
103 | |
104 } // namespace blink | |
105 | |
106 #endif | |
OLD | NEW |