OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/picture_image_layer_impl.h" | 5 #include "cc/layers/picture_image_layer_impl.h" |
6 | 6 |
7 #include "cc/test/fake_impl_proxy.h" | 7 #include "cc/test/fake_impl_proxy.h" |
8 #include "cc/test/fake_layer_tree_host_impl.h" | 8 #include "cc/test/fake_layer_tree_host_impl.h" |
9 #include "cc/test/fake_output_surface.h" | 9 #include "cc/test/fake_output_surface.h" |
10 #include "cc/test/fake_picture_layer_tiling_client.h" | 10 #include "cc/test/fake_picture_layer_tiling_client.h" |
11 #include "cc/test/impl_side_painting_settings.h" | 11 #include "cc/test/impl_side_painting_settings.h" |
| 12 #include "cc/trees/layer_tree_impl.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
13 | 14 |
14 namespace cc { | 15 namespace cc { |
15 namespace { | 16 namespace { |
16 | 17 |
17 class TestablePictureImageLayerImpl : public PictureImageLayerImpl { | 18 class TestablePictureImageLayerImpl : public PictureImageLayerImpl { |
18 public: | 19 public: |
19 TestablePictureImageLayerImpl(LayerTreeImpl* tree_impl, int id) | 20 TestablePictureImageLayerImpl(LayerTreeImpl* tree_impl, int id) |
20 : PictureImageLayerImpl(tree_impl, id) { | 21 : PictureImageLayerImpl(tree_impl, id) { |
21 } | 22 } |
(...skipping 12 matching lines...) Expand all Loading... |
34 scoped_ptr<TestablePictureImageLayerImpl> CreateLayer(int id) { | 35 scoped_ptr<TestablePictureImageLayerImpl> CreateLayer(int id) { |
35 TestablePictureImageLayerImpl* layer = | 36 TestablePictureImageLayerImpl* layer = |
36 new TestablePictureImageLayerImpl(host_impl_.pending_tree(), id); | 37 new TestablePictureImageLayerImpl(host_impl_.pending_tree(), id); |
37 layer->SetBounds(gfx::Size(100, 200)); | 38 layer->SetBounds(gfx::Size(100, 200)); |
38 layer->tilings_.reset(new PictureLayerTilingSet(&tiling_client_, | 39 layer->tilings_.reset(new PictureLayerTilingSet(&tiling_client_, |
39 layer->bounds())); | 40 layer->bounds())); |
40 layer->pile_ = tiling_client_.pile(); | 41 layer->pile_ = tiling_client_.pile(); |
41 return make_scoped_ptr(layer); | 42 return make_scoped_ptr(layer); |
42 } | 43 } |
43 | 44 |
| 45 void UpdateDrawProperties() { |
| 46 host_impl_.pending_tree()->UpdateDrawProperties(); |
| 47 } |
| 48 |
44 private: | 49 private: |
45 FakeImplProxy proxy_; | 50 FakeImplProxy proxy_; |
46 FakeLayerTreeHostImpl host_impl_; | 51 FakeLayerTreeHostImpl host_impl_; |
47 FakePictureLayerTilingClient tiling_client_; | 52 FakePictureLayerTilingClient tiling_client_; |
48 }; | 53 }; |
49 | 54 |
50 TEST_F(PictureImageLayerImplTest, CalculateContentsScale) { | 55 TEST_F(PictureImageLayerImplTest, CalculateContentsScale) { |
51 scoped_ptr<TestablePictureImageLayerImpl> layer(CreateLayer(1)); | 56 scoped_ptr<TestablePictureImageLayerImpl> layer(CreateLayer(1)); |
52 layer->SetDrawsContent(true); | 57 layer->SetDrawsContent(true); |
53 | 58 |
54 float contents_scale_x; | 59 float contents_scale_x; |
55 float contents_scale_y; | 60 float contents_scale_y; |
56 gfx::Size content_bounds; | 61 gfx::Size content_bounds; |
57 layer->CalculateContentsScale(2.f, false, | 62 layer->CalculateContentsScale(2.f, false, |
58 &contents_scale_x, &contents_scale_y, | 63 &contents_scale_x, &contents_scale_y, |
59 &content_bounds); | 64 &content_bounds); |
60 EXPECT_FLOAT_EQ(1.f, contents_scale_x); | 65 EXPECT_FLOAT_EQ(1.f, contents_scale_x); |
61 EXPECT_FLOAT_EQ(1.f, contents_scale_y); | 66 EXPECT_FLOAT_EQ(1.f, contents_scale_y); |
62 EXPECT_EQ(layer->bounds(), content_bounds); | 67 EXPECT_EQ(layer->bounds(), content_bounds); |
63 } | 68 } |
64 | 69 |
65 TEST_F(PictureImageLayerImplTest, AreVisibleResourcesReady) { | 70 TEST_F(PictureImageLayerImplTest, AreVisibleResourcesReady) { |
66 scoped_ptr<TestablePictureImageLayerImpl> layer(CreateLayer(1)); | 71 scoped_ptr<TestablePictureImageLayerImpl> layer(CreateLayer(1)); |
67 layer->SetBounds(gfx::Size(100, 200)); | 72 layer->SetBounds(gfx::Size(100, 200)); |
68 layer->SetDrawsContent(true); | 73 layer->SetDrawsContent(true); |
69 | 74 |
| 75 UpdateDrawProperties(); |
| 76 |
70 float contents_scale_x; | 77 float contents_scale_x; |
71 float contents_scale_y; | 78 float contents_scale_y; |
72 gfx::Size content_bounds; | 79 gfx::Size content_bounds; |
73 layer->CalculateContentsScale(2.f, false, | 80 layer->CalculateContentsScale(2.f, false, |
74 &contents_scale_x, &contents_scale_y, | 81 &contents_scale_x, &contents_scale_y, |
75 &content_bounds); | 82 &content_bounds); |
| 83 layer->UpdateTilePriorities(); |
76 | 84 |
77 EXPECT_TRUE(layer->AreVisibleResourcesReady()); | 85 EXPECT_TRUE(layer->AreVisibleResourcesReady()); |
78 } | 86 } |
79 | 87 |
80 } // namespace | 88 } // namespace |
81 } // namespace cc | 89 } // namespace cc |
OLD | NEW |