| OLD | NEW |
| 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 27 matching lines...) Expand all Loading... |
| 38 #include "platform/testing/FakeGraphicsLayer.h" | 38 #include "platform/testing/FakeGraphicsLayer.h" |
| 39 #include "platform/testing/FakeGraphicsLayerClient.h" | 39 #include "platform/testing/FakeGraphicsLayerClient.h" |
| 40 #include "platform/testing/WebLayerTreeViewImplForTesting.h" | 40 #include "platform/testing/WebLayerTreeViewImplForTesting.h" |
| 41 #include "platform/transforms/Matrix3DTransformOperation.h" | 41 #include "platform/transforms/Matrix3DTransformOperation.h" |
| 42 #include "platform/transforms/RotateTransformOperation.h" | 42 #include "platform/transforms/RotateTransformOperation.h" |
| 43 #include "platform/transforms/TranslateTransformOperation.h" | 43 #include "platform/transforms/TranslateTransformOperation.h" |
| 44 #include "public/platform/Platform.h" | 44 #include "public/platform/Platform.h" |
| 45 #include "public/platform/WebCompositorSupport.h" | 45 #include "public/platform/WebCompositorSupport.h" |
| 46 #include "public/platform/WebLayer.h" | 46 #include "public/platform/WebLayer.h" |
| 47 #include "public/platform/WebLayerTreeView.h" | 47 #include "public/platform/WebLayerTreeView.h" |
| 48 #include "public/platform/WebScheduler.h" |
| 49 #include "public/platform/WebThread.h" |
| 48 #include "testing/gtest/include/gtest/gtest.h" | 50 #include "testing/gtest/include/gtest/gtest.h" |
| 49 #include "wtf/PtrUtil.h" | 51 #include "wtf/PtrUtil.h" |
| 50 #include <memory> | 52 #include <memory> |
| 51 | 53 |
| 52 namespace blink { | 54 namespace blink { |
| 53 | 55 |
| 54 class GraphicsLayerTest : public testing::Test { | 56 class GraphicsLayerTest : public testing::Test { |
| 55 public: | 57 public: |
| 56 GraphicsLayerTest() { | 58 GraphicsLayerTest() { |
| 57 m_clipLayer = WTF::wrapUnique(new FakeGraphicsLayer(&m_client)); | 59 m_clipLayer = WTF::wrapUnique(new FakeGraphicsLayer(&m_client)); |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 } | 187 } |
| 186 | 188 |
| 187 void updateScrollOffset(const ScrollOffset& offset, ScrollType) override { | 189 void updateScrollOffset(const ScrollOffset& offset, ScrollType) override { |
| 188 m_scrollOffset = offset; | 190 m_scrollOffset = offset; |
| 189 } | 191 } |
| 190 ScrollOffset getScrollOffset() const override { return m_scrollOffset; } | 192 ScrollOffset getScrollOffset() const override { return m_scrollOffset; } |
| 191 IntSize scrollOffsetInt() const override { | 193 IntSize scrollOffsetInt() const override { |
| 192 return flooredIntSize(m_scrollOffset); | 194 return flooredIntSize(m_scrollOffset); |
| 193 } | 195 } |
| 194 | 196 |
| 197 RefPtr<WebTaskRunner> getTimerTaskRunner() const final { |
| 198 return Platform::current()->currentThread()->scheduler()->timerTaskRunner(); |
| 199 } |
| 200 |
| 195 DEFINE_INLINE_VIRTUAL_TRACE() { ScrollableArea::trace(visitor); } | 201 DEFINE_INLINE_VIRTUAL_TRACE() { ScrollableArea::trace(visitor); } |
| 196 | 202 |
| 197 private: | 203 private: |
| 198 ScrollOffset m_scrollOffset; | 204 ScrollOffset m_scrollOffset; |
| 199 }; | 205 }; |
| 200 | 206 |
| 201 TEST_F(GraphicsLayerTest, applyScrollToScrollableArea) { | 207 TEST_F(GraphicsLayerTest, applyScrollToScrollableArea) { |
| 202 FakeScrollableArea* scrollableArea = FakeScrollableArea::create(); | 208 FakeScrollableArea* scrollableArea = FakeScrollableArea::create(); |
| 203 m_graphicsLayer->setScrollableArea(scrollableArea, false); | 209 m_graphicsLayer->setScrollableArea(scrollableArea, false); |
| 204 | 210 |
| 205 WebDoublePoint scrollPosition(7, 9); | 211 WebDoublePoint scrollPosition(7, 9); |
| 206 m_platformLayer->setScrollPositionDouble(scrollPosition); | 212 m_platformLayer->setScrollPositionDouble(scrollPosition); |
| 207 m_graphicsLayer->didScroll(); | 213 m_graphicsLayer->didScroll(); |
| 208 | 214 |
| 209 EXPECT_FLOAT_EQ(scrollPosition.x, scrollableArea->getScrollOffset().width()); | 215 EXPECT_FLOAT_EQ(scrollPosition.x, scrollableArea->getScrollOffset().width()); |
| 210 EXPECT_FLOAT_EQ(scrollPosition.y, scrollableArea->getScrollOffset().height()); | 216 EXPECT_FLOAT_EQ(scrollPosition.y, scrollableArea->getScrollOffset().height()); |
| 211 } | 217 } |
| 212 | 218 |
| 213 } // namespace blink | 219 } // namespace blink |
| OLD | NEW |