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