summaryrefslogtreecommitdiff
path: root/Source/WebKit/chromium/tests/ScrollbarLayerChromiumTest.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2012-08-12 09:27:39 +0200
committerSimon Hausmann <simon.hausmann@nokia.com>2012-08-12 09:27:39 +0200
commit3749d61e1f7a59f5ec5067e560af1eb610c82015 (patch)
tree73dc228333948738bbe02976cacca8cd382bc978 /Source/WebKit/chromium/tests/ScrollbarLayerChromiumTest.cpp
parentb32b4dcd9a51ab8de6afc53d9e17f8707e1f7a5e (diff)
downloadqtwebkit-3749d61e1f7a59f5ec5067e560af1eb610c82015.tar.gz
Imported WebKit commit a77350243e054f3460d1137301d8b3faee3d2052 (http://svn.webkit.org/repository/webkit/trunk@125365)
New snapshot with build fixes for latest API changes in Qt and all WK1 Win MSVC fixes upstream
Diffstat (limited to 'Source/WebKit/chromium/tests/ScrollbarLayerChromiumTest.cpp')
-rw-r--r--Source/WebKit/chromium/tests/ScrollbarLayerChromiumTest.cpp73
1 files changed, 66 insertions, 7 deletions
diff --git a/Source/WebKit/chromium/tests/ScrollbarLayerChromiumTest.cpp b/Source/WebKit/chromium/tests/ScrollbarLayerChromiumTest.cpp
index d2cd9befc..0e3b1fbdb 100644
--- a/Source/WebKit/chromium/tests/ScrollbarLayerChromiumTest.cpp
+++ b/Source/WebKit/chromium/tests/ScrollbarLayerChromiumTest.cpp
@@ -26,12 +26,17 @@
#include "ScrollbarLayerChromium.h"
+#include "FakeWebScrollbarThemeGeometry.h"
#include "Scrollbar.h"
#include "Settings.h"
#include "TreeSynchronizer.h"
+#include "cc/CCScrollbarAnimationController.h"
#include "cc/CCScrollbarLayerImpl.h"
#include "cc/CCSingleThreadProxy.h"
#include <gtest/gtest.h>
+#include <public/WebScrollbar.h>
+#include <public/WebScrollbarThemeGeometry.h>
+#include <public/WebScrollbarThemePainter.h>
using namespace WebCore;
@@ -60,7 +65,7 @@ public:
virtual bool isScrollableAreaActive() const { return false; }
virtual bool isScrollViewScrollbar() const { return false; }
- virtual IntPoint convertFromContainingWindow(const IntPoint& windowPoint) { return IntPoint(); }
+ virtual IntPoint convertFromContainingWindow(const IntPoint& windowPoint) { return windowPoint; }
virtual bool isCustomScrollbar() const { return false; }
virtual ScrollbarOrientation orientation() const { return HorizontalScrollbar; }
@@ -83,6 +88,8 @@ public:
virtual bool enabled() const { return false; }
virtual void setEnabled(bool) { }
+ virtual bool isOverlayScrollbar() const { return false; }
+
MockScrollbar() : Scrollbar(0, HorizontalScrollbar, RegularScrollbar) { }
virtual ~MockScrollbar() { }
};
@@ -91,12 +98,15 @@ TEST(ScrollbarLayerChromiumTest, resolveScrollLayerPointer)
{
DebugScopedSetImplThread impl;
+ RefPtr<MockScrollbar> mockScrollbar = adoptRef(new MockScrollbar);
+ WebKit::WebScrollbarThemePainter painter(0, mockScrollbar.get());
+
Settings::setMockScrollbarsEnabled(true);
{
- RefPtr<MockScrollbar> scrollbar = adoptRef(new MockScrollbar);
+ OwnPtr<WebKit::WebScrollbar> scrollbar = WebKit::WebScrollbar::create(mockScrollbar.get());
RefPtr<LayerChromium> layerTreeRoot = LayerChromium::create();
RefPtr<LayerChromium> child1 = LayerChromium::create();
- RefPtr<LayerChromium> child2 = ScrollbarLayerChromium::create(scrollbar.get(), child1->id());
+ RefPtr<LayerChromium> child2 = ScrollbarLayerChromium::create(scrollbar.release(), painter, WebKit::FakeWebScrollbarThemeGeometry::create(), child1->id());
layerTreeRoot->addChild(child1);
layerTreeRoot->addChild(child2);
@@ -105,14 +115,15 @@ TEST(ScrollbarLayerChromiumTest, resolveScrollLayerPointer)
CCLayerImpl* ccChild1 = ccLayerTreeRoot->children()[0].get();
CCScrollbarLayerImpl* ccChild2 = static_cast<CCScrollbarLayerImpl*>(ccLayerTreeRoot->children()[1].get());
- EXPECT_EQ(ccChild1, ccChild2->scrollLayer());
+ EXPECT_TRUE(ccChild1->scrollbarAnimationController());
+ EXPECT_EQ(ccChild1->horizontalScrollbarLayer(), ccChild2);
}
{ // another traverse order
- RefPtr<MockScrollbar> scrollbar = adoptRef(new MockScrollbar);
+ OwnPtr<WebKit::WebScrollbar> scrollbar = WebKit::WebScrollbar::create(mockScrollbar.get());
RefPtr<LayerChromium> layerTreeRoot = LayerChromium::create();
RefPtr<LayerChromium> child2 = LayerChromium::create();
- RefPtr<LayerChromium> child1 = ScrollbarLayerChromium::create(scrollbar.get(), child2->id());
+ RefPtr<LayerChromium> child1 = ScrollbarLayerChromium::create(scrollbar.release(), painter, WebKit::FakeWebScrollbarThemeGeometry::create(), child2->id());
layerTreeRoot->addChild(child1);
layerTreeRoot->addChild(child2);
@@ -121,8 +132,56 @@ TEST(ScrollbarLayerChromiumTest, resolveScrollLayerPointer)
CCScrollbarLayerImpl* ccChild1 = static_cast<CCScrollbarLayerImpl*>(ccLayerTreeRoot->children()[0].get());
CCLayerImpl* ccChild2 = ccLayerTreeRoot->children()[1].get();
- EXPECT_EQ(ccChild1->scrollLayer(), ccChild2);
+ EXPECT_TRUE(ccChild2->scrollbarAnimationController());
+ EXPECT_EQ(ccChild2->horizontalScrollbarLayer(), ccChild1);
}
}
+TEST(ScrollbarLayerChromiumTest, scrollOffsetSynchronization)
+{
+ DebugScopedSetImplThread impl;
+
+ RefPtr<MockScrollbar> mockScrollbar = adoptRef(new MockScrollbar);
+ WebKit::WebScrollbarThemePainter painter(0, mockScrollbar.get());
+
+ Settings::setMockScrollbarsEnabled(true);
+
+ OwnPtr<WebKit::WebScrollbar> scrollbar = WebKit::WebScrollbar::create(mockScrollbar.get());
+ RefPtr<LayerChromium> layerTreeRoot = LayerChromium::create();
+ RefPtr<LayerChromium> contentLayer = LayerChromium::create();
+ RefPtr<LayerChromium> scrollbarLayer = ScrollbarLayerChromium::create(scrollbar.release(), painter, WebKit::FakeWebScrollbarThemeGeometry::create(), layerTreeRoot->id());
+ layerTreeRoot->addChild(contentLayer);
+ layerTreeRoot->addChild(scrollbarLayer);
+
+ layerTreeRoot->setScrollPosition(IntPoint(10, 20));
+ layerTreeRoot->setMaxScrollPosition(IntSize(30, 50));
+ contentLayer->setBounds(IntSize(100, 200));
+
+ OwnPtr<CCLayerImpl> ccLayerTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), nullptr, 0);
+
+ CCScrollbarLayerImpl* ccScrollbarLayer = static_cast<CCScrollbarLayerImpl*>(ccLayerTreeRoot->children()[1].get());
+
+ EXPECT_EQ(10, ccScrollbarLayer->currentPos());
+ EXPECT_EQ(100, ccScrollbarLayer->totalSize());
+ EXPECT_EQ(30, ccScrollbarLayer->maximum());
+
+ layerTreeRoot->setScrollPosition(IntPoint(100, 200));
+ layerTreeRoot->setMaxScrollPosition(IntSize(300, 500));
+ contentLayer->setBounds(IntSize(1000, 2000));
+
+ CCScrollbarAnimationController* scrollbarController = ccLayerTreeRoot->scrollbarAnimationController();
+ ccLayerTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), ccLayerTreeRoot.release(), 0);
+ EXPECT_EQ(scrollbarController, ccLayerTreeRoot->scrollbarAnimationController());
+
+ EXPECT_EQ(100, ccScrollbarLayer->currentPos());
+ EXPECT_EQ(1000, ccScrollbarLayer->totalSize());
+ EXPECT_EQ(300, ccScrollbarLayer->maximum());
+
+ ccLayerTreeRoot->scrollBy(FloatSize(12, 34));
+
+ EXPECT_EQ(112, ccScrollbarLayer->currentPos());
+ EXPECT_EQ(1000, ccScrollbarLayer->totalSize());
+ EXPECT_EQ(300, ccScrollbarLayer->maximum());
+}
+
}