| 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 "cc/texture_layer.h" | 5 #include "cc/texture_layer.h" |
| 6 | 6 |
| 7 #include "cc/layer_tree_host.h" | 7 #include "cc/layer_tree_host.h" |
| 8 #include "cc/single_thread_proxy.h" | 8 #include "cc/single_thread_proxy.h" |
| 9 #include "cc/test/fake_impl_proxy.h" |
| 10 #include "cc/test/fake_layer_tree_host_client.h" |
| 11 #include "cc/test/fake_layer_tree_host_impl.h" |
| 9 #include "cc/texture_layer_impl.h" | 12 #include "cc/texture_layer_impl.h" |
| 10 #include "cc/test/fake_layer_tree_host_client.h" | |
| 11 #include "cc/thread.h" | 13 #include "cc/thread.h" |
| 12 #include "testing/gmock/include/gmock/gmock.h" | 14 #include "testing/gmock/include/gmock/gmock.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 14 | 16 |
| 15 using ::testing::Mock; | 17 using ::testing::Mock; |
| 16 using ::testing::_; | 18 using ::testing::_; |
| 17 using ::testing::AtLeast; | 19 using ::testing::AtLeast; |
| 18 using ::testing::AnyNumber; | 20 using ::testing::AnyNumber; |
| 19 | 21 |
| 20 namespace cc { | 22 namespace cc { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 32 MOCK_METHOD0(setNeedsCommit, void()); | 34 MOCK_METHOD0(setNeedsCommit, void()); |
| 33 | 35 |
| 34 private: | 36 private: |
| 35 FakeLayerImplTreeHostClient m_fakeClient; | 37 FakeLayerImplTreeHostClient m_fakeClient; |
| 36 }; | 38 }; |
| 37 | 39 |
| 38 | 40 |
| 39 class TextureLayerTest : public testing::Test { | 41 class TextureLayerTest : public testing::Test { |
| 40 public: | 42 public: |
| 41 TextureLayerTest() | 43 TextureLayerTest() |
| 44 : m_hostImpl(&m_proxy) |
| 42 { | 45 { |
| 43 } | 46 } |
| 44 | 47 |
| 45 protected: | 48 protected: |
| 46 virtual void SetUp() | 49 virtual void SetUp() |
| 47 { | 50 { |
| 48 m_layerTreeHost.reset(new MockLayerImplTreeHost); | 51 m_layerTreeHost.reset(new MockLayerImplTreeHost); |
| 49 } | 52 } |
| 50 | 53 |
| 51 virtual void TearDown() | 54 virtual void TearDown() |
| 52 { | 55 { |
| 53 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); | 56 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); |
| 54 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(AnyNumber())
; | 57 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(AnyNumber())
; |
| 55 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AnyNumber()); | 58 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AnyNumber()); |
| 56 | 59 |
| 57 m_layerTreeHost->setRootLayer(0); | 60 m_layerTreeHost->setRootLayer(0); |
| 58 m_layerTreeHost.reset(); | 61 m_layerTreeHost.reset(); |
| 59 } | 62 } |
| 60 | 63 |
| 61 scoped_ptr<MockLayerImplTreeHost> m_layerTreeHost; | 64 scoped_ptr<MockLayerImplTreeHost> m_layerTreeHost; |
| 62 private: | 65 FakeImplProxy m_proxy; |
| 66 FakeLayerTreeHostImpl m_hostImpl; |
| 63 }; | 67 }; |
| 64 | 68 |
| 65 TEST_F(TextureLayerTest, syncImplWhenChangingTextureId) | 69 TEST_F(TextureLayerTest, syncImplWhenChangingTextureId) |
| 66 { | 70 { |
| 67 scoped_refptr<TextureLayer> testLayer = TextureLayer::create(0); | 71 scoped_refptr<TextureLayer> testLayer = TextureLayer::create(0); |
| 68 ASSERT_TRUE(testLayer); | 72 ASSERT_TRUE(testLayer); |
| 69 | 73 |
| 70 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(AnyNumber()); | 74 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(AnyNumber()); |
| 71 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AnyNumber()); | 75 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AnyNumber()); |
| 72 m_layerTreeHost->setRootLayer(testLayer); | 76 m_layerTreeHost->setRootLayer(testLayer); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 89 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); | 93 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); |
| 90 } | 94 } |
| 91 | 95 |
| 92 TEST_F(TextureLayerTest, syncImplWhenDrawing) | 96 TEST_F(TextureLayerTest, syncImplWhenDrawing) |
| 93 { | 97 { |
| 94 gfx::RectF dirtyRect(0, 0, 1, 1); | 98 gfx::RectF dirtyRect(0, 0, 1, 1); |
| 95 | 99 |
| 96 scoped_refptr<TextureLayer> testLayer = TextureLayer::create(0); | 100 scoped_refptr<TextureLayer> testLayer = TextureLayer::create(0); |
| 97 ASSERT_TRUE(testLayer); | 101 ASSERT_TRUE(testLayer); |
| 98 scoped_ptr<TextureLayerImpl> implLayer; | 102 scoped_ptr<TextureLayerImpl> implLayer; |
| 99 implLayer = TextureLayerImpl::create(1); | 103 implLayer = TextureLayerImpl::create(&m_hostImpl, 1); |
| 100 ASSERT_TRUE(implLayer); | 104 ASSERT_TRUE(implLayer); |
| 101 | 105 |
| 102 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(AnyNumber()); | 106 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(AnyNumber()); |
| 103 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AnyNumber()); | 107 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AnyNumber()); |
| 104 m_layerTreeHost->setRootLayer(testLayer); | 108 m_layerTreeHost->setRootLayer(testLayer); |
| 105 testLayer->setTextureId(1); | 109 testLayer->setTextureId(1); |
| 106 testLayer->setIsDrawable(true); | 110 testLayer->setIsDrawable(true); |
| 107 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); | 111 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); |
| 108 EXPECT_EQ(testLayer->layerTreeHost(), m_layerTreeHost.get()); | 112 EXPECT_EQ(testLayer->layerTreeHost(), m_layerTreeHost.get()); |
| 109 | 113 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); | 179 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); |
| 176 | 180 |
| 177 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(AtLeast(1)); | 181 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(AtLeast(1)); |
| 178 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AtLeast(1)); | 182 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AtLeast(1)); |
| 179 testLayer->removeFromParent(); | 183 testLayer->removeFromParent(); |
| 180 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); | 184 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); |
| 181 } | 185 } |
| 182 | 186 |
| 183 } // namespace | 187 } // namespace |
| 184 } // namespace cc | 188 } // namespace cc |
| OLD | NEW |