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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/GraphicsLayerTest.cpp

Issue 2383113003: Refactor ScrollableArea::setScrollPosition. (Closed)
Patch Set: Created 4 years, 2 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 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 void scrollControlWasSetNeedsPaintInvalidation() override {} 176 void scrollControlWasSetNeedsPaintInvalidation() override {}
177 bool userInputScrollable(ScrollbarOrientation) const override { return true; } 177 bool userInputScrollable(ScrollbarOrientation) const override { return true; }
178 bool shouldPlaceVerticalScrollbarOnLeft() const override { return false; } 178 bool shouldPlaceVerticalScrollbarOnLeft() const override { return false; }
179 int pageStep(ScrollbarOrientation) const override { return 0; } 179 int pageStep(ScrollbarOrientation) const override { return 0; }
180 IntPoint minimumScrollPosition() const override { return IntPoint(); } 180 IntPoint minimumScrollPosition() const override { return IntPoint(); }
181 IntPoint maximumScrollPosition() const override { 181 IntPoint maximumScrollPosition() const override {
182 return IntPoint(contentsSize().width() - visibleWidth(), 182 return IntPoint(contentsSize().width() - visibleWidth(),
183 contentsSize().height() - visibleHeight()); 183 contentsSize().height() - visibleHeight());
184 } 184 }
185 185
186 void setScrollOffset(const DoublePoint& scrollOffset, ScrollType) override { 186 void updateScrollPosition(const DoublePoint& position, ScrollType) override {
187 m_scrollPosition = scrollOffset; 187 m_scrollPosition = position;
188 } 188 }
189 DoublePoint scrollPositionDouble() const override { return m_scrollPosition; } 189 DoublePoint scrollPositionDouble() const override { return m_scrollPosition; }
190 IntPoint scrollPosition() const override { 190 IntPoint scrollPosition() const override {
191 return flooredIntPoint(m_scrollPosition); 191 return flooredIntPoint(m_scrollPosition);
192 } 192 }
193 193
194 DEFINE_INLINE_VIRTUAL_TRACE() { ScrollableArea::trace(visitor); } 194 DEFINE_INLINE_VIRTUAL_TRACE() { ScrollableArea::trace(visitor); }
195 195
196 private: 196 private:
197 DoublePoint m_scrollPosition; 197 DoublePoint m_scrollPosition;
198 }; 198 };
199 199
200 TEST_F(GraphicsLayerTest, applyScrollToScrollableArea) { 200 TEST_F(GraphicsLayerTest, applyScrollToScrollableArea) {
201 FakeScrollableArea* scrollableArea = FakeScrollableArea::create(); 201 FakeScrollableArea* scrollableArea = FakeScrollableArea::create();
202 m_graphicsLayer->setScrollableArea(scrollableArea, false); 202 m_graphicsLayer->setScrollableArea(scrollableArea, false);
203 203
204 WebDoublePoint scrollPosition(7, 9); 204 WebDoublePoint scrollPosition(7, 9);
205 m_platformLayer->setScrollPositionDouble(scrollPosition); 205 m_platformLayer->setScrollPositionDouble(scrollPosition);
206 m_graphicsLayer->didScroll(); 206 m_graphicsLayer->didScroll();
207 207
208 EXPECT_FLOAT_EQ(scrollPosition.x, scrollableArea->scrollPositionDouble().x()); 208 EXPECT_FLOAT_EQ(scrollPosition.x, scrollableArea->scrollPositionDouble().x());
209 EXPECT_FLOAT_EQ(scrollPosition.y, scrollableArea->scrollPositionDouble().y()); 209 EXPECT_FLOAT_EQ(scrollPosition.y, scrollableArea->scrollPositionDouble().y());
210 } 210 }
211 211
212 } // namespace blink 212 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698