[chromium] Add WebUnitTestSupport::createLayerTreeViewForTesting for webkit_unit_tests
[WebKit-https.git] / Source / WebKit / chromium / tests / ScrollingCoordinatorChromiumTest.cpp
index 271829d..2667cb5 100644 (file)
@@ -28,6 +28,8 @@
 
 #include "CompositorFakeWebGraphicsContext3D.h"
 #include "FrameTestHelpers.h"
+#include "GraphicsLayerChromium.h"
+#include "RenderLayerBacking.h"
 #include "RenderLayerCompositor.h"
 #include "RenderView.h"
 #include "URLTestHelpers.h"
 #include "WebViewClient.h"
 #include "WebViewImpl.h"
 #include <gtest/gtest.h>
+#include <public/Platform.h>
 #include <public/WebCompositorSupport.h>
 #include <public/WebLayer.h>
-#include <webkit/support/webkit_support.h>
-
-#if ENABLE(ACCELERATED_OVERFLOW_SCROLLING)
-#include "GraphicsLayerChromium.h"
-#endif
+#include <public/WebUnitTestSupport.h>
 
 using namespace WebCore;
 using namespace WebKit;
 
 namespace {
 
-class MockWebViewClient : public WebViewClient {
+class FakeWebViewClient : public WebViewClient {
 public:
     virtual WebCompositorOutputSurface* createOutputSurface() OVERRIDE
     {
         return Platform::current()->compositorSupport()->createOutputSurfaceFor3D(CompositorFakeWebGraphicsContext3D::create(WebGraphicsContext3D::Attributes()).leakPtr());
     }
+
+    virtual void initializeLayerTreeView(WebLayerTreeViewClient* client, const WebLayer& rootLayer, const WebLayerTreeView::Settings& settings)
+    {
+        m_layerTreeView = adoptPtr(Platform::current()->unitTestSupport()->createLayerTreeViewForTesting(WebUnitTestSupport::TestViewTypeUnitTest));
+        ASSERT(m_layerTreeView);
+        m_layerTreeView->setRootLayer(rootLayer);
+    }
+
+    virtual WebLayerTreeView* layerTreeView()
+    {
+        return m_layerTreeView.get();
+    }
+
+private:
+    OwnPtr<WebLayerTreeView> m_layerTreeView;
 };
 
 class MockWebFrameClient : public WebFrameClient {
@@ -66,7 +80,6 @@ class ScrollingCoordinatorChromiumTest : public testing::Test {
 public:
     ScrollingCoordinatorChromiumTest()
         : m_baseURL("http://www.test.com/")
-        , m_webCompositorInitializer(0)
     {
         Platform::current()->compositorSupport()->initialize(0);
 
@@ -77,6 +90,7 @@ public:
         m_webViewImpl->settings()->setForceCompositingMode(true);
         m_webViewImpl->settings()->setAcceleratedCompositingEnabled(true);
         m_webViewImpl->settings()->setAcceleratedCompositingForFixedPositionEnabled(true);
+        m_webViewImpl->settings()->setAcceleratedCompositingForOverflowScrollEnabled(true);
         m_webViewImpl->settings()->setFixedPositionCreatesStackingContext(true);
         m_webViewImpl->initializeMainFrame(&m_mockWebFrameClient);
         m_webViewImpl->resize(IntSize(320, 240));
@@ -84,7 +98,7 @@ public:
 
     virtual ~ScrollingCoordinatorChromiumTest()
     {
-        webkit_support::UnregisterAllMockedURLs();
+        Platform::current()->unitTestSupport()->unregisterAllMockedURLs();
         m_webViewImpl->close();
 
         Platform::current()->compositorSupport()->shutdown();
@@ -93,7 +107,7 @@ public:
     void navigateTo(const std::string& url)
     {
         FrameTestHelpers::loadFrame(m_webViewImpl->mainFrame(), url);
-        webkit_support::ServeAsynchronousMockedRequests();
+        Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests();
     }
 
     void registerMockedHttpURLLoad(const std::string& fileName)
@@ -114,8 +128,7 @@ public:
 protected:
     std::string m_baseURL;
     MockWebFrameClient m_mockWebFrameClient;
-    MockWebViewClient m_mockWebViewClient;
-    WebKitTests::WebCompositorInitializer m_webCompositorInitializer;
+    FakeWebViewClient m_mockWebViewClient;
     WebViewImpl* m_webViewImpl;
 };
 
@@ -195,11 +208,10 @@ TEST_F(ScrollingCoordinatorChromiumTest, clippedBodyTest)
     ASSERT_EQ(0u, rootScrollLayer->nonFastScrollableRegion().size());
 }
 
-#if ENABLE(ACCELERATED_OVERFLOW_SCROLLING)
-TEST_F(ScrollingCoordinatorChromiumTest, touchOverflowScrolling)
+TEST_F(ScrollingCoordinatorChromiumTest, overflowScrolling)
 {
-    registerMockedHttpURLLoad("touch-overflow-scrolling.html");
-    navigateTo(m_baseURL + "touch-overflow-scrolling.html");
+    registerMockedHttpURLLoad("overflow-scrolling.html");
+    navigateTo(m_baseURL + "overflow-scrolling.html");
 
     // Verify the properties of the accelerated scrolling element starting from the RenderObject
     // all the way to the WebLayer.
@@ -224,6 +236,5 @@ TEST_F(ScrollingCoordinatorChromiumTest, touchOverflowScrolling)
     WebLayer* webScrollLayer = static_cast<WebLayer*>(layerBacking->scrollingContentsLayer()->platformLayer());
     ASSERT_TRUE(webScrollLayer->scrollable());
 }
-#endif // ENABLE(ACCELERATED_OVERFLOW_SCROLLING)
 
 } // namespace