| 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 29 matching lines...) Expand all Loading... |
| 40 #include "wtf/PassOwnPtr.h" | 40 #include "wtf/PassOwnPtr.h" |
| 41 | 41 |
| 42 #include <gtest/gtest.h> | 42 #include <gtest/gtest.h> |
| 43 | 43 |
| 44 using namespace blink; | 44 using namespace blink; |
| 45 | 45 |
| 46 namespace { | 46 namespace { |
| 47 | 47 |
| 48 class MockGraphicsLayerClient : public GraphicsLayerClient { | 48 class MockGraphicsLayerClient : public GraphicsLayerClient { |
| 49 public: | 49 public: |
| 50 virtual void notifyAnimationStarted(const GraphicsLayer*, double monotonicTi
me) OVERRIDE { } | 50 virtual void notifyAnimationStarted(const GraphicsLayer*, double monotonicTi
me) override { } |
| 51 virtual void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsL
ayerPaintingPhase, const IntRect& inClip) OVERRIDE { } | 51 virtual void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsL
ayerPaintingPhase, const IntRect& inClip) override { } |
| 52 virtual String debugName(const GraphicsLayer*) OVERRIDE { return String(); } | 52 virtual String debugName(const GraphicsLayer*) override { return String(); } |
| 53 }; | 53 }; |
| 54 | 54 |
| 55 class GraphicsLayerForTesting : public GraphicsLayer { | 55 class GraphicsLayerForTesting : public GraphicsLayer { |
| 56 public: | 56 public: |
| 57 explicit GraphicsLayerForTesting(GraphicsLayerClient* client) | 57 explicit GraphicsLayerForTesting(GraphicsLayerClient* client) |
| 58 : GraphicsLayer(client) { }; | 58 : GraphicsLayer(client) { }; |
| 59 | 59 |
| 60 virtual WebLayer* contentsLayer() const { return GraphicsLayer::contentsLaye
r(); } | 60 virtual WebLayer* contentsLayer() const { return GraphicsLayer::contentsLaye
r(); } |
| 61 }; | 61 }; |
| 62 | 62 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 m_graphicsLayer->setShouldFlattenTransform(true); | 118 m_graphicsLayer->setShouldFlattenTransform(true); |
| 119 | 119 |
| 120 m_platformLayer = m_graphicsLayer->platformLayer(); | 120 m_platformLayer = m_graphicsLayer->platformLayer(); |
| 121 ASSERT_TRUE(m_platformLayer); | 121 ASSERT_TRUE(m_platformLayer); |
| 122 | 122 |
| 123 ASSERT_FALSE(m_platformLayer->hasActiveAnimation()); | 123 ASSERT_FALSE(m_platformLayer->hasActiveAnimation()); |
| 124 } | 124 } |
| 125 | 125 |
| 126 class FakeScrollableArea : public ScrollableArea { | 126 class FakeScrollableArea : public ScrollableArea { |
| 127 public: | 127 public: |
| 128 virtual bool isActive() const OVERRIDE { return false; } | 128 virtual bool isActive() const override { return false; } |
| 129 virtual int scrollSize(ScrollbarOrientation) const OVERRIDE { return 100; } | 129 virtual int scrollSize(ScrollbarOrientation) const override { return 100; } |
| 130 virtual bool isScrollCornerVisible() const OVERRIDE { return false; } | 130 virtual bool isScrollCornerVisible() const override { return false; } |
| 131 virtual IntRect scrollCornerRect() const OVERRIDE { return IntRect(); } | 131 virtual IntRect scrollCornerRect() const override { return IntRect(); } |
| 132 virtual int visibleWidth() const OVERRIDE { return 10; } | 132 virtual int visibleWidth() const override { return 10; } |
| 133 virtual int visibleHeight() const OVERRIDE { return 10; } | 133 virtual int visibleHeight() const override { return 10; } |
| 134 virtual IntSize contentsSize() const OVERRIDE { return IntSize(100, 100); } | 134 virtual IntSize contentsSize() const override { return IntSize(100, 100); } |
| 135 virtual bool scrollbarsCanBeActive() const OVERRIDE { return false; } | 135 virtual bool scrollbarsCanBeActive() const override { return false; } |
| 136 virtual IntRect scrollableAreaBoundingBox() const OVERRIDE { return IntRect(
); } | 136 virtual IntRect scrollableAreaBoundingBox() const override { return IntRect(
); } |
| 137 virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&) OVERRIDE {
} | 137 virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&) override {
} |
| 138 virtual void invalidateScrollCornerRect(const IntRect&) OVERRIDE { } | 138 virtual void invalidateScrollCornerRect(const IntRect&) override { } |
| 139 virtual bool userInputScrollable(ScrollbarOrientation) const OVERRIDE { retu
rn true; } | 139 virtual bool userInputScrollable(ScrollbarOrientation) const override { retu
rn true; } |
| 140 virtual bool shouldPlaceVerticalScrollbarOnLeft() const OVERRIDE { return fa
lse; } | 140 virtual bool shouldPlaceVerticalScrollbarOnLeft() const override { return fa
lse; } |
| 141 virtual int pageStep(ScrollbarOrientation) const OVERRIDE { return 0; } | 141 virtual int pageStep(ScrollbarOrientation) const override { return 0; } |
| 142 virtual IntPoint minimumScrollPosition() const OVERRIDE { return IntPoint();
} | 142 virtual IntPoint minimumScrollPosition() const override { return IntPoint();
} |
| 143 virtual IntPoint maximumScrollPosition() const OVERRIDE | 143 virtual IntPoint maximumScrollPosition() const override |
| 144 { | 144 { |
| 145 return IntPoint(contentsSize().width() - visibleWidth(), contentsSize().
height() - visibleHeight()); | 145 return IntPoint(contentsSize().width() - visibleWidth(), contentsSize().
height() - visibleHeight()); |
| 146 } | 146 } |
| 147 | 147 |
| 148 virtual void setScrollOffset(const IntPoint& scrollOffset) OVERRIDE { m_scro
llPosition = scrollOffset; } | 148 virtual void setScrollOffset(const IntPoint& scrollOffset) override { m_scro
llPosition = scrollOffset; } |
| 149 virtual IntPoint scrollPosition() const OVERRIDE { return m_scrollPosition;
} | 149 virtual IntPoint scrollPosition() const override { return m_scrollPosition;
} |
| 150 | 150 |
| 151 private: | 151 private: |
| 152 IntPoint m_scrollPosition; | 152 IntPoint m_scrollPosition; |
| 153 }; | 153 }; |
| 154 | 154 |
| 155 TEST_F(GraphicsLayerTest, applyScrollToScrollableArea) | 155 TEST_F(GraphicsLayerTest, applyScrollToScrollableArea) |
| 156 { | 156 { |
| 157 FakeScrollableArea scrollableArea; | 157 FakeScrollableArea scrollableArea; |
| 158 m_graphicsLayer->setScrollableArea(&scrollableArea, false); | 158 m_graphicsLayer->setScrollableArea(&scrollableArea, false); |
| 159 | 159 |
| 160 WebPoint scrollPosition(7, 9); | 160 WebPoint scrollPosition(7, 9); |
| 161 m_platformLayer->setScrollPosition(scrollPosition); | 161 m_platformLayer->setScrollPosition(scrollPosition); |
| 162 m_graphicsLayer->didScroll(); | 162 m_graphicsLayer->didScroll(); |
| 163 | 163 |
| 164 EXPECT_EQ(scrollPosition, WebPoint(scrollableArea.scrollPosition())); | 164 EXPECT_EQ(scrollPosition, WebPoint(scrollableArea.scrollPosition())); |
| 165 } | 165 } |
| 166 | 166 |
| 167 } // namespace | 167 } // namespace |
| OLD | NEW |