Revert "Reland c91b178b07b0d - Delete dead signin code (SigninGlobalError)"
[chromium-blink-merge.git] / cc / layers / delegated_renderer_layer_unittest.cc
blobad4a345fc0fa4c51418323bc0da9a5af6c4217a3
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "cc/layers/delegated_renderer_layer.h"
7 #include "cc/layers/delegated_frame_provider.h"
8 #include "cc/layers/delegated_frame_resource_collection.h"
9 #include "cc/layers/solid_color_layer.h"
10 #include "cc/output/delegated_frame_data.h"
11 #include "cc/test/fake_delegated_renderer_layer.h"
12 #include "cc/test/fake_layer_tree_host.h"
13 #include "cc/test/fake_proxy.h"
14 #include "cc/test/test_task_graph_runner.h"
15 #include "testing/gtest/include/gtest/gtest.h"
17 namespace cc {
18 namespace {
20 class DelegatedRendererLayerTest : public testing::Test {
21 public:
22 DelegatedRendererLayerTest()
23 : proxy_(), host_client_(FakeLayerTreeHostClient::DIRECT_3D) {
24 LayerTreeSettings settings;
25 settings.minimum_occlusion_tracking_size = gfx::Size();
27 host_impl_ =
28 FakeLayerTreeHost::Create(&host_client_, &task_graph_runner_, settings);
29 host_impl_->SetViewportSize(gfx::Size(10, 10));
32 protected:
33 FakeProxy proxy_;
34 FakeLayerTreeHostClient host_client_;
35 TestTaskGraphRunner task_graph_runner_;
36 TestSharedBitmapManager shared_bitmap_manager_;
37 scoped_ptr<LayerTreeHost> host_impl_;
40 class DelegatedRendererLayerTestSimple : public DelegatedRendererLayerTest {
41 public:
42 DelegatedRendererLayerTestSimple() : DelegatedRendererLayerTest() {
43 scoped_ptr<RenderPass> root_pass(RenderPass::Create());
44 root_pass->SetNew(
45 RenderPassId(1, 1), gfx::Rect(1, 1), gfx::Rect(1, 1), gfx::Transform());
46 scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData);
47 frame_data->render_pass_list.push_back(root_pass.Pass());
48 resources_ = new DelegatedFrameResourceCollection;
49 provider_ = new DelegatedFrameProvider(resources_, frame_data.Pass());
50 LayerSettings layer_settings;
51 root_layer_ = SolidColorLayer::Create(layer_settings);
52 layer_before_ = SolidColorLayer::Create(layer_settings);
53 delegated_renderer_layer_ =
54 FakeDelegatedRendererLayer::Create(layer_settings, provider_.get());
57 protected:
58 scoped_refptr<Layer> root_layer_;
59 scoped_refptr<Layer> layer_before_;
60 scoped_refptr<DelegatedRendererLayer> delegated_renderer_layer_;
61 scoped_refptr<DelegatedFrameResourceCollection> resources_;
62 scoped_refptr<DelegatedFrameProvider> provider_;
65 TEST_F(DelegatedRendererLayerTestSimple, DelegatedManyDescendants) {
66 EXPECT_EQ(0, root_layer_->NumDescendantsThatDrawContent());
67 root_layer_->AddChild(layer_before_);
68 EXPECT_EQ(0, root_layer_->NumDescendantsThatDrawContent());
69 layer_before_->SetIsDrawable(true);
70 EXPECT_EQ(1, root_layer_->NumDescendantsThatDrawContent());
71 EXPECT_EQ(0, layer_before_->NumDescendantsThatDrawContent());
72 layer_before_->AddChild(delegated_renderer_layer_);
73 EXPECT_EQ(0, layer_before_->NumDescendantsThatDrawContent());
74 EXPECT_EQ(0, delegated_renderer_layer_->NumDescendantsThatDrawContent());
75 EXPECT_EQ(1, root_layer_->NumDescendantsThatDrawContent());
76 delegated_renderer_layer_->SetIsDrawable(true);
77 EXPECT_EQ(1000, delegated_renderer_layer_->NumDescendantsThatDrawContent());
78 EXPECT_EQ(1001, layer_before_->NumDescendantsThatDrawContent());
79 EXPECT_EQ(1002, root_layer_->NumDescendantsThatDrawContent());
82 } // namespace
83 } // namespace cc