OLD | NEW |
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/ScrollbarTheme.h" | 9 #include "platform/scroll/ScrollbarTheme.h" |
10 #include "platform/scroll/ScrollbarThemeMock.h" | 10 #include "platform/scroll/ScrollbarThemeMock.h" |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 EXPECT_CALL(theme, shouldRepaintAllPartsOnInvalidation()).WillRepeatedly(Ret
urn(false)); | 139 EXPECT_CALL(theme, shouldRepaintAllPartsOnInvalidation()).WillRepeatedly(Ret
urn(false)); |
140 scrollbar->clearTrackNeedsRepaint(); | 140 scrollbar->clearTrackNeedsRepaint(); |
141 scrollbar->clearThumbNeedsRepaint(); | 141 scrollbar->clearThumbNeedsRepaint(); |
142 EXPECT_FALSE(scrollbar->trackNeedsRepaint()); | 142 EXPECT_FALSE(scrollbar->trackNeedsRepaint()); |
143 EXPECT_FALSE(scrollbar->thumbNeedsRepaint()); | 143 EXPECT_FALSE(scrollbar->thumbNeedsRepaint()); |
144 scrollbar->setNeedsPaintInvalidation(ThumbPart); | 144 scrollbar->setNeedsPaintInvalidation(ThumbPart); |
145 EXPECT_FALSE(scrollbar->trackNeedsRepaint()); | 145 EXPECT_FALSE(scrollbar->trackNeedsRepaint()); |
146 EXPECT_TRUE(scrollbar->thumbNeedsRepaint()); | 146 EXPECT_TRUE(scrollbar->thumbNeedsRepaint()); |
147 | 147 |
148 // Forced GC in order to finalize objects depending on the mock object. | 148 // Forced GC in order to finalize objects depending on the mock object. |
149 Heap::collectAllGarbage(); | 149 ThreadHeap::collectAllGarbage(); |
150 } | 150 } |
151 | 151 |
152 TEST_F(ScrollableAreaTest, ScrollbarGraphicsLayerInvalidation) | 152 TEST_F(ScrollableAreaTest, ScrollbarGraphicsLayerInvalidation) |
153 { | 153 { |
154 ScrollbarTheme::setMockScrollbarsEnabled(true); | 154 ScrollbarTheme::setMockScrollbarsEnabled(true); |
155 MockScrollableArea* scrollableArea = MockScrollableArea::create(IntPoint(0,
100)); | 155 MockScrollableArea* scrollableArea = MockScrollableArea::create(IntPoint(0,
100)); |
156 FakeGraphicsLayerClient graphicsLayerClient; | 156 FakeGraphicsLayerClient graphicsLayerClient; |
157 graphicsLayerClient.setIsTrackingPaintInvalidations(true); | 157 graphicsLayerClient.setIsTrackingPaintInvalidations(true); |
158 FakeGraphicsLayer graphicsLayer(&graphicsLayerClient); | 158 FakeGraphicsLayer graphicsLayer(&graphicsLayerClient); |
159 graphicsLayer.setDrawsContent(true); | 159 graphicsLayer.setDrawsContent(true); |
160 graphicsLayer.setSize(FloatSize(111, 222)); | 160 graphicsLayer.setSize(FloatSize(111, 222)); |
161 | 161 |
162 EXPECT_CALL(*scrollableArea, layerForHorizontalScrollbar()).WillRepeatedly(R
eturn(&graphicsLayer)); | 162 EXPECT_CALL(*scrollableArea, layerForHorizontalScrollbar()).WillRepeatedly(R
eturn(&graphicsLayer)); |
163 | 163 |
164 Scrollbar* scrollbar = Scrollbar::create(scrollableArea, HorizontalScrollbar
, RegularScrollbar, nullptr); | 164 Scrollbar* scrollbar = Scrollbar::create(scrollableArea, HorizontalScrollbar
, RegularScrollbar, nullptr); |
165 graphicsLayer.resetTrackedPaintInvalidations(); | 165 graphicsLayer.resetTrackedPaintInvalidations(); |
166 scrollbar->setNeedsPaintInvalidation(NoPart); | 166 scrollbar->setNeedsPaintInvalidation(NoPart); |
167 EXPECT_TRUE(graphicsLayer.hasTrackedPaintInvalidations()); | 167 EXPECT_TRUE(graphicsLayer.hasTrackedPaintInvalidations()); |
168 | 168 |
169 // Forced GC in order to finalize objects depending on the mock object. | 169 // Forced GC in order to finalize objects depending on the mock object. |
170 Heap::collectAllGarbage(); | 170 ThreadHeap::collectAllGarbage(); |
171 } | 171 } |
172 | 172 |
173 TEST_F(ScrollableAreaTest, InvalidatesNonCompositedScrollbarsWhenThumbMoves) | 173 TEST_F(ScrollableAreaTest, InvalidatesNonCompositedScrollbarsWhenThumbMoves) |
174 { | 174 { |
175 ScrollbarThemeWithMockInvalidation theme; | 175 ScrollbarThemeWithMockInvalidation theme; |
176 MockScrollableArea* scrollableArea = MockScrollableArea::create(IntPoint(100
, 100)); | 176 MockScrollableArea* scrollableArea = MockScrollableArea::create(IntPoint(100
, 100)); |
177 Scrollbar* horizontalScrollbar = Scrollbar::createForTesting(scrollableArea,
HorizontalScrollbar, RegularScrollbar, &theme); | 177 Scrollbar* horizontalScrollbar = Scrollbar::createForTesting(scrollableArea,
HorizontalScrollbar, RegularScrollbar, &theme); |
178 Scrollbar* verticalScrollbar = Scrollbar::createForTesting(scrollableArea, V
erticalScrollbar, RegularScrollbar, &theme); | 178 Scrollbar* verticalScrollbar = Scrollbar::createForTesting(scrollableArea, V
erticalScrollbar, RegularScrollbar, &theme); |
179 EXPECT_CALL(*scrollableArea, horizontalScrollbar()).WillRepeatedly(Return(ho
rizontalScrollbar)); | 179 EXPECT_CALL(*scrollableArea, horizontalScrollbar()).WillRepeatedly(Return(ho
rizontalScrollbar)); |
180 EXPECT_CALL(*scrollableArea, verticalScrollbar()).WillRepeatedly(Return(vert
icalScrollbar)); | 180 EXPECT_CALL(*scrollableArea, verticalScrollbar()).WillRepeatedly(Return(vert
icalScrollbar)); |
(...skipping 11 matching lines...) Expand all Loading... |
192 scrollableArea->setScrollPosition(DoublePoint(0, 50), ProgrammaticScroll); | 192 scrollableArea->setScrollPosition(DoublePoint(0, 50), ProgrammaticScroll); |
193 EXPECT_FALSE(scrollableArea->horizontalScrollbarNeedsPaintInvalidation()); | 193 EXPECT_FALSE(scrollableArea->horizontalScrollbarNeedsPaintInvalidation()); |
194 EXPECT_TRUE(scrollableArea->verticalScrollbarNeedsPaintInvalidation()); | 194 EXPECT_TRUE(scrollableArea->verticalScrollbarNeedsPaintInvalidation()); |
195 scrollableArea->clearNeedsPaintInvalidationForScrollControls(); | 195 scrollableArea->clearNeedsPaintInvalidationForScrollControls(); |
196 scrollableArea->setScrollPosition(DoublePoint(50, 50), ProgrammaticScroll); | 196 scrollableArea->setScrollPosition(DoublePoint(50, 50), ProgrammaticScroll); |
197 EXPECT_TRUE(scrollableArea->horizontalScrollbarNeedsPaintInvalidation()); | 197 EXPECT_TRUE(scrollableArea->horizontalScrollbarNeedsPaintInvalidation()); |
198 EXPECT_FALSE(scrollableArea->verticalScrollbarNeedsPaintInvalidation()); | 198 EXPECT_FALSE(scrollableArea->verticalScrollbarNeedsPaintInvalidation()); |
199 scrollableArea->clearNeedsPaintInvalidationForScrollControls(); | 199 scrollableArea->clearNeedsPaintInvalidationForScrollControls(); |
200 | 200 |
201 // Forced GC in order to finalize objects depending on the mock object. | 201 // Forced GC in order to finalize objects depending on the mock object. |
202 Heap::collectAllGarbage(); | 202 ThreadHeap::collectAllGarbage(); |
203 } | 203 } |
204 | 204 |
205 TEST_F(ScrollableAreaTest, InvalidatesCompositedScrollbarsIfPartsNeedRepaint) | 205 TEST_F(ScrollableAreaTest, InvalidatesCompositedScrollbarsIfPartsNeedRepaint) |
206 { | 206 { |
207 ScrollbarThemeWithMockInvalidation theme; | 207 ScrollbarThemeWithMockInvalidation theme; |
208 MockScrollableArea* scrollableArea = MockScrollableArea::create(IntPoint(100
, 100)); | 208 MockScrollableArea* scrollableArea = MockScrollableArea::create(IntPoint(100
, 100)); |
209 Scrollbar* horizontalScrollbar = Scrollbar::createForTesting(scrollableArea,
HorizontalScrollbar, RegularScrollbar, &theme); | 209 Scrollbar* horizontalScrollbar = Scrollbar::createForTesting(scrollableArea,
HorizontalScrollbar, RegularScrollbar, &theme); |
210 horizontalScrollbar->clearTrackNeedsRepaint(); | 210 horizontalScrollbar->clearTrackNeedsRepaint(); |
211 horizontalScrollbar->clearThumbNeedsRepaint(); | 211 horizontalScrollbar->clearThumbNeedsRepaint(); |
212 Scrollbar* verticalScrollbar = Scrollbar::createForTesting(scrollableArea, V
erticalScrollbar, RegularScrollbar, &theme); | 212 Scrollbar* verticalScrollbar = Scrollbar::createForTesting(scrollableArea, V
erticalScrollbar, RegularScrollbar, &theme); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 EXPECT_CALL(theme, invalidateOnThumbPositionChange(_, _, _)).Times(2).WillRe
peatedly(Return(NoPart)); | 259 EXPECT_CALL(theme, invalidateOnThumbPositionChange(_, _, _)).Times(2).WillRe
peatedly(Return(NoPart)); |
260 scrollableArea->setScrollPosition(DoublePoint(70, 70), ProgrammaticScroll); | 260 scrollableArea->setScrollPosition(DoublePoint(70, 70), ProgrammaticScroll); |
261 EXPECT_TRUE(layerForHorizontalScrollbar.hasTrackedPaintInvalidations()); | 261 EXPECT_TRUE(layerForHorizontalScrollbar.hasTrackedPaintInvalidations()); |
262 EXPECT_TRUE(layerForVerticalScrollbar.hasTrackedPaintInvalidations()); | 262 EXPECT_TRUE(layerForVerticalScrollbar.hasTrackedPaintInvalidations()); |
263 EXPECT_FALSE(horizontalScrollbar->trackNeedsRepaint()); | 263 EXPECT_FALSE(horizontalScrollbar->trackNeedsRepaint()); |
264 EXPECT_FALSE(horizontalScrollbar->thumbNeedsRepaint()); | 264 EXPECT_FALSE(horizontalScrollbar->thumbNeedsRepaint()); |
265 EXPECT_FALSE(verticalScrollbar->trackNeedsRepaint()); | 265 EXPECT_FALSE(verticalScrollbar->trackNeedsRepaint()); |
266 EXPECT_FALSE(verticalScrollbar->thumbNeedsRepaint()); | 266 EXPECT_FALSE(verticalScrollbar->thumbNeedsRepaint()); |
267 | 267 |
268 // Forced GC in order to finalize objects depending on the mock object. | 268 // Forced GC in order to finalize objects depending on the mock object. |
269 Heap::collectAllGarbage(); | 269 ThreadHeap::collectAllGarbage(); |
270 } | 270 } |
271 | 271 |
272 TEST_F(ScrollableAreaTest, RecalculatesScrollbarOverlayIfBackgroundChanges) | 272 TEST_F(ScrollableAreaTest, RecalculatesScrollbarOverlayIfBackgroundChanges) |
273 { | 273 { |
274 MockScrollableArea* scrollableArea = MockScrollableArea::create(IntPoint(0,
100)); | 274 MockScrollableArea* scrollableArea = MockScrollableArea::create(IntPoint(0,
100)); |
275 | 275 |
276 EXPECT_EQ(ScrollbarOverlayStyleDefault, scrollableArea->getScrollbarOverlayS
tyle()); | 276 EXPECT_EQ(ScrollbarOverlayStyleDefault, scrollableArea->getScrollbarOverlayS
tyle()); |
277 scrollableArea->recalculateScrollbarOverlayStyle(Color(34, 85, 51)); | 277 scrollableArea->recalculateScrollbarOverlayStyle(Color(34, 85, 51)); |
278 EXPECT_EQ(ScrollbarOverlayStyleLight, scrollableArea->getScrollbarOverlaySty
le()); | 278 EXPECT_EQ(ScrollbarOverlayStyleLight, scrollableArea->getScrollbarOverlaySty
le()); |
279 scrollableArea->recalculateScrollbarOverlayStyle(Color(236, 143, 185)); | 279 scrollableArea->recalculateScrollbarOverlayStyle(Color(236, 143, 185)); |
280 EXPECT_EQ(ScrollbarOverlayStyleDefault, scrollableArea->getScrollbarOverlayS
tyle()); | 280 EXPECT_EQ(ScrollbarOverlayStyleDefault, scrollableArea->getScrollbarOverlayS
tyle()); |
281 } | 281 } |
282 | 282 |
283 } // namespace blink | 283 } // namespace blink |
OLD | NEW |