Fix flaky PDFExtensionTest
[chromium-blink-merge.git] / cc / layers / delegated_renderer_layer_unittest.cc
blob96b62afeac1a248c9f483438e0908aea2e9bc3c1
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 LayerSettings layer_settings;
48 root_layer_ = SolidColorLayer::Create(layer_settings);
49 layer_before_ = SolidColorLayer::Create(layer_settings);
50 delegated_renderer_layer_ =
51 FakeDelegatedRendererLayer::Create(layer_settings, provider_.get());
54 protected:
55 scoped_refptr<Layer> root_layer_;
56 scoped_refptr<Layer> layer_before_;
57 scoped_refptr<DelegatedRendererLayer> delegated_renderer_layer_;
58 scoped_refptr<DelegatedFrameResourceCollection> resources_;
59 scoped_refptr<DelegatedFrameProvider> provider_;
62 TEST_F(DelegatedRendererLayerTestSimple, DelegatedManyDescendants) {
63 EXPECT_EQ(0, root_layer_->NumDescendantsThatDrawContent());
64 root_layer_->AddChild(layer_before_);
65 EXPECT_EQ(0, root_layer_->NumDescendantsThatDrawContent());
66 layer_before_->SetIsDrawable(true);
67 EXPECT_EQ(1, root_layer_->NumDescendantsThatDrawContent());
68 EXPECT_EQ(0, layer_before_->NumDescendantsThatDrawContent());
69 layer_before_->AddChild(delegated_renderer_layer_);
70 EXPECT_EQ(0, layer_before_->NumDescendantsThatDrawContent());
71 EXPECT_EQ(0, delegated_renderer_layer_->NumDescendantsThatDrawContent());
72 EXPECT_EQ(1, root_layer_->NumDescendantsThatDrawContent());
73 delegated_renderer_layer_->SetIsDrawable(true);
74 EXPECT_EQ(1000, delegated_renderer_layer_->NumDescendantsThatDrawContent());
75 EXPECT_EQ(1001, layer_before_->NumDescendantsThatDrawContent());
76 EXPECT_EQ(1002, root_layer_->NumDescendantsThatDrawContent());
79 } // namespace
80 } // namespace cc