diff options
Diffstat (limited to 'Source/WebKit/chromium/tests/WebLayerTest.cpp')
-rw-r--r-- | Source/WebKit/chromium/tests/WebLayerTest.cpp | 71 |
1 files changed, 45 insertions, 26 deletions
diff --git a/Source/WebKit/chromium/tests/WebLayerTest.cpp b/Source/WebKit/chromium/tests/WebLayerTest.cpp index 9b8e58ca1..eb544b29f 100644 --- a/Source/WebKit/chromium/tests/WebLayerTest.cpp +++ b/Source/WebKit/chromium/tests/WebLayerTest.cpp @@ -26,17 +26,20 @@ #include <public/WebLayer.h> #include "CompositorFakeWebGraphicsContext3D.h" +#include "WebCompositorInitializer.h" #include "WebLayerImpl.h" -#include <public/WebCompositor.h> +#include "WebLayerTreeViewTestCommon.h" #include <public/WebContentLayer.h> #include <public/WebContentLayerClient.h> #include <public/WebExternalTextureLayer.h> #include <public/WebFloatPoint.h> #include <public/WebFloatRect.h> +#include <public/WebLayerScrollClient.h> #include <public/WebLayerTreeView.h> #include <public/WebLayerTreeViewClient.h> #include <public/WebRect.h> #include <public/WebSize.h> +#include <public/WebSolidColorLayer.h> #include <gmock/gmock.h> @@ -49,23 +52,6 @@ using testing::_; namespace { -class MockWebLayerTreeViewClient : public WebLayerTreeViewClient { -public: - MOCK_METHOD0(scheduleComposite, void()); - - virtual void updateAnimations(double frameBeginTime) { } - virtual void didBeginFrame() { } - virtual void layout() { } - virtual void applyScrollAndScale(const WebSize& scrollDelta, float scaleFactor) { } - virtual WebGraphicsContext3D* createContext3D() { return CompositorFakeWebGraphicsContext3D::create(WebGraphicsContext3D::Attributes()).leakPtr(); } - virtual void didRebindGraphicsContext(bool success) { } - virtual WebCompositorOutputSurface* createOutputSurface() { return 0; } - virtual void didRecreateOutputSurface(bool success) { } - virtual void willCommit() { } - virtual void didCommitAndDrawFrame() { } - virtual void didCompleteSwapBuffers() { } -}; - class MockWebContentLayerClient : public WebContentLayerClient { public: MOCK_METHOD3(paintContents, void(WebCanvas*, const WebRect& clip, WebFloatRect& opaque)); @@ -73,13 +59,16 @@ public: class WebLayerTest : public Test { public: + WebLayerTest() + : m_compositorInitializer(0) + { + } + virtual void SetUp() { - // Initialize without threading support. - WebKit::WebCompositor::initialize(0); m_rootLayer = adoptPtr(WebLayer::create()); EXPECT_CALL(m_client, scheduleComposite()).Times(AnyNumber()); - EXPECT_TRUE(m_view.initialize(&m_client, *m_rootLayer, WebLayerTreeView::Settings())); + EXPECT_TRUE(m_view = adoptPtr(WebLayerTreeView::create(&m_client, *m_rootLayer, WebLayerTreeView::Settings()))); Mock::VerifyAndClearExpectations(&m_client); } @@ -87,16 +76,15 @@ public: { // We may get any number of scheduleComposite calls during shutdown. EXPECT_CALL(m_client, scheduleComposite()).Times(AnyNumber()); - m_view.setRootLayer(0); m_rootLayer.clear(); - m_view.reset(); - WebKit::WebCompositor::shutdown(); + m_view.clear(); } protected: + WebKitTests::WebCompositorInitializer m_compositorInitializer; MockWebLayerTreeViewClient m_client; OwnPtr<WebLayer> m_rootLayer; - WebLayerTreeView m_view; + OwnPtr<WebLayerTreeView> m_view; }; // Tests that the client gets called to ask for a composite if we change the @@ -156,7 +144,7 @@ TEST_F(WebLayerTest, Client) EXPECT_EQ(point, layer->position()); // Texture layer. - EXPECT_CALL(m_client, scheduleComposite()).Times(AnyNumber()); + EXPECT_CALL(m_client, scheduleComposite()).Times(AtLeast(1)); OwnPtr<WebExternalTextureLayer> textureLayer = adoptPtr(WebExternalTextureLayer::create()); m_rootLayer->addChild(textureLayer->layer()); Mock::VerifyAndClearExpectations(&m_client); @@ -187,6 +175,37 @@ TEST_F(WebLayerTest, Client) contentLayer->layer()->setDrawsContent(false); Mock::VerifyAndClearExpectations(&m_client); EXPECT_FALSE(contentLayer->layer()->drawsContent()); + + // Solid color layer. + EXPECT_CALL(m_client, scheduleComposite()).Times(AtLeast(1)); + OwnPtr<WebSolidColorLayer> solidColorLayer = adoptPtr(WebSolidColorLayer::create()); + m_rootLayer->addChild(solidColorLayer->layer()); + Mock::VerifyAndClearExpectations(&m_client); + +} + +class MockScrollClient : public WebLayerScrollClient { +public: + MOCK_METHOD0(didScroll, void()); +}; + +TEST_F(WebLayerTest, notifyScrollClient) +{ + MockScrollClient scrollClient; + + EXPECT_CALL(scrollClient, didScroll()).Times(0); + m_rootLayer->setScrollClient(&scrollClient); + Mock::VerifyAndClearExpectations(&scrollClient); + + EXPECT_CALL(scrollClient, didScroll()).Times(1); + m_rootLayer->setScrollPosition(WebPoint(14, 19)); + Mock::VerifyAndClearExpectations(&scrollClient); + + EXPECT_CALL(scrollClient, didScroll()).Times(0); + m_rootLayer->setScrollPosition(WebPoint(14, 19)); + Mock::VerifyAndClearExpectations(&scrollClient); + + m_rootLayer->setScrollClient(0); } } |