Use multiline attribute to check for IA2_STATE_MULTILINE.
[chromium-blink-merge.git] / cc / layers / delegated_renderer_layer_unittest.cc
blobf243d73c260927298c79d506910b5b6431876914
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 "testing/gtest/include/gtest/gtest.h"
16 namespace cc {
17 namespace {
19 class DelegatedRendererLayerTest : public testing::Test {
20 public:
21 DelegatedRendererLayerTest()
22 : proxy_(), host_client_(FakeLayerTreeHostClient::DIRECT_3D) {
23 LayerTreeSettings settings;
24 settings.minimum_occlusion_tracking_size = gfx::Size();
26 host_impl_ = FakeLayerTreeHost::Create(&host_client_, settings);
27 host_impl_->SetViewportSize(gfx::Size(10, 10));
30 protected:
31 FakeProxy proxy_;
32 FakeLayerTreeHostClient host_client_;
33 TestSharedBitmapManager shared_bitmap_manager_;
34 scoped_ptr<LayerTreeHost> host_impl_;
37 class DelegatedRendererLayerTestSimple : public DelegatedRendererLayerTest {
38 public:
39 DelegatedRendererLayerTestSimple() : DelegatedRendererLayerTest() {
40 scoped_ptr<RenderPass> root_pass(RenderPass::Create());
41 root_pass->SetNew(
42 RenderPassId(1, 1), gfx::Rect(1, 1), gfx::Rect(1, 1), gfx::Transform());
43 scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData);
44 frame_data->render_pass_list.push_back(root_pass.Pass());
45 resources_ = new DelegatedFrameResourceCollection;
46 provider_ = new DelegatedFrameProvider(resources_, frame_data.Pass());
47 root_layer_ = SolidColorLayer::Create();
48 layer_before_ = SolidColorLayer::Create();
49 delegated_renderer_layer_ =
50 FakeDelegatedRendererLayer::Create(provider_.get());
53 protected:
54 scoped_refptr<Layer> root_layer_;
55 scoped_refptr<Layer> layer_before_;
56 scoped_refptr<DelegatedRendererLayer> delegated_renderer_layer_;
57 scoped_refptr<DelegatedFrameResourceCollection> resources_;
58 scoped_refptr<DelegatedFrameProvider> provider_;
61 TEST_F(DelegatedRendererLayerTestSimple, DelegatedManyDescendants) {
62 EXPECT_EQ(0, root_layer_->NumDescendantsThatDrawContent());
63 root_layer_->AddChild(layer_before_);
64 EXPECT_EQ(0, root_layer_->NumDescendantsThatDrawContent());
65 layer_before_->SetIsDrawable(true);
66 EXPECT_EQ(1, root_layer_->NumDescendantsThatDrawContent());
67 EXPECT_EQ(0, layer_before_->NumDescendantsThatDrawContent());
68 layer_before_->AddChild(delegated_renderer_layer_);
69 EXPECT_EQ(0, layer_before_->NumDescendantsThatDrawContent());
70 EXPECT_EQ(0, delegated_renderer_layer_->NumDescendantsThatDrawContent());
71 EXPECT_EQ(1, root_layer_->NumDescendantsThatDrawContent());
72 delegated_renderer_layer_->SetIsDrawable(true);
73 EXPECT_EQ(1000, delegated_renderer_layer_->NumDescendantsThatDrawContent());
74 EXPECT_EQ(1001, layer_before_->NumDescendantsThatDrawContent());
75 EXPECT_EQ(1002, root_layer_->NumDescendantsThatDrawContent());
78 } // namespace
79 } // namespace cc