| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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 "LayerChromium.h" | 7 #include "LayerChromium.h" |
| 8 | 8 |
| 9 #include "CCGeometryTestUtils.h" | 9 #include "CCGeometryTestUtils.h" |
| 10 #include "CCLayerImpl.h" | 10 #include "CCLayerImpl.h" |
| 11 #include "CCLayerTreeHost.h" | 11 #include "CCLayerTreeHost.h" |
| 12 #include "CCSingleThreadProxy.h" | 12 #include "CCSingleThreadProxy.h" |
| 13 #include "FakeCCLayerTreeHostClient.h" | 13 #include "FakeCCLayerTreeHostClient.h" |
| 14 #include "LayerPainterChromium.h" | 14 #include "LayerPainterChromium.h" |
| 15 #include "WebCompositorInitializer.h" |
| 15 #include <gmock/gmock.h> | 16 #include <gmock/gmock.h> |
| 16 #include <gtest/gtest.h> | 17 #include <gtest/gtest.h> |
| 17 #include <public/WebCompositor.h> | |
| 18 #include <public/WebTransformationMatrix.h> | 18 #include <public/WebTransformationMatrix.h> |
| 19 | 19 |
| 20 using namespace WebCore; | 20 using namespace WebCore; |
| 21 using namespace WebKitTests; | 21 using namespace WebKitTests; |
| 22 using WebKit::WebTransformationMatrix; | 22 using WebKit::WebTransformationMatrix; |
| 23 using ::testing::Mock; | 23 using ::testing::Mock; |
| 24 using ::testing::_; | 24 using ::testing::_; |
| 25 using ::testing::AtLeast; | 25 using ::testing::AtLeast; |
| 26 using ::testing::AnyNumber; | 26 using ::testing::AnyNumber; |
| 27 | 27 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 47 FakeCCLayerTreeHostClient m_fakeClient; | 47 FakeCCLayerTreeHostClient m_fakeClient; |
| 48 }; | 48 }; |
| 49 | 49 |
| 50 class MockLayerPainterChromium : public LayerPainterChromium { | 50 class MockLayerPainterChromium : public LayerPainterChromium { |
| 51 public: | 51 public: |
| 52 virtual void paint(SkCanvas*, const IntRect&, FloatRect&) OVERRIDE { } | 52 virtual void paint(SkCanvas*, const IntRect&, FloatRect&) OVERRIDE { } |
| 53 }; | 53 }; |
| 54 | 54 |
| 55 | 55 |
| 56 class LayerChromiumTest : public testing::Test { | 56 class LayerChromiumTest : public testing::Test { |
| 57 public: |
| 58 LayerChromiumTest() |
| 59 : m_compositorInitializer(0) |
| 60 { |
| 61 } |
| 62 |
| 57 protected: | 63 protected: |
| 58 virtual void SetUp() | 64 virtual void SetUp() |
| 59 { | 65 { |
| 60 // Initialize without threading support. | |
| 61 WebKit::WebCompositor::initialize(0); | |
| 62 m_layerTreeHost = adoptPtr(new MockCCLayerTreeHost); | 66 m_layerTreeHost = adoptPtr(new MockCCLayerTreeHost); |
| 63 } | 67 } |
| 64 | 68 |
| 65 virtual void TearDown() | 69 virtual void TearDown() |
| 66 { | 70 { |
| 67 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); | 71 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); |
| 68 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AnyNumber()); | 72 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AnyNumber()); |
| 69 m_parent.clear(); | 73 m_parent.clear(); |
| 70 m_child1.clear(); | 74 m_child1.clear(); |
| 71 m_child2.clear(); | 75 m_child2.clear(); |
| 72 m_child3.clear(); | 76 m_child3.clear(); |
| 73 m_grandChild1.clear(); | 77 m_grandChild1.clear(); |
| 74 m_grandChild2.clear(); | 78 m_grandChild2.clear(); |
| 75 m_grandChild3.clear(); | 79 m_grandChild3.clear(); |
| 76 | 80 |
| 77 m_layerTreeHost->setRootLayer(0); | 81 m_layerTreeHost->setRootLayer(0); |
| 78 m_layerTreeHost.clear(); | 82 m_layerTreeHost.clear(); |
| 79 WebKit::WebCompositor::shutdown(); | |
| 80 } | 83 } |
| 81 | 84 |
| 82 void verifyTestTreeInitialState() const | 85 void verifyTestTreeInitialState() const |
| 83 { | 86 { |
| 84 ASSERT_EQ(static_cast<size_t>(3), m_parent->children().size()); | 87 ASSERT_EQ(static_cast<size_t>(3), m_parent->children().size()); |
| 85 EXPECT_EQ(m_child1, m_parent->children()[0]); | 88 EXPECT_EQ(m_child1, m_parent->children()[0]); |
| 86 EXPECT_EQ(m_child2, m_parent->children()[1]); | 89 EXPECT_EQ(m_child2, m_parent->children()[1]); |
| 87 EXPECT_EQ(m_child3, m_parent->children()[2]); | 90 EXPECT_EQ(m_child3, m_parent->children()[2]); |
| 88 EXPECT_EQ(m_parent.get(), m_child1->parent()); | 91 EXPECT_EQ(m_parent.get(), m_child1->parent()); |
| 89 EXPECT_EQ(m_parent.get(), m_child2->parent()); | 92 EXPECT_EQ(m_parent.get(), m_child2->parent()); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 m_child1->addChild(m_grandChild2); | 125 m_child1->addChild(m_grandChild2); |
| 123 m_child2->addChild(m_grandChild3); | 126 m_child2->addChild(m_grandChild3); |
| 124 | 127 |
| 125 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); | 128 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); |
| 126 | 129 |
| 127 verifyTestTreeInitialState(); | 130 verifyTestTreeInitialState(); |
| 128 } | 131 } |
| 129 | 132 |
| 130 OwnPtr<MockCCLayerTreeHost> m_layerTreeHost; | 133 OwnPtr<MockCCLayerTreeHost> m_layerTreeHost; |
| 131 RefPtr<LayerChromium> m_parent, m_child1, m_child2, m_child3, m_grandChild1,
m_grandChild2, m_grandChild3; | 134 RefPtr<LayerChromium> m_parent, m_child1, m_child2, m_child3, m_grandChild1,
m_grandChild2, m_grandChild3; |
| 135 WebCompositorInitializer m_compositorInitializer; |
| 132 }; | 136 }; |
| 133 | 137 |
| 134 TEST_F(LayerChromiumTest, basicCreateAndDestroy) | 138 TEST_F(LayerChromiumTest, basicCreateAndDestroy) |
| 135 { | 139 { |
| 136 RefPtr<LayerChromium> testLayer = LayerChromium::create(); | 140 RefPtr<LayerChromium> testLayer = LayerChromium::create(); |
| 137 ASSERT_TRUE(testLayer); | 141 ASSERT_TRUE(testLayer); |
| 138 | 142 |
| 139 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(0); | 143 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(0); |
| 140 testLayer->setLayerTreeHost(m_layerTreeHost.get()); | 144 testLayer->setLayerTreeHost(m_layerTreeHost.get()); |
| 141 } | 145 } |
| (...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 608 if (layer->maskLayer()) | 612 if (layer->maskLayer()) |
| 609 assertLayerTreeHostMatchesForSubtree(layer->maskLayer(), host); | 613 assertLayerTreeHostMatchesForSubtree(layer->maskLayer(), host); |
| 610 | 614 |
| 611 if (layer->replicaLayer()) | 615 if (layer->replicaLayer()) |
| 612 assertLayerTreeHostMatchesForSubtree(layer->replicaLayer(), host); | 616 assertLayerTreeHostMatchesForSubtree(layer->replicaLayer(), host); |
| 613 } | 617 } |
| 614 | 618 |
| 615 | 619 |
| 616 TEST(LayerChromiumLayerTreeHostTest, enteringTree) | 620 TEST(LayerChromiumLayerTreeHostTest, enteringTree) |
| 617 { | 621 { |
| 618 WebKit::WebCompositor::initialize(0); | 622 WebCompositorInitializer compositorInitializer(0); |
| 619 RefPtr<LayerChromium> parent = LayerChromium::create(); | 623 RefPtr<LayerChromium> parent = LayerChromium::create(); |
| 620 RefPtr<LayerChromium> child = LayerChromium::create(); | 624 RefPtr<LayerChromium> child = LayerChromium::create(); |
| 621 RefPtr<LayerChromium> mask = LayerChromium::create(); | 625 RefPtr<LayerChromium> mask = LayerChromium::create(); |
| 622 RefPtr<LayerChromium> replica = LayerChromium::create(); | 626 RefPtr<LayerChromium> replica = LayerChromium::create(); |
| 623 RefPtr<LayerChromium> replicaMask = LayerChromium::create(); | 627 RefPtr<LayerChromium> replicaMask = LayerChromium::create(); |
| 624 | 628 |
| 625 // Set up a detached tree of layers. The host pointer should be nil for thes
e layers. | 629 // Set up a detached tree of layers. The host pointer should be nil for thes
e layers. |
| 626 parent->addChild(child); | 630 parent->addChild(child); |
| 627 child->setMaskLayer(mask.get()); | 631 child->setMaskLayer(mask.get()); |
| 628 child->setReplicaLayer(replica.get()); | 632 child->setReplicaLayer(replica.get()); |
| 629 replica->setMaskLayer(mask.get()); | 633 replica->setMaskLayer(mask.get()); |
| 630 | 634 |
| 631 assertLayerTreeHostMatchesForSubtree(parent.get(), 0); | 635 assertLayerTreeHostMatchesForSubtree(parent.get(), 0); |
| 632 | 636 |
| 633 OwnPtr<FakeCCLayerTreeHost> layerTreeHost(FakeCCLayerTreeHost::create()); | 637 OwnPtr<FakeCCLayerTreeHost> layerTreeHost(FakeCCLayerTreeHost::create()); |
| 634 // Setting the root layer should set the host pointer for all layers in the
tree. | 638 // Setting the root layer should set the host pointer for all layers in the
tree. |
| 635 layerTreeHost->setRootLayer(parent.get()); | 639 layerTreeHost->setRootLayer(parent.get()); |
| 636 | 640 |
| 637 assertLayerTreeHostMatchesForSubtree(parent.get(), layerTreeHost.get()); | 641 assertLayerTreeHostMatchesForSubtree(parent.get(), layerTreeHost.get()); |
| 638 | 642 |
| 639 // Clearing the root layer should also clear out the host pointers for all l
ayers in the tree. | 643 // Clearing the root layer should also clear out the host pointers for all l
ayers in the tree. |
| 640 layerTreeHost->setRootLayer(0); | 644 layerTreeHost->setRootLayer(0); |
| 641 | 645 |
| 642 assertLayerTreeHostMatchesForSubtree(parent.get(), 0); | 646 assertLayerTreeHostMatchesForSubtree(parent.get(), 0); |
| 643 | 647 |
| 644 layerTreeHost.clear(); | 648 layerTreeHost.clear(); |
| 645 WebKit::WebCompositor::shutdown(); | |
| 646 } | 649 } |
| 647 | 650 |
| 648 TEST(LayerChromiumLayerTreeHostTest, addingLayerSubtree) | 651 TEST(LayerChromiumLayerTreeHostTest, addingLayerSubtree) |
| 649 { | 652 { |
| 650 WebKit::WebCompositor::initialize(0); | 653 WebCompositorInitializer compositorInitializer(0); |
| 651 RefPtr<LayerChromium> parent = LayerChromium::create(); | 654 RefPtr<LayerChromium> parent = LayerChromium::create(); |
| 652 OwnPtr<FakeCCLayerTreeHost> layerTreeHost(FakeCCLayerTreeHost::create()); | 655 OwnPtr<FakeCCLayerTreeHost> layerTreeHost(FakeCCLayerTreeHost::create()); |
| 653 | 656 |
| 654 layerTreeHost->setRootLayer(parent.get()); | 657 layerTreeHost->setRootLayer(parent.get()); |
| 655 | 658 |
| 656 EXPECT_EQ(parent->layerTreeHost(), layerTreeHost.get()); | 659 EXPECT_EQ(parent->layerTreeHost(), layerTreeHost.get()); |
| 657 | 660 |
| 658 // Adding a subtree to a layer already associated with a host should set the
host pointer on all layers in that subtree. | 661 // Adding a subtree to a layer already associated with a host should set the
host pointer on all layers in that subtree. |
| 659 RefPtr<LayerChromium> child = LayerChromium::create(); | 662 RefPtr<LayerChromium> child = LayerChromium::create(); |
| 660 RefPtr<LayerChromium> grandChild = LayerChromium::create(); | 663 RefPtr<LayerChromium> grandChild = LayerChromium::create(); |
| 661 child->addChild(grandChild); | 664 child->addChild(grandChild); |
| 662 | 665 |
| 663 // Masks, replicas, and replica masks should pick up the new host too. | 666 // Masks, replicas, and replica masks should pick up the new host too. |
| 664 RefPtr<LayerChromium> childMask = LayerChromium::create(); | 667 RefPtr<LayerChromium> childMask = LayerChromium::create(); |
| 665 child->setMaskLayer(childMask.get()); | 668 child->setMaskLayer(childMask.get()); |
| 666 RefPtr<LayerChromium> childReplica = LayerChromium::create(); | 669 RefPtr<LayerChromium> childReplica = LayerChromium::create(); |
| 667 child->setReplicaLayer(childReplica.get()); | 670 child->setReplicaLayer(childReplica.get()); |
| 668 RefPtr<LayerChromium> childReplicaMask = LayerChromium::create(); | 671 RefPtr<LayerChromium> childReplicaMask = LayerChromium::create(); |
| 669 childReplica->setMaskLayer(childReplicaMask.get()); | 672 childReplica->setMaskLayer(childReplicaMask.get()); |
| 670 | 673 |
| 671 parent->addChild(child); | 674 parent->addChild(child); |
| 672 assertLayerTreeHostMatchesForSubtree(parent.get(), layerTreeHost.get()); | 675 assertLayerTreeHostMatchesForSubtree(parent.get(), layerTreeHost.get()); |
| 673 | 676 |
| 674 layerTreeHost->setRootLayer(0); | 677 layerTreeHost->setRootLayer(0); |
| 675 layerTreeHost.clear(); | 678 layerTreeHost.clear(); |
| 676 WebKit::WebCompositor::shutdown(); | |
| 677 } | 679 } |
| 678 | 680 |
| 679 TEST(LayerChromiumLayerTreeHostTest, changeHost) | 681 TEST(LayerChromiumLayerTreeHostTest, changeHost) |
| 680 { | 682 { |
| 681 WebKit::WebCompositor::initialize(0); | 683 WebCompositorInitializer compositorInitializer(0); |
| 682 RefPtr<LayerChromium> parent = LayerChromium::create(); | 684 RefPtr<LayerChromium> parent = LayerChromium::create(); |
| 683 RefPtr<LayerChromium> child = LayerChromium::create(); | 685 RefPtr<LayerChromium> child = LayerChromium::create(); |
| 684 RefPtr<LayerChromium> mask = LayerChromium::create(); | 686 RefPtr<LayerChromium> mask = LayerChromium::create(); |
| 685 RefPtr<LayerChromium> replica = LayerChromium::create(); | 687 RefPtr<LayerChromium> replica = LayerChromium::create(); |
| 686 RefPtr<LayerChromium> replicaMask = LayerChromium::create(); | 688 RefPtr<LayerChromium> replicaMask = LayerChromium::create(); |
| 687 | 689 |
| 688 // Same setup as the previous test. | 690 // Same setup as the previous test. |
| 689 parent->addChild(child); | 691 parent->addChild(child); |
| 690 child->setMaskLayer(mask.get()); | 692 child->setMaskLayer(mask.get()); |
| 691 child->setReplicaLayer(replica.get()); | 693 child->setReplicaLayer(replica.get()); |
| 692 replica->setMaskLayer(mask.get()); | 694 replica->setMaskLayer(mask.get()); |
| 693 | 695 |
| 694 OwnPtr<FakeCCLayerTreeHost> firstLayerTreeHost(FakeCCLayerTreeHost::create()
); | 696 OwnPtr<FakeCCLayerTreeHost> firstLayerTreeHost(FakeCCLayerTreeHost::create()
); |
| 695 firstLayerTreeHost->setRootLayer(parent.get()); | 697 firstLayerTreeHost->setRootLayer(parent.get()); |
| 696 | 698 |
| 697 assertLayerTreeHostMatchesForSubtree(parent.get(), firstLayerTreeHost.get())
; | 699 assertLayerTreeHostMatchesForSubtree(parent.get(), firstLayerTreeHost.get())
; |
| 698 | 700 |
| 699 // Now re-root the tree to a new host (simulating what we do on a context lo
st event). | 701 // Now re-root the tree to a new host (simulating what we do on a context lo
st event). |
| 700 // This should update the host pointers for all layers in the tree. | 702 // This should update the host pointers for all layers in the tree. |
| 701 OwnPtr<FakeCCLayerTreeHost> secondLayerTreeHost(FakeCCLayerTreeHost::create(
)); | 703 OwnPtr<FakeCCLayerTreeHost> secondLayerTreeHost(FakeCCLayerTreeHost::create(
)); |
| 702 secondLayerTreeHost->setRootLayer(parent.get()); | 704 secondLayerTreeHost->setRootLayer(parent.get()); |
| 703 | 705 |
| 704 assertLayerTreeHostMatchesForSubtree(parent.get(), secondLayerTreeHost.get()
); | 706 assertLayerTreeHostMatchesForSubtree(parent.get(), secondLayerTreeHost.get()
); |
| 705 | 707 |
| 706 secondLayerTreeHost->setRootLayer(0); | 708 secondLayerTreeHost->setRootLayer(0); |
| 707 firstLayerTreeHost.clear(); | 709 firstLayerTreeHost.clear(); |
| 708 secondLayerTreeHost.clear(); | 710 secondLayerTreeHost.clear(); |
| 709 WebKit::WebCompositor::shutdown(); | |
| 710 } | 711 } |
| 711 | 712 |
| 712 TEST(LayerChromiumLayerTreeHostTest, changeHostInSubtree) | 713 TEST(LayerChromiumLayerTreeHostTest, changeHostInSubtree) |
| 713 { | 714 { |
| 714 WebKit::WebCompositor::initialize(0); | 715 WebCompositorInitializer compositorInitializer(0); |
| 715 RefPtr<LayerChromium> firstParent = LayerChromium::create(); | 716 RefPtr<LayerChromium> firstParent = LayerChromium::create(); |
| 716 RefPtr<LayerChromium> firstChild = LayerChromium::create(); | 717 RefPtr<LayerChromium> firstChild = LayerChromium::create(); |
| 717 RefPtr<LayerChromium> secondParent = LayerChromium::create(); | 718 RefPtr<LayerChromium> secondParent = LayerChromium::create(); |
| 718 RefPtr<LayerChromium> secondChild = LayerChromium::create(); | 719 RefPtr<LayerChromium> secondChild = LayerChromium::create(); |
| 719 RefPtr<LayerChromium> secondGrandChild = LayerChromium::create(); | 720 RefPtr<LayerChromium> secondGrandChild = LayerChromium::create(); |
| 720 | 721 |
| 721 // First put all children under the first parent and set the first host. | 722 // First put all children under the first parent and set the first host. |
| 722 firstParent->addChild(firstChild); | 723 firstParent->addChild(firstChild); |
| 723 secondChild->addChild(secondGrandChild); | 724 secondChild->addChild(secondGrandChild); |
| 724 firstParent->addChild(secondChild); | 725 firstParent->addChild(secondChild); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 736 | 737 |
| 737 // The moved layer and its children should point to the new host. | 738 // The moved layer and its children should point to the new host. |
| 738 EXPECT_EQ(secondLayerTreeHost.get(), secondChild->layerTreeHost()); | 739 EXPECT_EQ(secondLayerTreeHost.get(), secondChild->layerTreeHost()); |
| 739 EXPECT_EQ(secondLayerTreeHost.get(), secondGrandChild->layerTreeHost()); | 740 EXPECT_EQ(secondLayerTreeHost.get(), secondGrandChild->layerTreeHost()); |
| 740 | 741 |
| 741 // Test over, cleanup time. | 742 // Test over, cleanup time. |
| 742 firstLayerTreeHost->setRootLayer(0); | 743 firstLayerTreeHost->setRootLayer(0); |
| 743 secondLayerTreeHost->setRootLayer(0); | 744 secondLayerTreeHost->setRootLayer(0); |
| 744 firstLayerTreeHost.clear(); | 745 firstLayerTreeHost.clear(); |
| 745 secondLayerTreeHost.clear(); | 746 secondLayerTreeHost.clear(); |
| 746 WebKit::WebCompositor::shutdown(); | |
| 747 } | 747 } |
| 748 | 748 |
| 749 TEST(LayerChromiumLayerTreeHostTest, replaceMaskAndReplicaLayer) | 749 TEST(LayerChromiumLayerTreeHostTest, replaceMaskAndReplicaLayer) |
| 750 { | 750 { |
| 751 WebKit::WebCompositor::initialize(0); | 751 WebCompositorInitializer compositorInitializer(0); |
| 752 RefPtr<LayerChromium> parent = LayerChromium::create(); | 752 RefPtr<LayerChromium> parent = LayerChromium::create(); |
| 753 RefPtr<LayerChromium> mask = LayerChromium::create(); | 753 RefPtr<LayerChromium> mask = LayerChromium::create(); |
| 754 RefPtr<LayerChromium> replica = LayerChromium::create(); | 754 RefPtr<LayerChromium> replica = LayerChromium::create(); |
| 755 RefPtr<LayerChromium> maskChild = LayerChromium::create(); | 755 RefPtr<LayerChromium> maskChild = LayerChromium::create(); |
| 756 RefPtr<LayerChromium> replicaChild = LayerChromium::create(); | 756 RefPtr<LayerChromium> replicaChild = LayerChromium::create(); |
| 757 RefPtr<LayerChromium> maskReplacement = LayerChromium::create(); | 757 RefPtr<LayerChromium> maskReplacement = LayerChromium::create(); |
| 758 RefPtr<LayerChromium> replicaReplacement = LayerChromium::create(); | 758 RefPtr<LayerChromium> replicaReplacement = LayerChromium::create(); |
| 759 | 759 |
| 760 parent->setMaskLayer(mask.get()); | 760 parent->setMaskLayer(mask.get()); |
| 761 parent->setReplicaLayer(replica.get()); | 761 parent->setReplicaLayer(replica.get()); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 773 EXPECT_EQ(0, maskChild->layerTreeHost()); | 773 EXPECT_EQ(0, maskChild->layerTreeHost()); |
| 774 | 774 |
| 775 // Same for replacing a replica layer. | 775 // Same for replacing a replica layer. |
| 776 parent->setReplicaLayer(replicaReplacement.get()); | 776 parent->setReplicaLayer(replicaReplacement.get()); |
| 777 EXPECT_EQ(0, replica->layerTreeHost()); | 777 EXPECT_EQ(0, replica->layerTreeHost()); |
| 778 EXPECT_EQ(0, replicaChild->layerTreeHost()); | 778 EXPECT_EQ(0, replicaChild->layerTreeHost()); |
| 779 | 779 |
| 780 // Test over, cleanup time. | 780 // Test over, cleanup time. |
| 781 layerTreeHost->setRootLayer(0); | 781 layerTreeHost->setRootLayer(0); |
| 782 layerTreeHost.clear(); | 782 layerTreeHost.clear(); |
| 783 WebKit::WebCompositor::shutdown(); | |
| 784 } | 783 } |
| 785 | 784 |
| 786 TEST(LayerChromiumLayerTreeHostTest, destroyHostWithNonNullRootLayer) | 785 TEST(LayerChromiumLayerTreeHostTest, destroyHostWithNonNullRootLayer) |
| 787 { | 786 { |
| 788 WebKit::WebCompositor::initialize(0); | 787 WebCompositorInitializer compositorInitializer(0); |
| 789 RefPtr<LayerChromium> root = LayerChromium::create(); | 788 RefPtr<LayerChromium> root = LayerChromium::create(); |
| 790 RefPtr<LayerChromium> child = LayerChromium::create(); | 789 RefPtr<LayerChromium> child = LayerChromium::create(); |
| 791 root->addChild(child); | 790 root->addChild(child); |
| 792 OwnPtr<FakeCCLayerTreeHost> layerTreeHost(FakeCCLayerTreeHost::create()); | 791 OwnPtr<FakeCCLayerTreeHost> layerTreeHost(FakeCCLayerTreeHost::create()); |
| 793 layerTreeHost->setRootLayer(root); | 792 layerTreeHost->setRootLayer(root); |
| 794 layerTreeHost.clear(); | 793 layerTreeHost.clear(); |
| 795 WebKit::WebCompositor::shutdown(); | |
| 796 } | 794 } |
| 797 | 795 |
| 798 class MockLayerChromium : public LayerChromium { | 796 class MockLayerChromium : public LayerChromium { |
| 799 public: | 797 public: |
| 800 bool needsDisplay() const { return m_needsDisplay; } | 798 bool needsDisplay() const { return m_needsDisplay; } |
| 801 }; | 799 }; |
| 802 | 800 |
| 803 TEST(LayerChromiumTestWithoutFixture, setBoundsTriggersSetNeedsRedrawAfterGettin
gNonEmptyBounds) | 801 TEST(LayerChromiumTestWithoutFixture, setBoundsTriggersSetNeedsRedrawAfterGettin
gNonEmptyBounds) |
| 804 { | 802 { |
| 805 RefPtr<MockLayerChromium> layer(adoptRef(new MockLayerChromium)); | 803 RefPtr<MockLayerChromium> layer(adoptRef(new MockLayerChromium)); |
| 806 EXPECT_FALSE(layer->needsDisplay()); | 804 EXPECT_FALSE(layer->needsDisplay()); |
| 807 layer->setBounds(IntSize(0, 10)); | 805 layer->setBounds(IntSize(0, 10)); |
| 808 EXPECT_FALSE(layer->needsDisplay()); | 806 EXPECT_FALSE(layer->needsDisplay()); |
| 809 layer->setBounds(IntSize(10, 10)); | 807 layer->setBounds(IntSize(10, 10)); |
| 810 EXPECT_TRUE(layer->needsDisplay()); | 808 EXPECT_TRUE(layer->needsDisplay()); |
| 811 } | 809 } |
| 812 | 810 |
| 813 | 811 |
| 814 } // namespace | 812 } // namespace |
| OLD | NEW |