| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 | 6 |
| 7 #include "cc/texture_layer.h" | 7 #include "cc/texture_layer.h" |
| 8 | 8 |
| 9 #include "cc/layer_tree_host.h" | 9 #include "cc/layer_tree_host.h" |
| 10 #include "cc/single_thread_proxy.h" | 10 #include "cc/single_thread_proxy.h" |
| 11 #include "cc/texture_layer_impl.h" | 11 #include "cc/texture_layer_impl.h" |
| 12 #include "cc/test/fake_layer_tree_host_client.h" | 12 #include "cc/test/fake_layer_tree_host_client.h" |
| 13 #include "testing/gmock/include/gmock/gmock.h" | 13 #include "testing/gmock/include/gmock/gmock.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 | 15 |
| 16 using namespace cc; | 16 using namespace cc; |
| 17 using ::testing::Mock; | 17 using ::testing::Mock; |
| 18 using ::testing::_; | 18 using ::testing::_; |
| 19 using ::testing::AtLeast; | 19 using ::testing::AtLeast; |
| 20 using ::testing::AnyNumber; | 20 using ::testing::AnyNumber; |
| 21 | 21 |
| 22 namespace { | 22 namespace { |
| 23 | 23 |
| 24 class MockLayerImplTreeHost : public LayerTreeHost { | 24 class MockLayerImplTreeHost : public LayerTreeHost { |
| 25 public: | 25 public: |
| 26 MockLayerImplTreeHost() | 26 MockLayerImplTreeHost() |
| 27 : LayerTreeHost(&m_fakeClient, LayerTreeSettings()) | 27 : LayerTreeHost(&m_fakeClient, LayerTreeSettings()) |
| 28 { | 28 { |
| 29 initialize(); | 29 initialize(NULL); |
| 30 } | 30 } |
| 31 | 31 |
| 32 MOCK_METHOD0(acquireLayerTextures, void()); | 32 MOCK_METHOD0(acquireLayerTextures, void()); |
| 33 MOCK_METHOD0(setNeedsCommit, void()); | 33 MOCK_METHOD0(setNeedsCommit, void()); |
| 34 | 34 |
| 35 private: | 35 private: |
| 36 FakeLayerImplTreeHostClient m_fakeClient; | 36 FakeLayerImplTreeHostClient m_fakeClient; |
| 37 }; | 37 }; |
| 38 | 38 |
| 39 | 39 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); | 90 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); |
| 91 } | 91 } |
| 92 | 92 |
| 93 TEST_F(TextureLayerTest, syncImplWhenDrawing) | 93 TEST_F(TextureLayerTest, syncImplWhenDrawing) |
| 94 { | 94 { |
| 95 FloatRect dirtyRect(0, 0, 1, 1); | 95 FloatRect dirtyRect(0, 0, 1, 1); |
| 96 | 96 |
| 97 scoped_refptr<TextureLayer> testLayer = TextureLayer::create(0); | 97 scoped_refptr<TextureLayer> testLayer = TextureLayer::create(0); |
| 98 ASSERT_TRUE(testLayer); | 98 ASSERT_TRUE(testLayer); |
| 99 scoped_ptr<TextureLayerImpl> implLayer; | 99 scoped_ptr<TextureLayerImpl> implLayer; |
| 100 { | 100 implLayer = TextureLayerImpl::create(1); |
| 101 DebugScopedSetImplThread setImplThread; | |
| 102 implLayer = TextureLayerImpl::create(1); | |
| 103 } | |
| 104 ASSERT_TRUE(implLayer); | 101 ASSERT_TRUE(implLayer); |
| 105 | 102 |
| 106 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(AnyNumber()); | 103 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(AnyNumber()); |
| 107 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AnyNumber()); | 104 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AnyNumber()); |
| 108 m_layerTreeHost->setRootLayer(testLayer); | 105 m_layerTreeHost->setRootLayer(testLayer); |
| 109 testLayer->setTextureId(1); | 106 testLayer->setTextureId(1); |
| 110 testLayer->setIsDrawable(true); | 107 testLayer->setIsDrawable(true); |
| 111 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); | 108 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); |
| 112 EXPECT_EQ(testLayer->layerTreeHost(), m_layerTreeHost.get()); | 109 EXPECT_EQ(testLayer->layerTreeHost(), m_layerTreeHost.get()); |
| 113 | 110 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 137 testLayer->pushPropertiesTo(implLayer.get()); // fake commit | 134 testLayer->pushPropertiesTo(implLayer.get()); // fake commit |
| 138 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); | 135 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); |
| 139 | 136 |
| 140 // Second draw with layer in non-drawable state: no texture | 137 // Second draw with layer in non-drawable state: no texture |
| 141 // acquisition. | 138 // acquisition. |
| 142 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(0); | 139 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(0); |
| 143 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(0); | 140 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(0); |
| 144 testLayer->willModifyTexture(); | 141 testLayer->willModifyTexture(); |
| 145 testLayer->setNeedsDisplayRect(dirtyRect); | 142 testLayer->setNeedsDisplayRect(dirtyRect); |
| 146 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); | 143 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); |
| 147 | |
| 148 { | |
| 149 DebugScopedSetImplThread setImplThread; | |
| 150 delete implLayer.release(); | |
| 151 } | |
| 152 } | 144 } |
| 153 | 145 |
| 154 TEST_F(TextureLayerTest, syncImplWhenRemovingFromTree) | 146 TEST_F(TextureLayerTest, syncImplWhenRemovingFromTree) |
| 155 { | 147 { |
| 156 scoped_refptr<Layer> rootLayer = Layer::create(); | 148 scoped_refptr<Layer> rootLayer = Layer::create(); |
| 157 ASSERT_TRUE(rootLayer); | 149 ASSERT_TRUE(rootLayer); |
| 158 scoped_refptr<Layer> childLayer = Layer::create(); | 150 scoped_refptr<Layer> childLayer = Layer::create(); |
| 159 ASSERT_TRUE(childLayer); | 151 ASSERT_TRUE(childLayer); |
| 160 rootLayer->addChild(childLayer); | 152 rootLayer->addChild(childLayer); |
| 161 scoped_refptr<TextureLayer> testLayer = TextureLayer::create(0); | 153 scoped_refptr<TextureLayer> testLayer = TextureLayer::create(0); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 183 testLayer->setTextureId(1); | 175 testLayer->setTextureId(1); |
| 184 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); | 176 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); |
| 185 | 177 |
| 186 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(AtLeast(1)); | 178 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(AtLeast(1)); |
| 187 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AtLeast(1)); | 179 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AtLeast(1)); |
| 188 testLayer->removeFromParent(); | 180 testLayer->removeFromParent(); |
| 189 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); | 181 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); |
| 190 } | 182 } |
| 191 | 183 |
| 192 } // anonymous namespace | 184 } // anonymous namespace |
| OLD | NEW |