OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/layers/contents_scaling_layer.h" | 5 #include "cc/layers/contents_scaling_layer.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "cc/test/fake_layer_tree_host.h" | 9 #include "cc/test/fake_layer_tree_host.h" |
10 #include "cc/test/geometry_test_utils.h" | 10 #include "cc/test/geometry_test_utils.h" |
| 11 #include "cc/test/test_task_graph_runner.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
12 | 13 |
13 namespace cc { | 14 namespace cc { |
14 namespace { | 15 namespace { |
15 | 16 |
16 class MockContentsScalingLayer : public ContentsScalingLayer { | 17 class MockContentsScalingLayer : public ContentsScalingLayer { |
17 public: | 18 public: |
18 explicit MockContentsScalingLayer(const LayerSettings& settings) | 19 explicit MockContentsScalingLayer(const LayerSettings& settings) |
19 : ContentsScalingLayer(settings) {} | 20 : ContentsScalingLayer(settings) {} |
20 | 21 |
(...skipping 17 matching lines...) Expand all Loading... |
38 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( | 39 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( |
39 host->root_layer(), gfx::Size(500, 500), &render_surface_layer_list); | 40 host->root_layer(), gfx::Size(500, 500), &render_surface_layer_list); |
40 inputs.device_scale_factor = device_scale_factor; | 41 inputs.device_scale_factor = device_scale_factor; |
41 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 42 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
42 } | 43 } |
43 | 44 |
44 TEST(ContentsScalingLayerTest, CheckContentsBounds) { | 45 TEST(ContentsScalingLayerTest, CheckContentsBounds) { |
45 LayerSettings layer_settings; | 46 LayerSettings layer_settings; |
46 | 47 |
47 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); | 48 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); |
48 scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(&client); | 49 TestTaskGraphRunner task_graph_runner; |
| 50 scoped_ptr<FakeLayerTreeHost> host = |
| 51 FakeLayerTreeHost::Create(&client, &task_graph_runner); |
49 | 52 |
50 scoped_refptr<MockContentsScalingLayer> test_layer = | 53 scoped_refptr<MockContentsScalingLayer> test_layer = |
51 make_scoped_refptr(new MockContentsScalingLayer(layer_settings)); | 54 make_scoped_refptr(new MockContentsScalingLayer(layer_settings)); |
52 | 55 |
53 scoped_refptr<Layer> root = Layer::Create(layer_settings); | 56 scoped_refptr<Layer> root = Layer::Create(layer_settings); |
54 root->AddChild(test_layer); | 57 root->AddChild(test_layer); |
55 host->SetRootLayer(root); | 58 host->SetRootLayer(root); |
56 | 59 |
57 test_layer->SetBounds(gfx::Size(320, 240)); | 60 test_layer->SetBounds(gfx::Size(320, 240)); |
58 | 61 |
(...skipping 12 matching lines...) Expand all Loading... |
71 EXPECT_EQ(20, test_layer->content_bounds().width()); | 74 EXPECT_EQ(20, test_layer->content_bounds().width()); |
72 EXPECT_EQ(40, test_layer->content_bounds().height()); | 75 EXPECT_EQ(40, test_layer->content_bounds().height()); |
73 | 76 |
74 CalcDrawProps(host.get(), 1.33f); | 77 CalcDrawProps(host.get(), 1.33f); |
75 EXPECT_EQ(14, test_layer->content_bounds().width()); | 78 EXPECT_EQ(14, test_layer->content_bounds().width()); |
76 EXPECT_EQ(27, test_layer->content_bounds().height()); | 79 EXPECT_EQ(27, test_layer->content_bounds().height()); |
77 } | 80 } |
78 | 81 |
79 } // namespace | 82 } // namespace |
80 } // namespace cc | 83 } // namespace cc |
OLD | NEW |