OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/trees/layer_tree_host.h" | 5 #include "cc/trees/layer_tree_host.h" |
6 | 6 |
| 7 #include "cc/layers/solid_color_layer.h" |
| 8 #include "cc/test/fake_content_layer.h" |
7 #include "cc/test/fake_content_layer_client.h" | 9 #include "cc/test/fake_content_layer_client.h" |
| 10 #include "cc/test/fake_content_layer_impl.h" |
8 #include "cc/test/fake_picture_layer.h" | 11 #include "cc/test/fake_picture_layer.h" |
9 #include "cc/test/fake_picture_layer_impl.h" | 12 #include "cc/test/fake_picture_layer_impl.h" |
10 #include "cc/test/layer_tree_test.h" | 13 #include "cc/test/layer_tree_test.h" |
11 #include "cc/trees/layer_tree_impl.h" | 14 #include "cc/trees/layer_tree_impl.h" |
12 | 15 |
13 namespace cc { | 16 namespace cc { |
14 namespace { | 17 namespace { |
15 | 18 |
16 // These tests deal with picture layers. | 19 // These tests deal with picture layers. |
17 class LayerTreeHostPictureTest : public LayerTreeTest { | 20 class LayerTreeHostPictureTest : public LayerTreeTest { |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 } | 111 } |
109 | 112 |
110 virtual void AfterTest() OVERRIDE {} | 113 virtual void AfterTest() OVERRIDE {} |
111 | 114 |
112 FakeContentLayerClient client_; | 115 FakeContentLayerClient client_; |
113 int activates_; | 116 int activates_; |
114 }; | 117 }; |
115 | 118 |
116 MULTI_THREAD_TEST_F(LayerTreeHostPictureTestTwinLayer); | 119 MULTI_THREAD_TEST_F(LayerTreeHostPictureTestTwinLayer); |
117 | 120 |
| 121 class LayerTreeHostPictureNoUpdateTileProprityForZeroOpacityLayer |
| 122 : public LayerTreeHostPictureTest { |
| 123 protected: |
| 124 virtual void SetupTree() OVERRIDE { |
| 125 parent_layer_ = FakeContentLayer::Create(&parent_client_); |
| 126 parent_layer_->SetBounds(gfx::Size(40, 40)); |
| 127 parent_layer_->SetOpacity(0.f); |
| 128 parent_layer_->SetIsDrawable(true); |
| 129 |
| 130 scoped_refptr<Layer> root = SolidColorLayer::Create(); |
| 131 root->SetBounds(gfx::Size(60, 60)); |
| 132 root->SetOpacity(1.f); |
| 133 root->SetIsDrawable(true); |
| 134 root->AddChild(parent_layer_); |
| 135 layer_tree_host()->SetRootLayer(root); |
| 136 |
| 137 wheel_handler_ = FakeContentLayer::Create(NULL); |
| 138 wheel_handler_->SetBounds(gfx::Size(10, 10)); |
| 139 wheel_handler_->SetHaveWheelEventHandlers(true); |
| 140 wheel_handler_->SetIsDrawable(true); |
| 141 parent_layer_->AddChild(wheel_handler_); |
| 142 |
| 143 picture_ = FakePictureLayer::Create(&picture_client_); |
| 144 picture_->SetBounds(gfx::Size(30, 30)); |
| 145 picture_->SetPosition(gfx::Point(10, 0)); |
| 146 picture_->SetIsDrawable(true); |
| 147 parent_layer_->AddChild(picture_); |
| 148 |
| 149 LayerTreeHostPictureTest::SetupTree(); |
| 150 } |
| 151 |
| 152 virtual void BeginTest() OVERRIDE { |
| 153 PostSetNeedsCommitToMainThread(); |
| 154 } |
| 155 |
| 156 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
| 157 LayerTreeHostPictureTest::DrawLayersOnThread(impl); |
| 158 FakeContentLayerImpl* parent = |
| 159 static_cast<FakeContentLayerImpl*>(impl->RootLayer()->children()[0]); |
| 160 EXPECT_TRUE(parent->DrawsContent()); |
| 161 EXPECT_FALSE(parent->opacity()); |
| 162 EXPECT_EQ(0u, parent->append_quads_count()); |
| 163 ASSERT_EQ(2u, parent->children().size()); |
| 164 |
| 165 FakeContentLayerImpl* child = |
| 166 static_cast<FakeContentLayerImpl*>(parent->children()[0]); |
| 167 EXPECT_TRUE(child->opacity()); |
| 168 EXPECT_EQ(0u, child->append_quads_count()); |
| 169 |
| 170 FakePictureLayerImpl* picimpl = |
| 171 static_cast<FakePictureLayerImpl*>(parent->children()[1]); |
| 172 EXPECT_TRUE(picimpl->opacity()); |
| 173 EXPECT_EQ(0u, picimpl->append_quads_count()); |
| 174 EXPECT_EQ(0u, picimpl->update_tile_priorities_count()); |
| 175 |
| 176 EndTest(); |
| 177 } |
| 178 |
| 179 virtual void AfterTest() OVERRIDE {} |
| 180 |
| 181 private: |
| 182 FakeContentLayerClient parent_client_; |
| 183 FakeContentLayerClient picture_client_; |
| 184 scoped_refptr<FakeContentLayer> parent_layer_; |
| 185 scoped_refptr<FakeContentLayer> wheel_handler_; |
| 186 scoped_refptr<FakePictureLayer> picture_; |
| 187 }; |
| 188 |
| 189 MULTI_THREAD_TEST_F( |
| 190 LayerTreeHostPictureNoUpdateTileProprityForZeroOpacityLayer); |
| 191 |
118 } // namespace | 192 } // namespace |
119 } // namespace cc | 193 } // namespace cc |
OLD | NEW |