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

Side by Side Diff: cc/texture_layer_unittest.cc

Issue 12648005: cc: Chromify the LayerTreeHostImpl class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Compl 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/test/layer_tree_test_common.cc ('k') | cc/thread_proxy.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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(NULL); 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.active_tree(), 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->layer_tree_host(), m_layerTreeHost.get()); 117 EXPECT_EQ(testLayer->layer_tree_host(), m_layerTreeHost.get());
118 118
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 }; 393 };
394 394
395 SINGLE_AND_MULTI_THREAD_TEST_F(TextureLayerImplWithMailboxThreadedCallback); 395 SINGLE_AND_MULTI_THREAD_TEST_F(TextureLayerImplWithMailboxThreadedCallback);
396 396
397 class TextureLayerImplWithMailboxTest : public TextureLayerTest { 397 class TextureLayerImplWithMailboxTest : public TextureLayerTest {
398 protected: 398 protected:
399 virtual void SetUp() 399 virtual void SetUp()
400 { 400 {
401 TextureLayerTest::SetUp(); 401 TextureLayerTest::SetUp();
402 m_layerTreeHost.reset(new MockLayerImplTreeHost); 402 m_layerTreeHost.reset(new MockLayerImplTreeHost);
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.pending_tree(), 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.active_tree()));
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);
(...skipping 24 matching lines...) Expand all
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.active_tree(), 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.active_tree()->resource_provider());
469 implLayer->DidDraw(m_hostImpl.activeTree()->resource_provider()); 469 implLayer->DidDraw(m_hostImpl.active_tree()->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.active_tree()->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/test/layer_tree_test_common.cc ('k') | cc/thread_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698