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

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

Issue 1458703010: Mac: Don't repaint scrollbars every frame (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master2
Patch Set: Rebase and resolve Created 5 years 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 "config.h" 5 #include "config.h"
6 #include "platform/scroll/ScrollableArea.h" 6 #include "platform/scroll/ScrollableArea.h"
7 7
8 #include "platform/scroll/ScrollbarTheme.h"
9 #include "platform/scroll/ScrollbarThemeMock.h"
8 #include "platform/testing/TestingPlatformSupport.h" 10 #include "platform/testing/TestingPlatformSupport.h"
9 #include "public/platform/Platform.h" 11 #include "public/platform/Platform.h"
10 #include "public/platform/WebScheduler.h" 12 #include "public/platform/WebScheduler.h"
11 #include "public/platform/WebThread.h" 13 #include "public/platform/WebThread.h"
12 #include "testing/gmock/include/gmock/gmock.h" 14 #include "testing/gmock/include/gmock/gmock.h"
13 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
14 16
15 namespace blink { 17 namespace blink {
16 18
17 namespace { 19 namespace {
18 20
19 class MockScrollableArea : public NoBaseWillBeGarbageCollectedFinalized<MockScro llableArea>, public ScrollableArea { 21 class MockScrollableArea : public NoBaseWillBeGarbageCollectedFinalized<MockScro llableArea>, public ScrollableArea {
20 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(MockScrollableArea); 22 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(MockScrollableArea);
21 public: 23 public:
22 static PassOwnPtrWillBeRawPtr<MockScrollableArea> create(const IntPoint& max imumScrollPosition) 24 static PassOwnPtrWillBeRawPtr<MockScrollableArea> create(const IntPoint& max imumScrollPosition)
23 { 25 {
24 return adoptPtrWillBeNoop(new MockScrollableArea(maximumScrollPosition)) ; 26 return adoptPtrWillBeNoop(new MockScrollableArea(maximumScrollPosition)) ;
25 } 27 }
26 28
27 MOCK_CONST_METHOD0(isActive, bool()); 29 MOCK_CONST_METHOD0(isActive, bool());
28 MOCK_CONST_METHOD1(scrollSize, int(ScrollbarOrientation)); 30 MOCK_CONST_METHOD1(scrollSize, int(ScrollbarOrientation));
29 MOCK_CONST_METHOD0(isScrollCornerVisible, bool()); 31 MOCK_CONST_METHOD0(isScrollCornerVisible, bool());
30 MOCK_CONST_METHOD0(scrollCornerRect, IntRect()); 32 MOCK_CONST_METHOD0(scrollCornerRect, IntRect());
31 MOCK_METHOD0(scrollControlWasSetNeedsPaintInvalidation, void()); 33 MOCK_METHOD0(scrollControlWasSetNeedsPaintInvalidation, void());
32 MOCK_CONST_METHOD0(enclosingScrollableArea, ScrollableArea*()); 34 MOCK_CONST_METHOD0(enclosingScrollableArea, ScrollableArea*());
33 MOCK_CONST_METHOD1(visibleContentRect, IntRect(IncludeScrollbarsInRect)); 35 MOCK_CONST_METHOD1(visibleContentRect, IntRect(IncludeScrollbarsInRect));
34 MOCK_CONST_METHOD0(contentsSize, IntSize()); 36 MOCK_CONST_METHOD0(contentsSize, IntSize());
35 MOCK_CONST_METHOD0(scrollbarsCanBeActive, bool());
36 MOCK_CONST_METHOD0(scrollableAreaBoundingBox, IntRect()); 37 MOCK_CONST_METHOD0(scrollableAreaBoundingBox, IntRect());
37 38
38 bool userInputScrollable(ScrollbarOrientation) const override { return true; } 39 bool userInputScrollable(ScrollbarOrientation) const override { return true; }
40 bool scrollbarsCanBeActive () const override { return true; }
39 bool shouldPlaceVerticalScrollbarOnLeft() const override { return false; } 41 bool shouldPlaceVerticalScrollbarOnLeft() const override { return false; }
40 void setScrollOffset(const IntPoint& offset, ScrollType) override { m_scroll Position = offset.shrunkTo(m_maximumScrollPosition); } 42 void setScrollOffset(const IntPoint& offset, ScrollType) override { m_scroll Position = offset.shrunkTo(m_maximumScrollPosition); }
41 IntPoint scrollPosition() const override { return m_scrollPosition; } 43 IntPoint scrollPosition() const override { return m_scrollPosition; }
42 IntPoint minimumScrollPosition() const override { return IntPoint(); } 44 IntPoint minimumScrollPosition() const override { return IntPoint(); }
43 IntPoint maximumScrollPosition() const override { return m_maximumScrollPosi tion; } 45 IntPoint maximumScrollPosition() const override { return m_maximumScrollPosi tion; }
44 int visibleHeight() const override { return 768; } 46 int visibleHeight() const override { return 768; }
45 int visibleWidth() const override { return 1024; } 47 int visibleWidth() const override { return 1024; }
46 bool scrollAnimatorEnabled() const override { return false; } 48 bool scrollAnimatorEnabled() const override { return false; }
47 int pageStep(ScrollbarOrientation) const override { return 0; } 49 int pageStep(ScrollbarOrientation) const override { return 0; }
48 50
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 Platform* m_oldPlatform; // Not owned. 122 Platform* m_oldPlatform; // Not owned.
121 }; 123 };
122 124
123 TEST_F(ScrollableAreaTest, ScrollAnimatorCurrentPositionShouldBeSync) 125 TEST_F(ScrollableAreaTest, ScrollAnimatorCurrentPositionShouldBeSync)
124 { 126 {
125 OwnPtrWillBeRawPtr<MockScrollableArea> scrollableArea = MockScrollableArea:: create(IntPoint(0, 100)); 127 OwnPtrWillBeRawPtr<MockScrollableArea> scrollableArea = MockScrollableArea:: create(IntPoint(0, 100));
126 scrollableArea->setScrollPosition(IntPoint(0, 10000), CompositorScroll); 128 scrollableArea->setScrollPosition(IntPoint(0, 10000), CompositorScroll);
127 EXPECT_EQ(100.0, scrollableArea->scrollAnimator()->currentPosition().y()); 129 EXPECT_EQ(100.0, scrollableArea->scrollAnimator()->currentPosition().y());
128 } 130 }
129 131
132 TEST_F(ScrollableAreaTest, ScrollbarTrackAndThumbRepaint)
133 {
134 ScrollbarTheme::setMockScrollbarsEnabled(true);
135 ScrollbarThemeMock::setShouldRepaintAllPartsOnInvalidation(true);
136
137 OwnPtrWillBeRawPtr<MockScrollableArea> scrollableArea = MockScrollableArea:: create(IntPoint(0, 100));
138 RefPtrWillBeRawPtr<Scrollbar> scrollbar = Scrollbar::create(scrollableArea.g et(), HorizontalScrollbar, RegularScrollbar);
139
140 EXPECT_TRUE(scrollbar->trackNeedsRepaint());
141 EXPECT_TRUE(scrollbar->thumbNeedsRepaint());
142 scrollbar->setNeedsPaintInvalidation();
143 EXPECT_TRUE(scrollbar->trackNeedsRepaint());
144 EXPECT_TRUE(scrollbar->thumbNeedsRepaint());
145
146 scrollbar->setTrackNeedsRepaint(false);
147 scrollbar->setThumbNeedsRepaint(false);
148 EXPECT_FALSE(scrollbar->trackNeedsRepaint());
149 EXPECT_FALSE(scrollbar->thumbNeedsRepaint());
150 scrollbar->setNeedsPaintInvalidation();
151 EXPECT_TRUE(scrollbar->trackNeedsRepaint());
152 EXPECT_TRUE(scrollbar->thumbNeedsRepaint());
153
154 ScrollbarThemeMock::setShouldRepaintAllPartsOnInvalidation(false);
155 scrollbar->setTrackNeedsRepaint(false);
156 scrollbar->setThumbNeedsRepaint(false);
157 EXPECT_FALSE(scrollbar->trackNeedsRepaint());
158 EXPECT_FALSE(scrollbar->thumbNeedsRepaint());
159 scrollbar->setNeedsPaintInvalidation();
160 EXPECT_FALSE(scrollbar->trackNeedsRepaint());
161 EXPECT_FALSE(scrollbar->thumbNeedsRepaint());
162 }
163
130 } // namespace blink 164 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/mac/ScrollAnimatorMac.mm ('k') | third_party/WebKit/Source/platform/scroll/Scrollbar.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698