Index: cc/layers/delegated_renderer_layer_unittest.cc |
diff --git a/cc/layers/delegated_renderer_layer_unittest.cc b/cc/layers/delegated_renderer_layer_unittest.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..41742012d7eb95040e7895498ca52f4caeeabf73 |
--- /dev/null |
+++ b/cc/layers/delegated_renderer_layer_unittest.cc |
@@ -0,0 +1,84 @@ |
+// Copyright 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "cc/layers/delegated_renderer_layer.h" |
+ |
+#include "cc/layers/delegated_frame_provider.h" |
+#include "cc/layers/delegated_frame_resource_collection.h" |
+#include "cc/layers/solid_color_layer.h" |
+#include "cc/output/delegated_frame_data.h" |
+#include "cc/test/fake_delegated_renderer_layer.h" |
+#include "cc/test/fake_layer_tree_host.h" |
+#include "cc/test/fake_proxy.h" |
+#include "testing/gtest/include/gtest/gtest.h" |
+ |
+namespace cc { |
+namespace { |
+ |
+class DelegatedRendererLayerTest : public testing::Test { |
+ public: |
+ DelegatedRendererLayerTest() |
+ : proxy_(), always_impl_thread_and_main_thread_blocked_(&proxy_) { |
+ LayerTreeSettings settings; |
+ settings.minimum_occlusion_tracking_size = gfx::Size(); |
+ |
+ host_impl_ = FakeLayerTreeHost::Create(settings); |
+ host_impl_->SetViewportSize(gfx::Size(10, 10)); |
+ } |
+ |
+ protected: |
+ FakeProxy proxy_; |
+ DebugScopedSetImplThreadAndMainThreadBlocked |
+ always_impl_thread_and_main_thread_blocked_; |
danakj
2014/07/17 17:21:25
do you need this?
awoloszyn
2014/07/17 20:44:59
Done.
|
+ TestSharedBitmapManager shared_bitmap_manager_; |
+ scoped_ptr<LayerTreeHost> host_impl_; |
+}; |
+ |
+class DelegatedRendererLayerTestSimple : public DelegatedRendererLayerTest { |
+ public: |
+ DelegatedRendererLayerTestSimple() : DelegatedRendererLayerTest() { |
+ scoped_ptr<RenderPass> root_pass(RenderPass::Create()); |
+ root_pass->SetNew(RenderPass::Id(1, 1), |
+ gfx::Rect(1, 1), |
+ gfx::Rect(1, 1), |
+ gfx::Transform()); |
+ scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); |
+ frame_data->render_pass_list.push_back(root_pass.Pass()); |
+ resources_ = new DelegatedFrameResourceCollection; |
+ provider_ = new DelegatedFrameProvider(resources_, frame_data.Pass()); |
+ root_layer_ = SolidColorLayer::Create(); |
+ layer_before_ = SolidColorLayer::Create(); |
+ layer_after_ = SolidColorLayer::Create(); |
+ delegated_renderer_layer_ = FakeDelegatedRendererLayer::Create(provider_); |
+ } |
+ |
+ protected: |
+ scoped_refptr<Layer> root_layer_; |
+ scoped_refptr<Layer> layer_before_; |
+ scoped_refptr<Layer> layer_after_; |
danakj
2014/07/17 17:21:25
don't see you using this
awoloszyn
2014/07/17 20:44:59
Done.
|
+ scoped_refptr<DelegatedRendererLayer> delegated_renderer_layer_; |
+ |
+ scoped_refptr<DelegatedFrameResourceCollection> resources_; |
+ scoped_refptr<DelegatedFrameProvider> provider_; |
+}; |
+ |
+TEST_F(DelegatedRendererLayerTestSimple, DelegatedManyDescendants) { |
+ EXPECT_EQ(0, root_layer_->NumDescendantsThatDrawContent()); |
+ root_layer_->AddChild(layer_before_); |
+ EXPECT_EQ(0, root_layer_->NumDescendantsThatDrawContent()); |
+ layer_before_->SetIsDrawable(true); |
+ EXPECT_EQ(1, root_layer_->NumDescendantsThatDrawContent()); |
+ EXPECT_EQ(0, layer_before_->NumDescendantsThatDrawContent()); |
+ layer_before_->AddChild(delegated_renderer_layer_); |
+ EXPECT_EQ(1000, layer_before_->NumDescendantsThatDrawContent()); |
+ EXPECT_EQ(1000, delegated_renderer_layer_->NumDescendantsThatDrawContent()); |
danakj
2014/07/17 17:21:25
if the DRL isn't going to draw, this should be 0
awoloszyn
2014/07/17 20:44:59
This behavior has been changed, and DRLs won't con
|
+ EXPECT_EQ(1001, root_layer_->NumDescendantsThatDrawContent()); |
+ delegated_renderer_layer_->SetIsDrawable(true); |
+ EXPECT_EQ(1000, delegated_renderer_layer_->NumDescendantsThatDrawContent()); |
+ EXPECT_EQ(1001, layer_before_->NumDescendantsThatDrawContent()); |
+ EXPECT_EQ(1002, root_layer_->NumDescendantsThatDrawContent()); |
+} |
+ |
+} // namespace |
+} // namespace cc |