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

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

Issue 2321223003: Revert of Move collectGarbage* methods to ThreadState (Closed)
Patch Set: Created 4 years, 3 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 EXPECT_CALL(theme, shouldRepaintAllPartsOnInvalidation()).WillRepeatedly(Ret urn(false)); 67 EXPECT_CALL(theme, shouldRepaintAllPartsOnInvalidation()).WillRepeatedly(Ret urn(false));
68 scrollbar->clearTrackNeedsRepaint(); 68 scrollbar->clearTrackNeedsRepaint();
69 scrollbar->clearThumbNeedsRepaint(); 69 scrollbar->clearThumbNeedsRepaint();
70 EXPECT_FALSE(scrollbar->trackNeedsRepaint()); 70 EXPECT_FALSE(scrollbar->trackNeedsRepaint());
71 EXPECT_FALSE(scrollbar->thumbNeedsRepaint()); 71 EXPECT_FALSE(scrollbar->thumbNeedsRepaint());
72 scrollbar->setNeedsPaintInvalidation(ThumbPart); 72 scrollbar->setNeedsPaintInvalidation(ThumbPart);
73 EXPECT_FALSE(scrollbar->trackNeedsRepaint()); 73 EXPECT_FALSE(scrollbar->trackNeedsRepaint());
74 EXPECT_TRUE(scrollbar->thumbNeedsRepaint()); 74 EXPECT_TRUE(scrollbar->thumbNeedsRepaint());
75 75
76 // Forced GC in order to finalize objects depending on the mock object. 76 // Forced GC in order to finalize objects depending on the mock object.
77 ThreadState::current()-> collectAllGarbage(); 77 ThreadHeap::collectAllGarbage();
78 } 78 }
79 79
80 TEST_F(ScrollableAreaTest, ScrollbarGraphicsLayerInvalidation) 80 TEST_F(ScrollableAreaTest, ScrollbarGraphicsLayerInvalidation)
81 { 81 {
82 ScrollbarTheme::setMockScrollbarsEnabled(true); 82 ScrollbarTheme::setMockScrollbarsEnabled(true);
83 MockScrollableArea* scrollableArea = MockScrollableArea::create(IntPoint(0, 100)); 83 MockScrollableArea* scrollableArea = MockScrollableArea::create(IntPoint(0, 100));
84 FakeGraphicsLayerClient graphicsLayerClient; 84 FakeGraphicsLayerClient graphicsLayerClient;
85 graphicsLayerClient.setIsTrackingPaintInvalidations(true); 85 graphicsLayerClient.setIsTrackingPaintInvalidations(true);
86 FakeGraphicsLayer graphicsLayer(&graphicsLayerClient); 86 FakeGraphicsLayer graphicsLayer(&graphicsLayerClient);
87 graphicsLayer.setDrawsContent(true); 87 graphicsLayer.setDrawsContent(true);
88 graphicsLayer.setSize(FloatSize(111, 222)); 88 graphicsLayer.setSize(FloatSize(111, 222));
89 89
90 EXPECT_CALL(*scrollableArea, layerForHorizontalScrollbar()).WillRepeatedly(R eturn(&graphicsLayer)); 90 EXPECT_CALL(*scrollableArea, layerForHorizontalScrollbar()).WillRepeatedly(R eturn(&graphicsLayer));
91 91
92 Scrollbar* scrollbar = Scrollbar::create(scrollableArea, HorizontalScrollbar , RegularScrollbar, nullptr); 92 Scrollbar* scrollbar = Scrollbar::create(scrollableArea, HorizontalScrollbar , RegularScrollbar, nullptr);
93 graphicsLayer.resetTrackedPaintInvalidations(); 93 graphicsLayer.resetTrackedPaintInvalidations();
94 scrollbar->setNeedsPaintInvalidation(NoPart); 94 scrollbar->setNeedsPaintInvalidation(NoPart);
95 EXPECT_TRUE(graphicsLayer.hasTrackedPaintInvalidations()); 95 EXPECT_TRUE(graphicsLayer.hasTrackedPaintInvalidations());
96 96
97 // Forced GC in order to finalize objects depending on the mock object. 97 // Forced GC in order to finalize objects depending on the mock object.
98 ThreadState::current()-> collectAllGarbage(); 98 ThreadHeap::collectAllGarbage();
99 } 99 }
100 100
101 TEST_F(ScrollableAreaTest, InvalidatesNonCompositedScrollbarsWhenThumbMoves) 101 TEST_F(ScrollableAreaTest, InvalidatesNonCompositedScrollbarsWhenThumbMoves)
102 { 102 {
103 ScrollbarThemeWithMockInvalidation theme; 103 ScrollbarThemeWithMockInvalidation theme;
104 MockScrollableArea* scrollableArea = MockScrollableArea::create(IntPoint(100 , 100)); 104 MockScrollableArea* scrollableArea = MockScrollableArea::create(IntPoint(100 , 100));
105 Scrollbar* horizontalScrollbar = Scrollbar::createForTesting(scrollableArea, HorizontalScrollbar, RegularScrollbar, &theme); 105 Scrollbar* horizontalScrollbar = Scrollbar::createForTesting(scrollableArea, HorizontalScrollbar, RegularScrollbar, &theme);
106 Scrollbar* verticalScrollbar = Scrollbar::createForTesting(scrollableArea, V erticalScrollbar, RegularScrollbar, &theme); 106 Scrollbar* verticalScrollbar = Scrollbar::createForTesting(scrollableArea, V erticalScrollbar, RegularScrollbar, &theme);
107 EXPECT_CALL(*scrollableArea, horizontalScrollbar()).WillRepeatedly(Return(ho rizontalScrollbar)); 107 EXPECT_CALL(*scrollableArea, horizontalScrollbar()).WillRepeatedly(Return(ho rizontalScrollbar));
108 EXPECT_CALL(*scrollableArea, verticalScrollbar()).WillRepeatedly(Return(vert icalScrollbar)); 108 EXPECT_CALL(*scrollableArea, verticalScrollbar()).WillRepeatedly(Return(vert icalScrollbar));
(...skipping 11 matching lines...) Expand all
120 scrollableArea->setScrollPosition(DoublePoint(0, 50), ProgrammaticScroll); 120 scrollableArea->setScrollPosition(DoublePoint(0, 50), ProgrammaticScroll);
121 EXPECT_FALSE(scrollableArea->horizontalScrollbarNeedsPaintInvalidation()); 121 EXPECT_FALSE(scrollableArea->horizontalScrollbarNeedsPaintInvalidation());
122 EXPECT_TRUE(scrollableArea->verticalScrollbarNeedsPaintInvalidation()); 122 EXPECT_TRUE(scrollableArea->verticalScrollbarNeedsPaintInvalidation());
123 scrollableArea->clearNeedsPaintInvalidationForScrollControls(); 123 scrollableArea->clearNeedsPaintInvalidationForScrollControls();
124 scrollableArea->setScrollPosition(DoublePoint(50, 50), ProgrammaticScroll); 124 scrollableArea->setScrollPosition(DoublePoint(50, 50), ProgrammaticScroll);
125 EXPECT_TRUE(scrollableArea->horizontalScrollbarNeedsPaintInvalidation()); 125 EXPECT_TRUE(scrollableArea->horizontalScrollbarNeedsPaintInvalidation());
126 EXPECT_FALSE(scrollableArea->verticalScrollbarNeedsPaintInvalidation()); 126 EXPECT_FALSE(scrollableArea->verticalScrollbarNeedsPaintInvalidation());
127 scrollableArea->clearNeedsPaintInvalidationForScrollControls(); 127 scrollableArea->clearNeedsPaintInvalidationForScrollControls();
128 128
129 // Forced GC in order to finalize objects depending on the mock object. 129 // Forced GC in order to finalize objects depending on the mock object.
130 ThreadState::current()-> collectAllGarbage(); 130 ThreadHeap::collectAllGarbage();
131 } 131 }
132 132
133 TEST_F(ScrollableAreaTest, InvalidatesCompositedScrollbarsIfPartsNeedRepaint) 133 TEST_F(ScrollableAreaTest, InvalidatesCompositedScrollbarsIfPartsNeedRepaint)
134 { 134 {
135 ScrollbarThemeWithMockInvalidation theme; 135 ScrollbarThemeWithMockInvalidation theme;
136 MockScrollableArea* scrollableArea = MockScrollableArea::create(IntPoint(100 , 100)); 136 MockScrollableArea* scrollableArea = MockScrollableArea::create(IntPoint(100 , 100));
137 Scrollbar* horizontalScrollbar = Scrollbar::createForTesting(scrollableArea, HorizontalScrollbar, RegularScrollbar, &theme); 137 Scrollbar* horizontalScrollbar = Scrollbar::createForTesting(scrollableArea, HorizontalScrollbar, RegularScrollbar, &theme);
138 horizontalScrollbar->clearTrackNeedsRepaint(); 138 horizontalScrollbar->clearTrackNeedsRepaint();
139 horizontalScrollbar->clearThumbNeedsRepaint(); 139 horizontalScrollbar->clearThumbNeedsRepaint();
140 Scrollbar* verticalScrollbar = Scrollbar::createForTesting(scrollableArea, V erticalScrollbar, RegularScrollbar, &theme); 140 Scrollbar* verticalScrollbar = Scrollbar::createForTesting(scrollableArea, V erticalScrollbar, RegularScrollbar, &theme);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 EXPECT_CALL(theme, invalidateOnThumbPositionChange(_, _, _)).Times(2).WillRe peatedly(Return(NoPart)); 187 EXPECT_CALL(theme, invalidateOnThumbPositionChange(_, _, _)).Times(2).WillRe peatedly(Return(NoPart));
188 scrollableArea->setScrollPosition(DoublePoint(70, 70), ProgrammaticScroll); 188 scrollableArea->setScrollPosition(DoublePoint(70, 70), ProgrammaticScroll);
189 EXPECT_TRUE(layerForHorizontalScrollbar.hasTrackedPaintInvalidations()); 189 EXPECT_TRUE(layerForHorizontalScrollbar.hasTrackedPaintInvalidations());
190 EXPECT_TRUE(layerForVerticalScrollbar.hasTrackedPaintInvalidations()); 190 EXPECT_TRUE(layerForVerticalScrollbar.hasTrackedPaintInvalidations());
191 EXPECT_FALSE(horizontalScrollbar->trackNeedsRepaint()); 191 EXPECT_FALSE(horizontalScrollbar->trackNeedsRepaint());
192 EXPECT_FALSE(horizontalScrollbar->thumbNeedsRepaint()); 192 EXPECT_FALSE(horizontalScrollbar->thumbNeedsRepaint());
193 EXPECT_FALSE(verticalScrollbar->trackNeedsRepaint()); 193 EXPECT_FALSE(verticalScrollbar->trackNeedsRepaint());
194 EXPECT_FALSE(verticalScrollbar->thumbNeedsRepaint()); 194 EXPECT_FALSE(verticalScrollbar->thumbNeedsRepaint());
195 195
196 // Forced GC in order to finalize objects depending on the mock object. 196 // Forced GC in order to finalize objects depending on the mock object.
197 ThreadState::current()-> collectAllGarbage(); 197 ThreadHeap::collectAllGarbage();
198 } 198 }
199 199
200 TEST_F(ScrollableAreaTest, RecalculatesScrollbarOverlayIfBackgroundChanges) 200 TEST_F(ScrollableAreaTest, RecalculatesScrollbarOverlayIfBackgroundChanges)
201 { 201 {
202 MockScrollableArea* scrollableArea = MockScrollableArea::create(IntPoint(0, 100)); 202 MockScrollableArea* scrollableArea = MockScrollableArea::create(IntPoint(0, 100));
203 203
204 EXPECT_EQ(ScrollbarOverlayStyleDefault, scrollableArea->getScrollbarOverlayS tyle()); 204 EXPECT_EQ(ScrollbarOverlayStyleDefault, scrollableArea->getScrollbarOverlayS tyle());
205 scrollableArea->recalculateScrollbarOverlayStyle(Color(34, 85, 51)); 205 scrollableArea->recalculateScrollbarOverlayStyle(Color(34, 85, 51));
206 EXPECT_EQ(ScrollbarOverlayStyleLight, scrollableArea->getScrollbarOverlaySty le()); 206 EXPECT_EQ(ScrollbarOverlayStyleLight, scrollableArea->getScrollbarOverlaySty le());
207 scrollableArea->recalculateScrollbarOverlayStyle(Color(236, 143, 185)); 207 scrollableArea->recalculateScrollbarOverlayStyle(Color(236, 143, 185));
208 EXPECT_EQ(ScrollbarOverlayStyleDefault, scrollableArea->getScrollbarOverlayS tyle()); 208 EXPECT_EQ(ScrollbarOverlayStyleDefault, scrollableArea->getScrollbarOverlayS tyle());
209 } 209 }
210 210
211 } // namespace blink 211 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698