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

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

Issue 1173053003: Remove ScrollableArea::notifyScrollPositionChanged and cleanup scroll animators. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase + remove updateScrollbars from FrameView::setScrollPosition Created 5 years, 6 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
« no previous file with comments | « Source/platform/scroll/ScrollableArea.cpp ('k') | Source/web/WebLocalFrameImpl.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 ScrollableArea { 17 class MockScrollableArea : public ScrollableArea {
18 public: 18 public:
19 MockScrollableArea(const IntPoint& maximumScrollPosition) 19 MockScrollableArea(const IntPoint& maximumScrollPosition)
20 : m_maximumScrollPosition(maximumScrollPosition) { } 20 : m_maximumScrollPosition(maximumScrollPosition) { }
21 21
22 MOCK_CONST_METHOD0(isActive, bool()); 22 MOCK_CONST_METHOD0(isActive, bool());
23 MOCK_CONST_METHOD1(scrollSize, int(ScrollbarOrientation)); 23 MOCK_CONST_METHOD1(scrollSize, int(ScrollbarOrientation));
24 MOCK_METHOD2(invalidateScrollbar, void(Scrollbar*, const IntRect&)); 24 MOCK_METHOD2(invalidateScrollbar, void(Scrollbar*, const IntRect&));
25 MOCK_CONST_METHOD0(isScrollCornerVisible, bool()); 25 MOCK_CONST_METHOD0(isScrollCornerVisible, bool());
26 MOCK_CONST_METHOD0(scrollCornerRect, IntRect()); 26 MOCK_CONST_METHOD0(scrollCornerRect, IntRect());
27 MOCK_METHOD2(invalidateScrollbarRect, void(Scrollbar*, const IntRect&)); 27 MOCK_METHOD2(invalidateScrollbarRect, void(Scrollbar*, const IntRect&));
28 MOCK_METHOD1(invalidateScrollCornerRect, void(const IntRect&)); 28 MOCK_METHOD1(invalidateScrollCornerRect, void(const IntRect&));
29 MOCK_CONST_METHOD0(enclosingScrollableArea, ScrollableArea*()); 29 MOCK_CONST_METHOD0(enclosingScrollableArea, ScrollableArea*());
30 MOCK_CONST_METHOD0(minimumScrollPosition, IntPoint());
31 MOCK_CONST_METHOD1(visibleContentRect, IntRect(IncludeScrollbarsInRect)); 30 MOCK_CONST_METHOD1(visibleContentRect, IntRect(IncludeScrollbarsInRect));
32 MOCK_CONST_METHOD0(contentsSize, IntSize()); 31 MOCK_CONST_METHOD0(contentsSize, IntSize());
33 MOCK_CONST_METHOD0(scrollbarsCanBeActive, bool()); 32 MOCK_CONST_METHOD0(scrollbarsCanBeActive, bool());
34 MOCK_CONST_METHOD0(scrollableAreaBoundingBox, IntRect()); 33 MOCK_CONST_METHOD0(scrollableAreaBoundingBox, IntRect());
35 34
36 bool userInputScrollable(ScrollbarOrientation) const override { return true; } 35 bool userInputScrollable(ScrollbarOrientation) const override { return true; }
37 bool shouldPlaceVerticalScrollbarOnLeft() const override { return false; } 36 bool shouldPlaceVerticalScrollbarOnLeft() const override { return false; }
38 void setScrollOffset(const IntPoint& offset, ScrollType) override { m_scroll Position = offset.shrunkTo(m_maximumScrollPosition); } 37 void setScrollOffset(const IntPoint& offset, ScrollType) override { m_scroll Position = offset.shrunkTo(m_maximumScrollPosition); }
39 IntPoint scrollPosition() const override { return m_scrollPosition; } 38 IntPoint scrollPosition() const override { return m_scrollPosition; }
39 IntPoint minimumScrollPosition() const override { return IntPoint(); }
40 IntPoint maximumScrollPosition() const override { return m_maximumScrollPosi tion; } 40 IntPoint maximumScrollPosition() const override { return m_maximumScrollPosi tion; }
41 int visibleHeight() const override { return 768; } 41 int visibleHeight() const override { return 768; }
42 int visibleWidth() const override { return 1024; } 42 int visibleWidth() const override { return 1024; }
43 bool scrollAnimatorEnabled() const override { return false; } 43 bool scrollAnimatorEnabled() const override { return false; }
44 int pageStep(ScrollbarOrientation) const override { return 0; } 44 int pageStep(ScrollbarOrientation) const override { return 0; }
45 45
46 private: 46 private:
47 IntPoint m_scrollPosition; 47 IntPoint m_scrollPosition;
48 IntPoint m_maximumScrollPosition; 48 IntPoint m_maximumScrollPosition;
49 }; 49 };
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 } 107 }
108 108
109 private: 109 private:
110 FakePlatform m_fakePlatform; 110 FakePlatform m_fakePlatform;
111 Platform* m_oldPlatform; // Not owned. 111 Platform* m_oldPlatform; // Not owned.
112 }; 112 };
113 113
114 TEST_F(ScrollableAreaTest, ScrollAnimatorCurrentPositionShouldBeSync) 114 TEST_F(ScrollableAreaTest, ScrollAnimatorCurrentPositionShouldBeSync)
115 { 115 {
116 MockScrollableArea scrollableArea(IntPoint(0, 100)); 116 MockScrollableArea scrollableArea(IntPoint(0, 100));
117 scrollableArea.notifyScrollPositionChanged(IntPoint(0, 10000)); 117 scrollableArea.setScrollPosition(IntPoint(0, 10000), CompositorScroll);
118 EXPECT_EQ(100.0, scrollableArea.scrollAnimator()->currentPosition().y()); 118 EXPECT_EQ(100.0, scrollableArea.scrollAnimator()->currentPosition().y());
119 } 119 }
120 120
121 } // namespace blink 121 } // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/scroll/ScrollableArea.cpp ('k') | Source/web/WebLocalFrameImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698