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

Side by Side Diff: cc/texture_layer_unittest.cc

Issue 12774006: cc: Chromify Layer and LayerImpl classes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: MoreAndroidCompilings Created 7 years, 9 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
« no previous file with comments | « cc/texture_layer_impl.cc ('k') | cc/tiled_layer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "cc/texture_layer.h" 5 #include "cc/texture_layer.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "cc/layer_tree_host.h" 10 #include "cc/layer_tree_host.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 m_layerTreeHost.reset(); 66 m_layerTreeHost.reset();
67 } 67 }
68 68
69 scoped_ptr<MockLayerImplTreeHost> m_layerTreeHost; 69 scoped_ptr<MockLayerImplTreeHost> m_layerTreeHost;
70 FakeImplProxy m_proxy; 70 FakeImplProxy m_proxy;
71 FakeLayerTreeHostImpl m_hostImpl; 71 FakeLayerTreeHostImpl m_hostImpl;
72 }; 72 };
73 73
74 TEST_F(TextureLayerTest, syncImplWhenChangingTextureId) 74 TEST_F(TextureLayerTest, syncImplWhenChangingTextureId)
75 { 75 {
76 scoped_refptr<TextureLayer> testLayer = TextureLayer::create(0); 76 scoped_refptr<TextureLayer> testLayer = TextureLayer::Create(NULL);
77 ASSERT_TRUE(testLayer); 77 ASSERT_TRUE(testLayer);
78 78
79 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(AnyNumber()); 79 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(AnyNumber());
80 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AnyNumber()); 80 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AnyNumber());
81 m_layerTreeHost->setRootLayer(testLayer); 81 m_layerTreeHost->setRootLayer(testLayer);
82 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); 82 Mock::VerifyAndClearExpectations(m_layerTreeHost.get());
83 EXPECT_EQ(testLayer->layerTreeHost(), m_layerTreeHost.get()); 83 EXPECT_EQ(testLayer->layer_tree_host(), m_layerTreeHost.get());
84 84
85 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(0); 85 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(0);
86 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AtLeast(1)); 86 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AtLeast(1));
87 testLayer->setTextureId(1); 87 testLayer->setTextureId(1);
88 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); 88 Mock::VerifyAndClearExpectations(m_layerTreeHost.get());
89 89
90 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(AtLeast(1)); 90 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(AtLeast(1));
91 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AtLeast(1)); 91 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AtLeast(1));
92 testLayer->setTextureId(2); 92 testLayer->setTextureId(2);
93 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); 93 Mock::VerifyAndClearExpectations(m_layerTreeHost.get());
94 94
95 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(AtLeast(1)); 95 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(AtLeast(1));
96 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AtLeast(1)); 96 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AtLeast(1));
97 testLayer->setTextureId(0); 97 testLayer->setTextureId(0);
98 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); 98 Mock::VerifyAndClearExpectations(m_layerTreeHost.get());
99 } 99 }
100 100
101 TEST_F(TextureLayerTest, syncImplWhenDrawing) 101 TEST_F(TextureLayerTest, syncImplWhenDrawing)
102 { 102 {
103 gfx::RectF dirtyRect(0, 0, 1, 1); 103 gfx::RectF dirtyRect(0, 0, 1, 1);
104 104
105 scoped_refptr<TextureLayer> testLayer = TextureLayer::create(0); 105 scoped_refptr<TextureLayer> testLayer = TextureLayer::Create(NULL);
106 ASSERT_TRUE(testLayer); 106 ASSERT_TRUE(testLayer);
107 scoped_ptr<TextureLayerImpl> implLayer; 107 scoped_ptr<TextureLayerImpl> implLayer;
108 implLayer = TextureLayerImpl::create(m_hostImpl.activeTree(), 1, false); 108 implLayer = TextureLayerImpl::Create(m_hostImpl.activeTree(), 1, false);
109 ASSERT_TRUE(implLayer); 109 ASSERT_TRUE(implLayer);
110 110
111 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(AnyNumber()); 111 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(AnyNumber());
112 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AnyNumber()); 112 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AnyNumber());
113 m_layerTreeHost->setRootLayer(testLayer); 113 m_layerTreeHost->setRootLayer(testLayer);
114 testLayer->setTextureId(1); 114 testLayer->setTextureId(1);
115 testLayer->setIsDrawable(true); 115 testLayer->SetIsDrawable(true);
116 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); 116 Mock::VerifyAndClearExpectations(m_layerTreeHost.get());
117 EXPECT_EQ(testLayer->layerTreeHost(), m_layerTreeHost.get()); 117 EXPECT_EQ(testLayer->layer_tree_host(), m_layerTreeHost.get());
118 118
119 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(1); 119 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(1);
120 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(0); 120 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(0);
121 testLayer->willModifyTexture(); 121 testLayer->willModifyTexture();
122 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); 122 Mock::VerifyAndClearExpectations(m_layerTreeHost.get());
123 123
124 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(0); 124 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(0);
125 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(1); 125 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(1);
126 testLayer->setNeedsDisplayRect(dirtyRect); 126 testLayer->SetNeedsDisplayRect(dirtyRect);
127 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); 127 Mock::VerifyAndClearExpectations(m_layerTreeHost.get());
128 128
129 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(0); 129 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(0);
130 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(1); 130 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(1);
131 testLayer->pushPropertiesTo(implLayer.get()); // fake commit 131 testLayer->PushPropertiesTo(implLayer.get()); // fake commit
132 testLayer->setIsDrawable(false); 132 testLayer->SetIsDrawable(false);
133 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); 133 Mock::VerifyAndClearExpectations(m_layerTreeHost.get());
134 134
135 // Verify that non-drawable layers don't signal the compositor, 135 // Verify that non-drawable layers don't signal the compositor,
136 // except for the first draw after last commit, which must acquire 136 // except for the first draw after last commit, which must acquire
137 // the texture. 137 // the texture.
138 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(1); 138 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(1);
139 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(0); 139 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(0);
140 testLayer->willModifyTexture(); 140 testLayer->willModifyTexture();
141 testLayer->setNeedsDisplayRect(dirtyRect); 141 testLayer->SetNeedsDisplayRect(dirtyRect);
142 testLayer->pushPropertiesTo(implLayer.get()); // fake commit 142 testLayer->PushPropertiesTo(implLayer.get()); // fake commit
143 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); 143 Mock::VerifyAndClearExpectations(m_layerTreeHost.get());
144 144
145 // Second draw with layer in non-drawable state: no texture 145 // Second draw with layer in non-drawable state: no texture
146 // acquisition. 146 // acquisition.
147 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(0); 147 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(0);
148 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(0); 148 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(0);
149 testLayer->willModifyTexture(); 149 testLayer->willModifyTexture();
150 testLayer->setNeedsDisplayRect(dirtyRect); 150 testLayer->SetNeedsDisplayRect(dirtyRect);
151 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); 151 Mock::VerifyAndClearExpectations(m_layerTreeHost.get());
152 } 152 }
153 153
154 TEST_F(TextureLayerTest, syncImplWhenRemovingFromTree) 154 TEST_F(TextureLayerTest, syncImplWhenRemovingFromTree)
155 { 155 {
156 scoped_refptr<Layer> rootLayer = Layer::create(); 156 scoped_refptr<Layer> rootLayer = Layer::Create();
157 ASSERT_TRUE(rootLayer); 157 ASSERT_TRUE(rootLayer);
158 scoped_refptr<Layer> childLayer = Layer::create(); 158 scoped_refptr<Layer> childLayer = Layer::Create();
159 ASSERT_TRUE(childLayer); 159 ASSERT_TRUE(childLayer);
160 rootLayer->addChild(childLayer); 160 rootLayer->AddChild(childLayer);
161 scoped_refptr<TextureLayer> testLayer = TextureLayer::create(0); 161 scoped_refptr<TextureLayer> testLayer = TextureLayer::Create(NULL);
162 ASSERT_TRUE(testLayer); 162 ASSERT_TRUE(testLayer);
163 testLayer->setTextureId(0); 163 testLayer->setTextureId(0);
164 childLayer->addChild(testLayer); 164 childLayer->AddChild(testLayer);
165 165
166 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(AnyNumber()); 166 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(AnyNumber());
167 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AnyNumber()); 167 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AnyNumber());
168 m_layerTreeHost->setRootLayer(rootLayer); 168 m_layerTreeHost->setRootLayer(rootLayer);
169 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); 169 Mock::VerifyAndClearExpectations(m_layerTreeHost.get());
170 170
171 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(0); 171 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(0);
172 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AtLeast(1)); 172 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AtLeast(1));
173 testLayer->removeFromParent(); 173 testLayer->RemoveFromParent();
174 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); 174 Mock::VerifyAndClearExpectations(m_layerTreeHost.get());
175 175
176 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(0); 176 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(0);
177 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AtLeast(1)); 177 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AtLeast(1));
178 childLayer->addChild(testLayer); 178 childLayer->AddChild(testLayer);
179 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); 179 Mock::VerifyAndClearExpectations(m_layerTreeHost.get());
180 180
181 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(0); 181 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(0);
182 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AtLeast(1)); 182 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AtLeast(1));
183 testLayer->setTextureId(1); 183 testLayer->setTextureId(1);
184 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); 184 Mock::VerifyAndClearExpectations(m_layerTreeHost.get());
185 185
186 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(AtLeast(1)); 186 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(AtLeast(1));
187 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AtLeast(1)); 187 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AtLeast(1));
188 testLayer->removeFromParent(); 188 testLayer->RemoveFromParent();
189 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); 189 Mock::VerifyAndClearExpectations(m_layerTreeHost.get());
190 } 190 }
191 191
192 class MockMailboxCallback { 192 class MockMailboxCallback {
193 public: 193 public:
194 MOCK_METHOD2(Release, void(const std::string& mailbox, unsigned syncPoint)); 194 MOCK_METHOD2(Release, void(const std::string& mailbox, unsigned syncPoint));
195 }; 195 };
196 196
197 struct CommonMailboxObjects { 197 struct CommonMailboxObjects {
198 CommonMailboxObjects() 198 CommonMailboxObjects()
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 Release(m_testData.m_mailboxName1, 235 Release(m_testData.m_mailboxName1,
236 m_testData.m_syncPoint1)).Times(1); 236 m_testData.m_syncPoint1)).Times(1);
237 TextureLayerTest::TearDown(); 237 TextureLayerTest::TearDown();
238 } 238 }
239 239
240 CommonMailboxObjects m_testData; 240 CommonMailboxObjects m_testData;
241 }; 241 };
242 242
243 TEST_F(TextureLayerWithMailboxTest, replaceMailboxOnMainThreadBeforeCommit) 243 TEST_F(TextureLayerWithMailboxTest, replaceMailboxOnMainThreadBeforeCommit)
244 { 244 {
245 scoped_refptr<TextureLayer> testLayer = TextureLayer::createForMailbox(); 245 scoped_refptr<TextureLayer> testLayer = TextureLayer::CreateForMailbox();
246 ASSERT_TRUE(testLayer); 246 ASSERT_TRUE(testLayer);
247 247
248 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(0); 248 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(0);
249 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AnyNumber()); 249 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AnyNumber());
250 m_layerTreeHost->setRootLayer(testLayer); 250 m_layerTreeHost->setRootLayer(testLayer);
251 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); 251 Mock::VerifyAndClearExpectations(m_layerTreeHost.get());
252 252
253 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(0); 253 EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(0);
254 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AtLeast(1)); 254 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AtLeast(1));
255 testLayer->setTextureMailbox(m_testData.m_mailbox1); 255 testLayer->setTextureMailbox(m_testData.m_mailbox1);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 std::string(64, mailbox_char), 297 std::string(64, mailbox_char),
298 base::Bind( 298 base::Bind(
299 &TextureLayerImplWithMailboxThreadedCallback::releaseCallback, 299 &TextureLayerImplWithMailboxThreadedCallback::releaseCallback,
300 base::Unretained(this))); 300 base::Unretained(this)));
301 m_layer->setTextureMailbox(mailbox); 301 m_layer->setTextureMailbox(mailbox);
302 } 302 }
303 303
304 virtual void beginTest() OVERRIDE 304 virtual void beginTest() OVERRIDE
305 { 305 {
306 gfx::Size bounds(100, 100); 306 gfx::Size bounds(100, 100);
307 m_root = Layer::create(); 307 m_root = Layer::Create();
308 m_root->setAnchorPoint(gfx::PointF()); 308 m_root->SetAnchorPoint(gfx::PointF());
309 m_root->setBounds(bounds); 309 m_root->SetBounds(bounds);
310 310
311 m_layer = TextureLayer::createForMailbox(); 311 m_layer = TextureLayer::CreateForMailbox();
312 m_layer->setIsDrawable(true); 312 m_layer->SetIsDrawable(true);
313 m_layer->setAnchorPoint(gfx::PointF()); 313 m_layer->SetAnchorPoint(gfx::PointF());
314 m_layer->setBounds(bounds); 314 m_layer->SetBounds(bounds);
315 315
316 m_root->addChild(m_layer); 316 m_root->AddChild(m_layer);
317 m_layerTreeHost->setRootLayer(m_root); 317 m_layerTreeHost->setRootLayer(m_root);
318 m_layerTreeHost->setViewportSize(bounds, bounds); 318 m_layerTreeHost->setViewportSize(bounds, bounds);
319 setMailbox('1'); 319 setMailbox('1');
320 EXPECT_EQ(0, m_callbackCount); 320 EXPECT_EQ(0, m_callbackCount);
321 321
322 // Case #1: change mailbox before the commit. The old mailbox should be 322 // Case #1: change mailbox before the commit. The old mailbox should be
323 // released immediately. 323 // released immediately.
324 setMailbox('2'); 324 setMailbox('2');
325 EXPECT_EQ(1, m_callbackCount); 325 EXPECT_EQ(1, m_callbackCount);
326 postSetNeedsCommitToMainThread(); 326 postSetNeedsCommitToMainThread();
(...skipping 14 matching lines...) Expand all
341 // Old mailbox was released, task was posted, but won't execute 341 // Old mailbox was released, task was posted, but won't execute
342 // until this didCommit returns. 342 // until this didCommit returns.
343 // TODO(piman): fix this. 343 // TODO(piman): fix this.
344 EXPECT_EQ(1, m_callbackCount); 344 EXPECT_EQ(1, m_callbackCount);
345 m_layerTreeHost->setNeedsCommit(); 345 m_layerTreeHost->setNeedsCommit();
346 break; 346 break;
347 case 3: 347 case 3:
348 EXPECT_EQ(2, m_callbackCount); 348 EXPECT_EQ(2, m_callbackCount);
349 // Case #3: change mailbox when the layer doesn't draw. The old 349 // Case #3: change mailbox when the layer doesn't draw. The old
350 // mailbox should be released during the next commit. 350 // mailbox should be released during the next commit.
351 m_layer->setBounds(gfx::Size()); 351 m_layer->SetBounds(gfx::Size());
352 setMailbox('4'); 352 setMailbox('4');
353 break; 353 break;
354 case 4: 354 case 4:
355 // Old mailbox was released, task was posted, but won't execute 355 // Old mailbox was released, task was posted, but won't execute
356 // until this didCommit returns. 356 // until this didCommit returns.
357 // TODO(piman): fix this. 357 // TODO(piman): fix this.
358 EXPECT_EQ(2, m_callbackCount); 358 EXPECT_EQ(2, m_callbackCount);
359 m_layerTreeHost->setNeedsCommit(); 359 m_layerTreeHost->setNeedsCommit();
360 break; 360 break;
361 case 5: 361 case 5:
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 EXPECT_TRUE(m_hostImpl.initializeRenderer(createFakeOutputSurface())); 403 EXPECT_TRUE(m_hostImpl.initializeRenderer(createFakeOutputSurface()));
404 } 404 }
405 405
406 CommonMailboxObjects m_testData; 406 CommonMailboxObjects m_testData;
407 }; 407 };
408 408
409 TEST_F(TextureLayerImplWithMailboxTest, testImplLayerCallbacks) 409 TEST_F(TextureLayerImplWithMailboxTest, testImplLayerCallbacks)
410 { 410 {
411 m_hostImpl.createPendingTree(); 411 m_hostImpl.createPendingTree();
412 scoped_ptr<TextureLayerImpl> pendingLayer; 412 scoped_ptr<TextureLayerImpl> pendingLayer;
413 pendingLayer = TextureLayerImpl::create(m_hostImpl.pendingTree(), 1, true); 413 pendingLayer = TextureLayerImpl::Create(m_hostImpl.pendingTree(), 1, true);
414 ASSERT_TRUE(pendingLayer); 414 ASSERT_TRUE(pendingLayer);
415 415
416 scoped_ptr<LayerImpl> activeLayer(pendingLayer->createLayerImpl( 416 scoped_ptr<LayerImpl> activeLayer(pendingLayer->CreateLayerImpl(
417 m_hostImpl.activeTree())); 417 m_hostImpl.activeTree()));
418 ASSERT_TRUE(activeLayer); 418 ASSERT_TRUE(activeLayer);
419 419
420 pendingLayer->setTextureMailbox(m_testData.m_mailbox1); 420 pendingLayer->setTextureMailbox(m_testData.m_mailbox1);
421 421
422 // Test multiple commits without an activation. 422 // Test multiple commits without an activation.
423 EXPECT_CALL(m_testData.m_mockCallback, 423 EXPECT_CALL(m_testData.m_mockCallback,
424 Release(m_testData.m_mailboxName1, 424 Release(m_testData.m_mailboxName1,
425 m_testData.m_syncPoint1)).Times(1); 425 m_testData.m_syncPoint1)).Times(1);
426 pendingLayer->setTextureMailbox(m_testData.m_mailbox2); 426 pendingLayer->setTextureMailbox(m_testData.m_mailbox2);
427 Mock::VerifyAndClearExpectations(&m_testData.m_mockCallback); 427 Mock::VerifyAndClearExpectations(&m_testData.m_mockCallback);
428 428
429 // Test callback after activation. 429 // Test callback after activation.
430 pendingLayer->pushPropertiesTo(activeLayer.get()); 430 pendingLayer->PushPropertiesTo(activeLayer.get());
431 activeLayer->didBecomeActive(); 431 activeLayer->DidBecomeActive();
432 432
433 EXPECT_CALL(m_testData.m_mockCallback, 433 EXPECT_CALL(m_testData.m_mockCallback,
434 Release(_, _)).Times(0); 434 Release(_, _)).Times(0);
435 pendingLayer->setTextureMailbox(m_testData.m_mailbox1); 435 pendingLayer->setTextureMailbox(m_testData.m_mailbox1);
436 Mock::VerifyAndClearExpectations(&m_testData.m_mockCallback); 436 Mock::VerifyAndClearExpectations(&m_testData.m_mockCallback);
437 437
438 EXPECT_CALL(m_testData.m_mockCallback, 438 EXPECT_CALL(m_testData.m_mockCallback,
439 Release(m_testData.m_mailboxName2, _)).Times(1); 439 Release(m_testData.m_mailboxName2, _)).Times(1);
440 pendingLayer->pushPropertiesTo(activeLayer.get()); 440 pendingLayer->PushPropertiesTo(activeLayer.get());
441 activeLayer->didBecomeActive(); 441 activeLayer->DidBecomeActive();
442 Mock::VerifyAndClearExpectations(&m_testData.m_mockCallback); 442 Mock::VerifyAndClearExpectations(&m_testData.m_mockCallback);
443 443
444 // Test resetting the mailbox. 444 // Test resetting the mailbox.
445 EXPECT_CALL(m_testData.m_mockCallback, 445 EXPECT_CALL(m_testData.m_mockCallback,
446 Release(m_testData.m_mailboxName1, _)).Times(1); 446 Release(m_testData.m_mailboxName1, _)).Times(1);
447 pendingLayer->setTextureMailbox(TextureMailbox()); 447 pendingLayer->setTextureMailbox(TextureMailbox());
448 pendingLayer->pushPropertiesTo(activeLayer.get()); 448 pendingLayer->PushPropertiesTo(activeLayer.get());
449 activeLayer->didBecomeActive(); 449 activeLayer->DidBecomeActive();
450 Mock::VerifyAndClearExpectations(&m_testData.m_mockCallback); 450 Mock::VerifyAndClearExpectations(&m_testData.m_mockCallback);
451 451
452 // Test destructor. 452 // Test destructor.
453 EXPECT_CALL(m_testData.m_mockCallback, 453 EXPECT_CALL(m_testData.m_mockCallback,
454 Release(m_testData.m_mailboxName1, 454 Release(m_testData.m_mailboxName1,
455 m_testData.m_syncPoint1)).Times(1); 455 m_testData.m_syncPoint1)).Times(1);
456 pendingLayer->setTextureMailbox(m_testData.m_mailbox1); 456 pendingLayer->setTextureMailbox(m_testData.m_mailbox1);
457 } 457 }
458 458
459 TEST_F(TextureLayerImplWithMailboxTest, testDestructorCallbackOnCreatedResource) 459 TEST_F(TextureLayerImplWithMailboxTest, testDestructorCallbackOnCreatedResource)
460 { 460 {
461 scoped_ptr<TextureLayerImpl> implLayer; 461 scoped_ptr<TextureLayerImpl> implLayer;
462 implLayer = TextureLayerImpl::create(m_hostImpl.activeTree(), 1, true); 462 implLayer = TextureLayerImpl::Create(m_hostImpl.activeTree(), 1, true);
463 ASSERT_TRUE(implLayer); 463 ASSERT_TRUE(implLayer);
464 464
465 EXPECT_CALL(m_testData.m_mockCallback, 465 EXPECT_CALL(m_testData.m_mockCallback,
466 Release(m_testData.m_mailboxName1, _)).Times(1); 466 Release(m_testData.m_mailboxName1, _)).Times(1);
467 implLayer->setTextureMailbox(m_testData.m_mailbox1); 467 implLayer->setTextureMailbox(m_testData.m_mailbox1);
468 implLayer->willDraw(m_hostImpl.activeTree()->resource_provider()); 468 implLayer->WillDraw(m_hostImpl.activeTree()->resource_provider());
469 implLayer->didDraw(m_hostImpl.activeTree()->resource_provider()); 469 implLayer->DidDraw(m_hostImpl.activeTree()->resource_provider());
470 implLayer->setTextureMailbox(TextureMailbox()); 470 implLayer->setTextureMailbox(TextureMailbox());
471 } 471 }
472 472
473 TEST_F(TextureLayerImplWithMailboxTest, testCallbackOnInUseResource) 473 TEST_F(TextureLayerImplWithMailboxTest, testCallbackOnInUseResource)
474 { 474 {
475 ResourceProvider *provider = m_hostImpl.activeTree()->resource_provider(); 475 ResourceProvider *provider = m_hostImpl.activeTree()->resource_provider();
476 ResourceProvider::ResourceId id = 476 ResourceProvider::ResourceId id =
477 provider->CreateResourceFromTextureMailbox(m_testData.m_mailbox1); 477 provider->CreateResourceFromTextureMailbox(m_testData.m_mailbox1);
478 provider->AllocateForTesting(id); 478 provider->AllocateForTesting(id);
479 479
480 // Transfer some resources to the parent. 480 // Transfer some resources to the parent.
481 ResourceProvider::ResourceIdArray resourceIdsToTransfer; 481 ResourceProvider::ResourceIdArray resourceIdsToTransfer;
482 resourceIdsToTransfer.push_back(id); 482 resourceIdsToTransfer.push_back(id);
483 TransferableResourceArray list; 483 TransferableResourceArray list;
484 provider->PrepareSendToParent(resourceIdsToTransfer, &list); 484 provider->PrepareSendToParent(resourceIdsToTransfer, &list);
485 EXPECT_TRUE(provider->InUseByConsumer(id)); 485 EXPECT_TRUE(provider->InUseByConsumer(id));
486 EXPECT_CALL(m_testData.m_mockCallback, Release(_, _)).Times(0); 486 EXPECT_CALL(m_testData.m_mockCallback, Release(_, _)).Times(0);
487 provider->DeleteResource(id); 487 provider->DeleteResource(id);
488 Mock::VerifyAndClearExpectations(&m_testData.m_mockCallback); 488 Mock::VerifyAndClearExpectations(&m_testData.m_mockCallback);
489 EXPECT_CALL(m_testData.m_mockCallback, 489 EXPECT_CALL(m_testData.m_mockCallback,
490 Release(m_testData.m_mailboxName1, _)).Times(1); 490 Release(m_testData.m_mailboxName1, _)).Times(1);
491 provider->ReceiveFromParent(list); 491 provider->ReceiveFromParent(list);
492 } 492 }
493 493
494 } // namespace 494 } // namespace
495 } // namespace cc 495 } // namespace cc
OLDNEW
« no previous file with comments | « cc/texture_layer_impl.cc ('k') | cc/tiled_layer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698