Chromium Code Reviews| Index: cc/resources/picture_layer_tiling_unittest.cc |
| diff --git a/cc/resources/picture_layer_tiling_unittest.cc b/cc/resources/picture_layer_tiling_unittest.cc |
| index 5e29b826275064786933a743a10812754c712c7c..d96ee036a5c0b4d2611736c83164966ba47b53fa 100644 |
| --- a/cc/resources/picture_layer_tiling_unittest.cc |
| +++ b/cc/resources/picture_layer_tiling_unittest.cc |
| @@ -12,6 +12,27 @@ |
| namespace cc { |
| namespace { |
| +class TestablePictureLayerTiling : public PictureLayerTiling { |
| + public: |
| + using PictureLayerTiling::SetLiveTilesRect; |
| + |
| + static scoped_ptr<TestablePictureLayerTiling> Create( |
| + float contents_scale, |
| + gfx::Size layer_bounds, |
| + PictureLayerTilingClient* client) { |
| + return make_scoped_ptr(new TestablePictureLayerTiling( |
| + contents_scale, |
| + layer_bounds, |
| + client)); |
| + } |
| + |
| + protected: |
| + TestablePictureLayerTiling(float contents_scale, |
| + gfx::Size layer_bounds, |
| + PictureLayerTilingClient* client) |
| + : PictureLayerTiling(contents_scale, layer_bounds, client) { } |
| +}; |
| + |
| class PictureLayerTilingIteratorTest : public testing::Test { |
| public: |
| PictureLayerTilingIteratorTest() {} |
| @@ -21,9 +42,22 @@ class PictureLayerTilingIteratorTest : public testing::Test { |
| float contents_scale, |
| gfx::Size layer_bounds) { |
| client_.SetTileSize(tile_size); |
| - tiling_ = PictureLayerTiling::Create(contents_scale); |
| - tiling_->SetClient(&client_); |
| - tiling_->SetLayerBounds(layer_bounds); |
| + tiling_ = TestablePictureLayerTiling::Create(contents_scale, |
| + layer_bounds, |
| + &client_); |
| + tiling_->CreateAllTilesForTesting(); |
| + } |
| + |
| + void SetLiveRectAndVerifyTiles(gfx::Rect live_tiles_rect) { |
| + tiling_->SetLiveTilesRect(live_tiles_rect); // max tiles in tile manager |
|
enne (OOO)
2013/04/11 00:16:02
I don't think this comment is true, and could just
|
| + |
| + std::vector<Tile*> tiles = tiling_->AllTilesForTesting(); |
| + for (std::vector<Tile*>::iterator iter = tiles.begin(); |
| + iter != tiles.end(); |
|
enne (OOO)
2013/04/11 00:16:02
style nit: don't indent 5 spaces after a for loop
|
| + ++iter) { |
| + EXPECT_EQ(*iter != NULL, |
|
enne (OOO)
2013/04/11 00:16:02
Now that the loop has changed, this is a little bi
|
| + live_tiles_rect.Intersects((*iter)->content_rect())); |
| + } |
| } |
| void VerifyTilesExactlyCoverRect( |
| @@ -92,11 +126,21 @@ class PictureLayerTilingIteratorTest : public testing::Test { |
| protected: |
| FakePictureLayerTilingClient client_; |
| - scoped_ptr<PictureLayerTiling> tiling_; |
| + scoped_ptr<TestablePictureLayerTiling> tiling_; |
| DISALLOW_COPY_AND_ASSIGN(PictureLayerTilingIteratorTest); |
| }; |
| +TEST_F(PictureLayerTilingIteratorTest, LiveTilesExactlyCoverLiveTileRect) { |
| + Initialize(gfx::Size(100, 100), 1, gfx::Size(1099, 801)); |
| + SetLiveRectAndVerifyTiles(gfx::Rect(100, 100)); |
| + SetLiveRectAndVerifyTiles(gfx::Rect(101, 99)); |
| + SetLiveRectAndVerifyTiles(gfx::Rect(1099, 1)); |
| + SetLiveRectAndVerifyTiles(gfx::Rect(1, 801)); |
| + SetLiveRectAndVerifyTiles(gfx::Rect(1099, 1)); |
| + SetLiveRectAndVerifyTiles(gfx::Rect(201, 800)); |
| +} |
| + |
| TEST_F(PictureLayerTilingIteratorTest, IteratorCoversLayerBoundsNoScale) { |
| Initialize(gfx::Size(100, 100), 1, gfx::Size(1099, 801)); |
| VerifyTilesExactlyCoverRect(1, gfx::Rect()); |
| @@ -448,7 +492,7 @@ TEST_F(PictureLayerTilingIteratorTest, TilesExist) { |
| 2.0, // current frame time |
| false, // store screen space quads on tiles |
| 10000); // max tiles in tile manager |
| - VerifyTiles(1.f, gfx::Rect(layer_bounds), base::Bind(&TileExists, false)); |
| + VerifyTiles(1.f, gfx::Rect(), base::Bind(&TileExists, false)); |
| } |
| } // namespace |