// Copyright 2014 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_() { LayerTreeSettings settings; settings.minimum_occlusion_tracking_size = gfx::Size(); host_impl_ = FakeLayerTreeHost::Create(settings); host_impl_->SetViewportSize(gfx::Size(10, 10)); } protected: FakeProxy proxy_; TestSharedBitmapManager shared_bitmap_manager_; scoped_ptr host_impl_; }; class DelegatedRendererLayerTestSimple : public DelegatedRendererLayerTest { public: DelegatedRendererLayerTestSimple() : DelegatedRendererLayerTest() { scoped_ptr root_pass(RenderPass::Create()); root_pass->SetNew( RenderPassId(1, 1), gfx::Rect(1, 1), gfx::Rect(1, 1), gfx::Transform()); scoped_ptr 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(); delegated_renderer_layer_ = FakeDelegatedRendererLayer::Create(provider_.get()); } protected: scoped_refptr root_layer_; scoped_refptr layer_before_; scoped_refptr delegated_renderer_layer_; scoped_refptr resources_; scoped_refptr 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(0, layer_before_->NumDescendantsThatDrawContent()); EXPECT_EQ(0, delegated_renderer_layer_->NumDescendantsThatDrawContent()); EXPECT_EQ(1, 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