Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(380)

Side by Side Diff: cc/texture_layer_unittest.cc

Issue 11189043: cc: Rename cc classes and members to match filenames (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "CCLayerTreeHost.h" 9 #include "CCLayerTreeHost.h"
10 #include "cc/test/fake_layer_tree_host_client.h" 10 #include "cc/test/fake_layer_tree_host_client.h"
11 #include "cc/test/web_compositor_initializer.h" 11 #include "cc/test/web_compositor_initializer.h"
12 #include "testing/gmock/include/gmock/gmock.h" 12 #include "testing/gmock/include/gmock/gmock.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 14
15 using namespace cc; 15 using namespace cc;
16 using ::testing::Mock; 16 using ::testing::Mock;
17 using ::testing::_; 17 using ::testing::_;
18 using ::testing::AtLeast; 18 using ::testing::AtLeast;
19 using ::testing::AnyNumber; 19 using ::testing::AnyNumber;
20 20
21 namespace { 21 namespace {
22 22
23 class MockCCLayerTreeHost : public CCLayerTreeHost { 23 class MockLayerImplTreeHost : public LayerTreeHost {
24 public: 24 public:
25 MockCCLayerTreeHost() 25 MockLayerImplTreeHost()
26 : CCLayerTreeHost(&m_fakeClient, CCLayerTreeSettings()) 26 : LayerTreeHost(&m_fakeClient, LayerTreeSettings())
27 { 27 {
28 initialize(); 28 initialize();
29 } 29 }
30 30
31 MOCK_METHOD0(acquireLayerTextures, void()); 31 MOCK_METHOD0(acquireLayerTextures, void());
32 32
33 private: 33 private:
34 FakeCCLayerTreeHostClient m_fakeClient; 34 FakeLayerImplTreeHostClient m_fakeClient;
35 }; 35 };
36 36
37 37
38 class TextureLayerChromiumTest : public testing::Test { 38 class TextureLayerTest : public testing::Test {
39 public: 39 public:
40 TextureLayerChromiumTest() 40 TextureLayerTest()
41 : m_compositorInitializer(0) 41 : m_compositorInitializer(0)
42 { 42 {
43 } 43 }
44 44
45 protected: 45 protected:
46 virtual void SetUp() 46 virtual void SetUp()
47 { 47 {
48 m_layerTreeHost.reset(new MockCCLayerTreeHost); 48 m_layerTreeHost.reset(new MockLayerImplTreeHost);
49 } 49 }
50 50
51 virtual void TearDown() 51 virtual void TearDown()
52 { 52 {
53 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); 53 Mock::VerifyAndClearExpectations(m_layerTreeHost.get());
54 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(AnyNumber()) ; 54 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(AnyNumber()) ;
55 55
56 m_layerTreeHost->setRootLayer(0); 56 m_layerTreeHost->setRootLayer(0);
57 m_layerTreeHost.reset(); 57 m_layerTreeHost.reset();
58 } 58 }
59 59
60 scoped_ptr<MockCCLayerTreeHost> m_layerTreeHost; 60 scoped_ptr<MockLayerImplTreeHost> m_layerTreeHost;
61 private: 61 private:
62 WebKitTests::WebCompositorInitializer m_compositorInitializer; 62 WebKitTests::WebCompositorInitializer m_compositorInitializer;
63 }; 63 };
64 64
65 TEST_F(TextureLayerChromiumTest, syncImplWhenChangingTextureId) 65 TEST_F(TextureLayerTest, syncImplWhenChangingTextureId)
66 { 66 {
67 scoped_refptr<TextureLayerChromium> testLayer = TextureLayerChromium::create (0); 67 scoped_refptr<TextureLayer> testLayer = TextureLayer::create(0);
68 ASSERT_TRUE(testLayer); 68 ASSERT_TRUE(testLayer);
69 69
70 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(AnyNumber()); 70 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(AnyNumber());
71 m_layerTreeHost->setRootLayer(testLayer); 71 m_layerTreeHost->setRootLayer(testLayer);
72 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); 72 Mock::VerifyAndClearExpectations(m_layerTreeHost.get());
73 EXPECT_EQ(testLayer->layerTreeHost(), m_layerTreeHost.get()); 73 EXPECT_EQ(testLayer->layerTreeHost(), m_layerTreeHost.get());
74 74
75 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(0); 75 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(0);
76 testLayer->setTextureId(1); 76 testLayer->setTextureId(1);
77 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); 77 Mock::VerifyAndClearExpectations(m_layerTreeHost.get());
78 78
79 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(AtLeast(1)); 79 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(AtLeast(1));
80 testLayer->setTextureId(2); 80 testLayer->setTextureId(2);
81 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); 81 Mock::VerifyAndClearExpectations(m_layerTreeHost.get());
82 82
83 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(AtLeast(1)); 83 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(AtLeast(1));
84 testLayer->setTextureId(0); 84 testLayer->setTextureId(0);
85 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); 85 Mock::VerifyAndClearExpectations(m_layerTreeHost.get());
86 } 86 }
87 87
88 TEST_F(TextureLayerChromiumTest, syncImplWhenRemovingFromTree) 88 TEST_F(TextureLayerTest, syncImplWhenRemovingFromTree)
89 { 89 {
90 scoped_refptr<LayerChromium> rootLayer = LayerChromium::create(); 90 scoped_refptr<Layer> rootLayer = Layer::create();
91 ASSERT_TRUE(rootLayer); 91 ASSERT_TRUE(rootLayer);
92 scoped_refptr<LayerChromium> childLayer = LayerChromium::create(); 92 scoped_refptr<Layer> childLayer = Layer::create();
93 ASSERT_TRUE(childLayer); 93 ASSERT_TRUE(childLayer);
94 rootLayer->addChild(childLayer); 94 rootLayer->addChild(childLayer);
95 scoped_refptr<TextureLayerChromium> testLayer = TextureLayerChromium::create (0); 95 scoped_refptr<TextureLayer> testLayer = TextureLayer::create(0);
96 ASSERT_TRUE(testLayer); 96 ASSERT_TRUE(testLayer);
97 testLayer->setTextureId(0); 97 testLayer->setTextureId(0);
98 childLayer->addChild(testLayer); 98 childLayer->addChild(testLayer);
99 99
100 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(AnyNumber()); 100 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(AnyNumber());
101 m_layerTreeHost->setRootLayer(rootLayer); 101 m_layerTreeHost->setRootLayer(rootLayer);
102 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); 102 Mock::VerifyAndClearExpectations(m_layerTreeHost.get());
103 103
104 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(0); 104 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(0);
105 testLayer->removeFromParent(); 105 testLayer->removeFromParent();
106 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); 106 Mock::VerifyAndClearExpectations(m_layerTreeHost.get());
107 107
108 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(0); 108 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(0);
109 childLayer->addChild(testLayer); 109 childLayer->addChild(testLayer);
110 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); 110 Mock::VerifyAndClearExpectations(m_layerTreeHost.get());
111 111
112 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(0); 112 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(0);
113 testLayer->setTextureId(1); 113 testLayer->setTextureId(1);
114 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); 114 Mock::VerifyAndClearExpectations(m_layerTreeHost.get());
115 115
116 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(AtLeast(1)); 116 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(AtLeast(1));
117 testLayer->removeFromParent(); 117 testLayer->removeFromParent();
118 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); 118 Mock::VerifyAndClearExpectations(m_layerTreeHost.get());
119 } 119 }
120 120
121 } // anonymous namespace 121 } // anonymous namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698