Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "cc/layers/picture_image_layer_impl.h" | |
| 6 | |
| 7 #include "cc/test/fake_impl_proxy.h" | |
| 8 #include "cc/test/fake_layer_tree_host_impl.h" | |
| 9 #include "cc/test/fake_output_surface.h" | |
| 10 #include "cc/test/fake_picture_layer_tiling_client.h" | |
| 11 #include "cc/test/impl_side_painting_settings.h" | |
| 12 #include "testing/gtest/include/gtest/gtest.h" | |
| 13 | |
| 14 namespace cc { | |
| 15 namespace { | |
| 16 | |
| 17 class TestablePictureImageLayerImpl : public PictureImageLayerImpl { | |
| 18 public: | |
| 19 TestablePictureImageLayerImpl(LayerTreeImpl* tree_impl, int id) | |
| 20 : PictureImageLayerImpl(tree_impl, id) { | |
| 21 } | |
| 22 friend class PictureImageLayerImplTest; | |
| 23 }; | |
| 24 | |
| 25 class PictureImageLayerImplTest : public testing::Test { | |
| 26 public: | |
| 27 PictureImageLayerImplTest() | |
| 28 : host_impl_(ImplSidePaintingSettings(), &proxy_) { | |
| 29 tiling_client_.SetTileSize(ImplSidePaintingSettings().default_tile_size); | |
| 30 host_impl_.CreatePendingTree(); | |
| 31 host_impl_.InitializeRenderer(CreateFakeOutputSurface()); | |
| 32 } | |
| 33 | |
| 34 scoped_ptr<TestablePictureImageLayerImpl> CreateLayer(int id) { | |
| 35 TestablePictureImageLayerImpl* layer = | |
| 36 new TestablePictureImageLayerImpl(host_impl_.pending_tree(), id); | |
| 37 layer->SetBounds(gfx::Size(100, 200)); | |
| 38 layer->tilings_.reset(new PictureLayerTilingSet(&tiling_client_)); | |
| 39 layer->tilings_->SetLayerBounds(layer->bounds()); | |
| 40 layer->pile_ = tiling_client_.pile(); | |
| 41 return make_scoped_ptr(layer); | |
| 42 } | |
| 43 | |
| 44 private: | |
| 45 FakeImplProxy proxy_; | |
| 46 FakeLayerTreeHostImpl host_impl_; | |
| 47 FakePictureLayerTilingClient tiling_client_; | |
| 48 }; | |
| 49 | |
| 50 TEST_F(PictureImageLayerImplTest, CalcualateContentsScale) { | |
|
enne (OOO)
2013/03/23 00:47:32
Typo.
| |
| 51 scoped_ptr<TestablePictureImageLayerImpl> layer(CreateLayer(1)); | |
| 52 layer->SetDrawsContent(true); | |
| 53 | |
| 54 float contents_scale_x; | |
| 55 float contents_scale_y; | |
| 56 gfx::Size content_bounds; | |
| 57 layer->CalculateContentsScale(2.f, false, | |
| 58 &contents_scale_x, &contents_scale_y, | |
| 59 &content_bounds); | |
| 60 EXPECT_FLOAT_EQ(1.f, contents_scale_x); | |
| 61 EXPECT_FLOAT_EQ(1.f, contents_scale_y); | |
| 62 EXPECT_EQ(layer->bounds(), content_bounds); | |
| 63 } | |
| 64 | |
| 65 TEST_F(PictureImageLayerImplTest, AreVisibleResourcesReady) { | |
| 66 scoped_ptr<TestablePictureImageLayerImpl> layer(CreateLayer(1)); | |
| 67 layer->SetBounds(gfx::Size(100, 200)); | |
| 68 layer->SetDrawsContent(true); | |
| 69 | |
| 70 float contents_scale_x; | |
| 71 float contents_scale_y; | |
| 72 gfx::Size content_bounds; | |
| 73 layer->CalculateContentsScale(2.f, false, | |
| 74 &contents_scale_x, &contents_scale_y, | |
| 75 &content_bounds); | |
| 76 | |
| 77 EXPECT_TRUE(layer->AreVisibleResourcesReady()); | |
| 78 } | |
| 79 | |
| 80 } // namespace | |
| 81 } // namespace cc | |
| OLD | NEW |