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/test/web_compositor_initializer.h" | |
14 #include "testing/gmock/include/gmock/gmock.h" | 13 #include "testing/gmock/include/gmock/gmock.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
16 | 15 |
17 using namespace cc; | 16 using namespace cc; |
18 using ::testing::Mock; | 17 using ::testing::Mock; |
19 using ::testing::_; | 18 using ::testing::_; |
20 using ::testing::AtLeast; | 19 using ::testing::AtLeast; |
21 using ::testing::AnyNumber; | 20 using ::testing::AnyNumber; |
22 | 21 |
23 namespace { | 22 namespace { |
(...skipping 10 matching lines...) Expand all Loading... |
34 MOCK_METHOD0(setNeedsCommit, void()); | 33 MOCK_METHOD0(setNeedsCommit, void()); |
35 | 34 |
36 private: | 35 private: |
37 FakeLayerImplTreeHostClient m_fakeClient; | 36 FakeLayerImplTreeHostClient m_fakeClient; |
38 }; | 37 }; |
39 | 38 |
40 | 39 |
41 class TextureLayerTest : public testing::Test { | 40 class TextureLayerTest : public testing::Test { |
42 public: | 41 public: |
43 TextureLayerTest() | 42 TextureLayerTest() |
44 : m_compositorInitializer(0) | |
45 { | 43 { |
46 } | 44 } |
47 | 45 |
48 protected: | 46 protected: |
49 virtual void SetUp() | 47 virtual void SetUp() |
50 { | 48 { |
51 m_layerTreeHost.reset(new MockLayerImplTreeHost); | 49 m_layerTreeHost.reset(new MockLayerImplTreeHost); |
52 } | 50 } |
53 | 51 |
54 virtual void TearDown() | 52 virtual void TearDown() |
55 { | 53 { |
56 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); | 54 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); |
57 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(AnyNumber())
; | 55 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(AnyNumber())
; |
58 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AnyNumber()); | 56 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AnyNumber()); |
59 | 57 |
60 m_layerTreeHost->setRootLayer(0); | 58 m_layerTreeHost->setRootLayer(0); |
61 m_layerTreeHost.reset(); | 59 m_layerTreeHost.reset(); |
62 } | 60 } |
63 | 61 |
64 scoped_ptr<MockLayerImplTreeHost> m_layerTreeHost; | 62 scoped_ptr<MockLayerImplTreeHost> m_layerTreeHost; |
65 private: | 63 private: |
66 WebKitTests::WebCompositorInitializer m_compositorInitializer; | |
67 }; | 64 }; |
68 | 65 |
69 TEST_F(TextureLayerTest, syncImplWhenChangingTextureId) | 66 TEST_F(TextureLayerTest, syncImplWhenChangingTextureId) |
70 { | 67 { |
71 scoped_refptr<TextureLayer> testLayer = TextureLayer::create(0); | 68 scoped_refptr<TextureLayer> testLayer = TextureLayer::create(0); |
72 ASSERT_TRUE(testLayer); | 69 ASSERT_TRUE(testLayer); |
73 | 70 |
74 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(AnyNumber()); | 71 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(AnyNumber()); |
75 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AnyNumber()); | 72 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AnyNumber()); |
76 m_layerTreeHost->setRootLayer(testLayer); | 73 m_layerTreeHost->setRootLayer(testLayer); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 testLayer->setTextureId(1); | 183 testLayer->setTextureId(1); |
187 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); | 184 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); |
188 | 185 |
189 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(AtLeast(1)); | 186 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(AtLeast(1)); |
190 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AtLeast(1)); | 187 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AtLeast(1)); |
191 testLayer->removeFromParent(); | 188 testLayer->removeFromParent(); |
192 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); | 189 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); |
193 } | 190 } |
194 | 191 |
195 } // anonymous namespace | 192 } // anonymous namespace |
OLD | NEW |