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

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

Issue 1406133005: Calculate paint invalidation rect for scrollbars (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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/TestingPlatformSupport.h" 8 #include "platform/TestingPlatformSupport.h"
9 #include "public/platform/Platform.h" 9 #include "public/platform/Platform.h"
10 #include "public/platform/WebScheduler.h" 10 #include "public/platform/WebScheduler.h"
11 #include "public/platform/WebThread.h" 11 #include "public/platform/WebThread.h"
12 #include <gmock/gmock.h> 12 #include <gmock/gmock.h>
13 #include <gtest/gtest.h> 13 #include <gtest/gtest.h>
14 14
15 namespace blink { 15 namespace blink {
16 16
17 class MockScrollableArea : public NoBaseWillBeGarbageCollectedFinalized<MockScro llableArea>, public ScrollableArea { 17 class MockScrollableArea : public NoBaseWillBeGarbageCollectedFinalized<MockScro llableArea>, public ScrollableArea {
18 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(MockScrollableArea); 18 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(MockScrollableArea);
19 public: 19 public:
20 static PassOwnPtrWillBeRawPtr<MockScrollableArea> create(const IntPoint& max imumScrollPosition) 20 static PassOwnPtrWillBeRawPtr<MockScrollableArea> create(const IntPoint& max imumScrollPosition)
21 { 21 {
22 return adoptPtrWillBeNoop(new MockScrollableArea(maximumScrollPosition)) ; 22 return adoptPtrWillBeNoop(new MockScrollableArea(maximumScrollPosition)) ;
23 } 23 }
24 24
25 MOCK_CONST_METHOD0(isActive, bool()); 25 MOCK_CONST_METHOD0(isActive, bool());
26 MOCK_CONST_METHOD1(scrollSize, int(ScrollbarOrientation)); 26 MOCK_CONST_METHOD1(scrollSize, int(ScrollbarOrientation));
27 MOCK_METHOD2(invalidateScrollbar, void(Scrollbar*, const IntRect&));
28 MOCK_CONST_METHOD0(isScrollCornerVisible, bool()); 27 MOCK_CONST_METHOD0(isScrollCornerVisible, bool());
29 MOCK_CONST_METHOD0(scrollCornerRect, IntRect()); 28 MOCK_CONST_METHOD0(scrollCornerRect, IntRect());
30 MOCK_METHOD2(invalidateScrollbarRect, void(Scrollbar*, const IntRect&)); 29 MOCK_METHOD0(scrollControlWasSetNeedsPaintInvalidation, void());
31 MOCK_METHOD1(invalidateScrollCornerRect, void(const IntRect&));
32 MOCK_CONST_METHOD0(enclosingScrollableArea, ScrollableArea*()); 30 MOCK_CONST_METHOD0(enclosingScrollableArea, ScrollableArea*());
33 MOCK_CONST_METHOD1(visibleContentRect, IntRect(IncludeScrollbarsInRect)); 31 MOCK_CONST_METHOD1(visibleContentRect, IntRect(IncludeScrollbarsInRect));
34 MOCK_CONST_METHOD0(contentsSize, IntSize()); 32 MOCK_CONST_METHOD0(contentsSize, IntSize());
35 MOCK_CONST_METHOD0(scrollbarsCanBeActive, bool()); 33 MOCK_CONST_METHOD0(scrollbarsCanBeActive, bool());
36 MOCK_CONST_METHOD0(scrollableAreaBoundingBox, IntRect()); 34 MOCK_CONST_METHOD0(scrollableAreaBoundingBox, IntRect());
37 35
38 bool userInputScrollable(ScrollbarOrientation) const override { return true; } 36 bool userInputScrollable(ScrollbarOrientation) const override { return true; }
39 bool shouldPlaceVerticalScrollbarOnLeft() const override { return false; } 37 bool shouldPlaceVerticalScrollbarOnLeft() const override { return false; }
40 void setScrollOffset(const IntPoint& offset, ScrollType) override { m_scroll Position = offset.shrunkTo(m_maximumScrollPosition); } 38 void setScrollOffset(const IntPoint& offset, ScrollType) override { m_scroll Position = offset.shrunkTo(m_maximumScrollPosition); }
41 IntPoint scrollPosition() const override { return m_scrollPosition; } 39 IntPoint scrollPosition() const override { return m_scrollPosition; }
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 }; 117 };
120 118
121 TEST_F(ScrollableAreaTest, ScrollAnimatorCurrentPositionShouldBeSync) 119 TEST_F(ScrollableAreaTest, ScrollAnimatorCurrentPositionShouldBeSync)
122 { 120 {
123 OwnPtrWillBeRawPtr<MockScrollableArea> scrollableArea = MockScrollableArea:: create(IntPoint(0, 100)); 121 OwnPtrWillBeRawPtr<MockScrollableArea> scrollableArea = MockScrollableArea:: create(IntPoint(0, 100));
124 scrollableArea->setScrollPosition(IntPoint(0, 10000), CompositorScroll); 122 scrollableArea->setScrollPosition(IntPoint(0, 10000), CompositorScroll);
125 EXPECT_EQ(100.0, scrollableArea->scrollAnimator()->currentPosition().y()); 123 EXPECT_EQ(100.0, scrollableArea->scrollAnimator()->currentPosition().y());
126 } 124 }
127 125
128 } // namespace blink 126 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/scroll/ScrollableArea.cpp ('k') | third_party/WebKit/Source/platform/scroll/Scrollbar.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698