| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 #include <public/WebLayer.h> | 6 #include <public/WebLayer.h> |
| 7 | 7 |
| 8 #include "cc/test/compositor_fake_web_graphics_context_3d.h" | 8 #include "cc/test/compositor_fake_web_graphics_context_3d.h" |
| 9 #include "cc/test/web_compositor_initializer.h" | |
| 10 #include "web_layer_impl.h" | 9 #include "web_layer_impl.h" |
| 11 #include "web_layer_tree_view_test_common.h" | 10 #include "web_layer_tree_view_test_common.h" |
| 12 #include <public/WebContentLayer.h> | 11 #include <public/WebContentLayer.h> |
| 13 #include <public/WebContentLayerClient.h> | 12 #include <public/WebContentLayerClient.h> |
| 14 #include <public/WebExternalTextureLayer.h> | 13 #include <public/WebExternalTextureLayer.h> |
| 15 #include <public/WebFloatPoint.h> | 14 #include <public/WebFloatPoint.h> |
| 16 #include <public/WebFloatRect.h> | 15 #include <public/WebFloatRect.h> |
| 17 #include <public/WebLayerScrollClient.h> | 16 #include <public/WebLayerScrollClient.h> |
| 18 #include <public/WebLayerTreeView.h> | 17 #include <public/WebLayerTreeView.h> |
| 19 #include <public/WebLayerTreeViewClient.h> | 18 #include <public/WebLayerTreeViewClient.h> |
| (...skipping 13 matching lines...) Expand all Loading... |
| 33 namespace { | 32 namespace { |
| 34 | 33 |
| 35 class MockWebContentLayerClient : public WebContentLayerClient { | 34 class MockWebContentLayerClient : public WebContentLayerClient { |
| 36 public: | 35 public: |
| 37 MOCK_METHOD3(paintContents, void(WebCanvas*, const WebRect& clip, WebFloatRe
ct& opaque)); | 36 MOCK_METHOD3(paintContents, void(WebCanvas*, const WebRect& clip, WebFloatRe
ct& opaque)); |
| 38 }; | 37 }; |
| 39 | 38 |
| 40 class WebLayerTest : public Test { | 39 class WebLayerTest : public Test { |
| 41 public: | 40 public: |
| 42 WebLayerTest() | 41 WebLayerTest() |
| 43 : m_compositorInitializer(0) | |
| 44 { | 42 { |
| 45 } | 43 } |
| 46 | 44 |
| 47 virtual void SetUp() | 45 virtual void SetUp() |
| 48 { | 46 { |
| 49 m_rootLayer.reset(WebLayer::create()); | 47 m_rootLayer.reset(WebLayer::create()); |
| 50 EXPECT_CALL(m_client, scheduleComposite()).Times(AnyNumber()); | 48 EXPECT_CALL(m_client, scheduleComposite()).Times(AnyNumber()); |
| 51 m_view.reset(WebLayerTreeView::create(&m_client, *m_rootLayer, WebLayerT
reeView::Settings())); | 49 m_view.reset(WebLayerTreeView::create(&m_client, *m_rootLayer, WebLayerT
reeView::Settings())); |
| 52 EXPECT_TRUE(m_view); | 50 EXPECT_TRUE(m_view); |
| 53 Mock::VerifyAndClearExpectations(&m_client); | 51 Mock::VerifyAndClearExpectations(&m_client); |
| 54 } | 52 } |
| 55 | 53 |
| 56 virtual void TearDown() | 54 virtual void TearDown() |
| 57 { | 55 { |
| 58 // We may get any number of scheduleComposite calls during shutdown. | 56 // We may get any number of scheduleComposite calls during shutdown. |
| 59 EXPECT_CALL(m_client, scheduleComposite()).Times(AnyNumber()); | 57 EXPECT_CALL(m_client, scheduleComposite()).Times(AnyNumber()); |
| 60 m_rootLayer.reset(); | 58 m_rootLayer.reset(); |
| 61 m_view.reset(); | 59 m_view.reset(); |
| 62 } | 60 } |
| 63 | 61 |
| 64 protected: | 62 protected: |
| 65 WebKitTests::WebCompositorInitializer m_compositorInitializer; | |
| 66 MockWebLayerTreeViewClient m_client; | 63 MockWebLayerTreeViewClient m_client; |
| 67 scoped_ptr<WebLayer> m_rootLayer; | 64 scoped_ptr<WebLayer> m_rootLayer; |
| 68 scoped_ptr<WebLayerTreeView> m_view; | 65 scoped_ptr<WebLayerTreeView> m_view; |
| 69 }; | 66 }; |
| 70 | 67 |
| 71 // Tests that the client gets called to ask for a composite if we change the | 68 // Tests that the client gets called to ask for a composite if we change the |
| 72 // fields. | 69 // fields. |
| 73 TEST_F(WebLayerTest, Client) | 70 TEST_F(WebLayerTest, Client) |
| 74 { | 71 { |
| 75 // Base layer. | 72 // Base layer. |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 Mock::VerifyAndClearExpectations(&scrollClient); | 181 Mock::VerifyAndClearExpectations(&scrollClient); |
| 185 | 182 |
| 186 EXPECT_CALL(scrollClient, didScroll()).Times(0); | 183 EXPECT_CALL(scrollClient, didScroll()).Times(0); |
| 187 m_rootLayer->setScrollPosition(WebPoint(14, 19)); | 184 m_rootLayer->setScrollPosition(WebPoint(14, 19)); |
| 188 Mock::VerifyAndClearExpectations(&scrollClient); | 185 Mock::VerifyAndClearExpectations(&scrollClient); |
| 189 | 186 |
| 190 m_rootLayer->setScrollClient(0); | 187 m_rootLayer->setScrollClient(0); |
| 191 } | 188 } |
| 192 | 189 |
| 193 } | 190 } |
| OLD | NEW |