Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Side by Side Diff: third_party/WebKit/Source/platform/scroll/ScrollableAreaTest.cpp

Issue 2621393003: Remove ScrollbarTestSuite from platform/scroll (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 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 "platform/scroll/ScrollableArea.h" 5 #include "platform/scroll/ScrollableArea.h"
6 6
7 #include "platform/graphics/Color.h" 7 #include "platform/graphics/Color.h"
8 #include "platform/graphics/GraphicsLayer.h" 8 #include "platform/graphics/GraphicsLayer.h"
9 #include "platform/scroll/ScrollbarTestSuite.h" 9 #include "platform/scroll/ScrollbarTestSuite.h"
10 #include "platform/scroll/ScrollbarTheme.h" 10 #include "platform/scroll/ScrollbarTheme.h"
(...skipping 14 matching lines...) Expand all
25 25
26 class ScrollbarThemeWithMockInvalidation : public ScrollbarThemeMock { 26 class ScrollbarThemeWithMockInvalidation : public ScrollbarThemeMock {
27 public: 27 public:
28 MOCK_CONST_METHOD0(shouldRepaintAllPartsOnInvalidation, bool()); 28 MOCK_CONST_METHOD0(shouldRepaintAllPartsOnInvalidation, bool());
29 MOCK_CONST_METHOD3(invalidateOnThumbPositionChange, 29 MOCK_CONST_METHOD3(invalidateOnThumbPositionChange,
30 ScrollbarPart(const ScrollbarThemeClient&, float, float)); 30 ScrollbarPart(const ScrollbarThemeClient&, float, float));
31 }; 31 };
32 32
33 } // namespace 33 } // namespace
34 34
35 class ScrollableAreaTest : public ScrollbarTestSuite {}; 35 using ScrollableAreaTest = testing::Test;
36 36
37 TEST_F(ScrollableAreaTest, ScrollAnimatorCurrentPositionShouldBeSync) { 37 TEST_F(ScrollableAreaTest, ScrollAnimatorCurrentPositionShouldBeSync) {
38 ScopedTestingPlatformSupport<TestingPlatformSupportWithMockScheduler, 38 ScopedTestingPlatformSupport<TestingPlatformSupportWithMockScheduler>
39 const TestingPlatformSupport::Config&> 39 platform;
40 platform(m_config);
41 40
42 MockScrollableArea* scrollableArea = 41 MockScrollableArea* scrollableArea =
43 MockScrollableArea::create(ScrollOffset(0, 100)); 42 MockScrollableArea::create(ScrollOffset(0, 100));
44 scrollableArea->setScrollOffset(ScrollOffset(0, 10000), CompositorScroll); 43 scrollableArea->setScrollOffset(ScrollOffset(0, 10000), CompositorScroll);
45 EXPECT_EQ(100.0, scrollableArea->scrollAnimator().currentOffset().height()); 44 EXPECT_EQ(100.0, scrollableArea->scrollAnimator().currentOffset().height());
46 } 45 }
47 46
48 TEST_F(ScrollableAreaTest, ScrollbarTrackAndThumbRepaint) { 47 TEST_F(ScrollableAreaTest, ScrollbarTrackAndThumbRepaint) {
49 ScopedTestingPlatformSupport<TestingPlatformSupportWithMockScheduler, 48 ScopedTestingPlatformSupport<TestingPlatformSupportWithMockScheduler>
50 const TestingPlatformSupport::Config&> 49 platform;
51 platform(m_config);
52 50
53 ScrollbarThemeWithMockInvalidation theme; 51 ScrollbarThemeWithMockInvalidation theme;
54 MockScrollableArea* scrollableArea = 52 MockScrollableArea* scrollableArea =
55 MockScrollableArea::create(ScrollOffset(0, 100)); 53 MockScrollableArea::create(ScrollOffset(0, 100));
56 Scrollbar* scrollbar = Scrollbar::createForTesting( 54 Scrollbar* scrollbar = Scrollbar::createForTesting(
57 scrollableArea, HorizontalScrollbar, RegularScrollbar, &theme); 55 scrollableArea, HorizontalScrollbar, RegularScrollbar, &theme);
58 56
59 EXPECT_CALL(theme, shouldRepaintAllPartsOnInvalidation()) 57 EXPECT_CALL(theme, shouldRepaintAllPartsOnInvalidation())
60 .WillRepeatedly(Return(true)); 58 .WillRepeatedly(Return(true));
61 EXPECT_TRUE(scrollbar->trackNeedsRepaint()); 59 EXPECT_TRUE(scrollbar->trackNeedsRepaint());
(...skipping 20 matching lines...) Expand all
82 EXPECT_FALSE(scrollbar->thumbNeedsRepaint()); 80 EXPECT_FALSE(scrollbar->thumbNeedsRepaint());
83 scrollbar->setNeedsPaintInvalidation(ThumbPart); 81 scrollbar->setNeedsPaintInvalidation(ThumbPart);
84 EXPECT_FALSE(scrollbar->trackNeedsRepaint()); 82 EXPECT_FALSE(scrollbar->trackNeedsRepaint());
85 EXPECT_TRUE(scrollbar->thumbNeedsRepaint()); 83 EXPECT_TRUE(scrollbar->thumbNeedsRepaint());
86 84
87 // Forced GC in order to finalize objects depending on the mock object. 85 // Forced GC in order to finalize objects depending on the mock object.
88 ThreadState::current()->collectAllGarbage(); 86 ThreadState::current()->collectAllGarbage();
89 } 87 }
90 88
91 TEST_F(ScrollableAreaTest, ScrollbarGraphicsLayerInvalidation) { 89 TEST_F(ScrollableAreaTest, ScrollbarGraphicsLayerInvalidation) {
92 ScopedTestingPlatformSupport<TestingPlatformSupportWithMockScheduler, 90 ScopedTestingPlatformSupport<TestingPlatformSupportWithMockScheduler>
93 const TestingPlatformSupport::Config&> 91 platform;
94 platform(m_config);
95 92
96 ScrollbarTheme::setMockScrollbarsEnabled(true); 93 ScrollbarTheme::setMockScrollbarsEnabled(true);
97 MockScrollableArea* scrollableArea = 94 MockScrollableArea* scrollableArea =
98 MockScrollableArea::create(ScrollOffset(0, 100)); 95 MockScrollableArea::create(ScrollOffset(0, 100));
99 FakeGraphicsLayerClient graphicsLayerClient; 96 FakeGraphicsLayerClient graphicsLayerClient;
100 graphicsLayerClient.setIsTrackingRasterInvalidations(true); 97 graphicsLayerClient.setIsTrackingRasterInvalidations(true);
101 FakeGraphicsLayer graphicsLayer(&graphicsLayerClient); 98 FakeGraphicsLayer graphicsLayer(&graphicsLayerClient);
102 graphicsLayer.setDrawsContent(true); 99 graphicsLayer.setDrawsContent(true);
103 graphicsLayer.setSize(FloatSize(111, 222)); 100 graphicsLayer.setSize(FloatSize(111, 222));
104 101
105 EXPECT_CALL(*scrollableArea, layerForHorizontalScrollbar()) 102 EXPECT_CALL(*scrollableArea, layerForHorizontalScrollbar())
106 .WillRepeatedly(Return(&graphicsLayer)); 103 .WillRepeatedly(Return(&graphicsLayer));
107 104
108 Scrollbar* scrollbar = Scrollbar::create(scrollableArea, HorizontalScrollbar, 105 Scrollbar* scrollbar = Scrollbar::create(scrollableArea, HorizontalScrollbar,
109 RegularScrollbar, nullptr); 106 RegularScrollbar, nullptr);
110 graphicsLayer.resetTrackedRasterInvalidations(); 107 graphicsLayer.resetTrackedRasterInvalidations();
111 scrollbar->setNeedsPaintInvalidation(NoPart); 108 scrollbar->setNeedsPaintInvalidation(NoPart);
112 EXPECT_TRUE(graphicsLayer.hasTrackedRasterInvalidations()); 109 EXPECT_TRUE(graphicsLayer.hasTrackedRasterInvalidations());
113 110
114 // Forced GC in order to finalize objects depending on the mock object. 111 // Forced GC in order to finalize objects depending on the mock object.
115 ThreadState::current()->collectAllGarbage(); 112 ThreadState::current()->collectAllGarbage();
116 } 113 }
117 114
118 TEST_F(ScrollableAreaTest, InvalidatesNonCompositedScrollbarsWhenThumbMoves) { 115 TEST_F(ScrollableAreaTest, InvalidatesNonCompositedScrollbarsWhenThumbMoves) {
119 ScopedTestingPlatformSupport<TestingPlatformSupportWithMockScheduler, 116 ScopedTestingPlatformSupport<TestingPlatformSupportWithMockScheduler>
120 const TestingPlatformSupport::Config&> 117 platform;
121 platform(m_config);
122 118
123 ScrollbarThemeWithMockInvalidation theme; 119 ScrollbarThemeWithMockInvalidation theme;
124 MockScrollableArea* scrollableArea = 120 MockScrollableArea* scrollableArea =
125 MockScrollableArea::create(ScrollOffset(100, 100)); 121 MockScrollableArea::create(ScrollOffset(100, 100));
126 Scrollbar* horizontalScrollbar = Scrollbar::createForTesting( 122 Scrollbar* horizontalScrollbar = Scrollbar::createForTesting(
127 scrollableArea, HorizontalScrollbar, RegularScrollbar, &theme); 123 scrollableArea, HorizontalScrollbar, RegularScrollbar, &theme);
128 Scrollbar* verticalScrollbar = Scrollbar::createForTesting( 124 Scrollbar* verticalScrollbar = Scrollbar::createForTesting(
129 scrollableArea, VerticalScrollbar, RegularScrollbar, &theme); 125 scrollableArea, VerticalScrollbar, RegularScrollbar, &theme);
130 EXPECT_CALL(*scrollableArea, horizontalScrollbar()) 126 EXPECT_CALL(*scrollableArea, horizontalScrollbar())
131 .WillRepeatedly(Return(horizontalScrollbar)); 127 .WillRepeatedly(Return(horizontalScrollbar));
(...skipping 21 matching lines...) Expand all
153 scrollableArea->setScrollOffset(ScrollOffset(50, 50), ProgrammaticScroll); 149 scrollableArea->setScrollOffset(ScrollOffset(50, 50), ProgrammaticScroll);
154 EXPECT_TRUE(scrollableArea->horizontalScrollbarNeedsPaintInvalidation()); 150 EXPECT_TRUE(scrollableArea->horizontalScrollbarNeedsPaintInvalidation());
155 EXPECT_FALSE(scrollableArea->verticalScrollbarNeedsPaintInvalidation()); 151 EXPECT_FALSE(scrollableArea->verticalScrollbarNeedsPaintInvalidation());
156 scrollableArea->clearNeedsPaintInvalidationForScrollControls(); 152 scrollableArea->clearNeedsPaintInvalidationForScrollControls();
157 153
158 // Forced GC in order to finalize objects depending on the mock object. 154 // Forced GC in order to finalize objects depending on the mock object.
159 ThreadState::current()->collectAllGarbage(); 155 ThreadState::current()->collectAllGarbage();
160 } 156 }
161 157
162 TEST_F(ScrollableAreaTest, InvalidatesCompositedScrollbarsIfPartsNeedRepaint) { 158 TEST_F(ScrollableAreaTest, InvalidatesCompositedScrollbarsIfPartsNeedRepaint) {
163 ScopedTestingPlatformSupport<TestingPlatformSupportWithMockScheduler, 159 ScopedTestingPlatformSupport<TestingPlatformSupportWithMockScheduler>
164 const TestingPlatformSupport::Config&> 160 platform;
165 platform(m_config);
166 161
167 ScrollbarThemeWithMockInvalidation theme; 162 ScrollbarThemeWithMockInvalidation theme;
168 MockScrollableArea* scrollableArea = 163 MockScrollableArea* scrollableArea =
169 MockScrollableArea::create(ScrollOffset(100, 100)); 164 MockScrollableArea::create(ScrollOffset(100, 100));
170 Scrollbar* horizontalScrollbar = Scrollbar::createForTesting( 165 Scrollbar* horizontalScrollbar = Scrollbar::createForTesting(
171 scrollableArea, HorizontalScrollbar, RegularScrollbar, &theme); 166 scrollableArea, HorizontalScrollbar, RegularScrollbar, &theme);
172 horizontalScrollbar->clearTrackNeedsRepaint(); 167 horizontalScrollbar->clearTrackNeedsRepaint();
173 horizontalScrollbar->clearThumbNeedsRepaint(); 168 horizontalScrollbar->clearThumbNeedsRepaint();
174 Scrollbar* verticalScrollbar = Scrollbar::createForTesting( 169 Scrollbar* verticalScrollbar = Scrollbar::createForTesting(
175 scrollableArea, VerticalScrollbar, RegularScrollbar, &theme); 170 scrollableArea, VerticalScrollbar, RegularScrollbar, &theme);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 EXPECT_FALSE(horizontalScrollbar->trackNeedsRepaint()); 230 EXPECT_FALSE(horizontalScrollbar->trackNeedsRepaint());
236 EXPECT_FALSE(horizontalScrollbar->thumbNeedsRepaint()); 231 EXPECT_FALSE(horizontalScrollbar->thumbNeedsRepaint());
237 EXPECT_FALSE(verticalScrollbar->trackNeedsRepaint()); 232 EXPECT_FALSE(verticalScrollbar->trackNeedsRepaint());
238 EXPECT_FALSE(verticalScrollbar->thumbNeedsRepaint()); 233 EXPECT_FALSE(verticalScrollbar->thumbNeedsRepaint());
239 234
240 // Forced GC in order to finalize objects depending on the mock object. 235 // Forced GC in order to finalize objects depending on the mock object.
241 ThreadState::current()->collectAllGarbage(); 236 ThreadState::current()->collectAllGarbage();
242 } 237 }
243 238
244 TEST_F(ScrollableAreaTest, RecalculatesScrollbarOverlayIfBackgroundChanges) { 239 TEST_F(ScrollableAreaTest, RecalculatesScrollbarOverlayIfBackgroundChanges) {
245 ScopedTestingPlatformSupport<TestingPlatformSupportWithMockScheduler, 240 ScopedTestingPlatformSupport<TestingPlatformSupportWithMockScheduler>
246 const TestingPlatformSupport::Config&> 241 platform;
247 platform(m_config);
248 242
249 MockScrollableArea* scrollableArea = 243 MockScrollableArea* scrollableArea =
250 MockScrollableArea::create(ScrollOffset(0, 100)); 244 MockScrollableArea::create(ScrollOffset(0, 100));
251 245
252 EXPECT_EQ(ScrollbarOverlayColorThemeDark, 246 EXPECT_EQ(ScrollbarOverlayColorThemeDark,
253 scrollableArea->getScrollbarOverlayColorTheme()); 247 scrollableArea->getScrollbarOverlayColorTheme());
254 scrollableArea->recalculateScrollbarOverlayColorTheme(Color(34, 85, 51)); 248 scrollableArea->recalculateScrollbarOverlayColorTheme(Color(34, 85, 51));
255 EXPECT_EQ(ScrollbarOverlayColorThemeLight, 249 EXPECT_EQ(ScrollbarOverlayColorThemeLight,
256 scrollableArea->getScrollbarOverlayColorTheme()); 250 scrollableArea->getScrollbarOverlayColorTheme());
257 scrollableArea->recalculateScrollbarOverlayColorTheme(Color(236, 143, 185)); 251 scrollableArea->recalculateScrollbarOverlayColorTheme(Color(236, 143, 185));
258 EXPECT_EQ(ScrollbarOverlayColorThemeDark, 252 EXPECT_EQ(ScrollbarOverlayColorThemeDark,
259 scrollableArea->getScrollbarOverlayColorTheme()); 253 scrollableArea->getScrollbarOverlayColorTheme());
260 } 254 }
261 255
262 } // namespace blink 256 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698