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 a8caf48904b835f7e1c8905379fbedcfe6b1fb85..0c8589d8633137c4b7dcd0b1660fc9636c851588 100644 |
| --- a/cc/resources/picture_layer_tiling_unittest.cc |
| +++ b/cc/resources/picture_layer_tiling_unittest.cc |
| @@ -53,6 +53,7 @@ static void UpdateAllTilePriorities(PictureLayerTilingSet* set, |
| class TestablePictureLayerTiling : public PictureLayerTiling { |
| public: |
| using PictureLayerTiling::SetLiveTilesRect; |
| + using PictureLayerTiling::UpdateTilesToCurrentPile; |
| using PictureLayerTiling::TileAt; |
| static scoped_ptr<TestablePictureLayerTiling> Create( |
| @@ -210,6 +211,102 @@ TEST_F(PictureLayerTilingIteratorTest, ResizeDeletesTiles) { |
| EXPECT_FALSE(tiling_->TileAt(0, 0)); |
| } |
| +TEST_F(PictureLayerTilingIteratorTest, ResizeLiveTileRectOverTileBorders) { |
| + // The tiling has three rows and columns. |
| + Initialize(gfx::Size(100, 100), 1, gfx::Size(250, 250)); |
| + EXPECT_EQ(3, tiling_->TilingDataForTesting().num_tiles_x()); |
| + EXPECT_EQ(3, tiling_->TilingDataForTesting().num_tiles_y()); |
| + |
| + // The live tiles rect covers the whole tiling. |
| + SetLiveRectAndVerifyTiles(gfx::Rect(250, 250)); |
| + |
| + // Tiles in the right row and column exist. |
| + EXPECT_TRUE(tiling_->TileAt(2, 0)); |
| + EXPECT_TRUE(tiling_->TileAt(2, 1)); |
| + EXPECT_TRUE(tiling_->TileAt(2, 2)); |
| + EXPECT_TRUE(tiling_->TileAt(1, 2)); |
| + EXPECT_TRUE(tiling_->TileAt(0, 2)); |
| + |
| + // Shrink the live tiles rect to the very edge of the right-most and |
| + // bottom-most tiles. Their border pixels would still be inside the live |
| + // tiles rect, but the tiles should not exist just for that. |
| + int right = tiling_->TilingDataForTesting().TileBounds(2, 2).x(); |
| + int bottom = tiling_->TilingDataForTesting().TileBounds(2, 2).y(); |
| + |
| + SetLiveRectAndVerifyTiles(gfx::Rect(right, bottom)); |
| + EXPECT_FALSE(tiling_->TileAt(2, 0)); |
| + EXPECT_FALSE(tiling_->TileAt(2, 1)); |
| + EXPECT_FALSE(tiling_->TileAt(2, 2)); |
| + EXPECT_FALSE(tiling_->TileAt(1, 2)); |
| + EXPECT_FALSE(tiling_->TileAt(0, 2)); |
| + |
| + // Including the bottom row and right column again, should create the tiles. |
| + SetLiveRectAndVerifyTiles(gfx::Rect(right + 1, bottom + 1)); |
|
danakj
2014/08/26 19:00:11
This is the test from https://codereview.chromium.
vmpstr
2014/08/26 19:02:15
Ah ok. No this is fine, it's just I couldn't repro
danakj
2014/08/26 19:28:34
Oh, I lied slightly. It doesn't crash in here. But
|
| + |
| + EXPECT_TRUE(tiling_->TileAt(2, 0)); |
| + EXPECT_TRUE(tiling_->TileAt(2, 1)); |
| + EXPECT_TRUE(tiling_->TileAt(2, 2)); |
| + EXPECT_TRUE(tiling_->TileAt(1, 2)); |
| + EXPECT_TRUE(tiling_->TileAt(0, 2)); |
| + |
| + // Shrink the live tiles rect to the very edge of the left-most and |
| + // top-most tiles. Their border pixels would still be inside the live |
| + // tiles rect, but the tiles should not exist just for that. |
| + int left = tiling_->TilingDataForTesting().TileBounds(0, 0).right(); |
| + int top = tiling_->TilingDataForTesting().TileBounds(0, 0).bottom(); |
| + |
| + SetLiveRectAndVerifyTiles(gfx::Rect(left, top, 250 - left, 250 - top)); |
| + EXPECT_FALSE(tiling_->TileAt(0, 2)); |
| + EXPECT_FALSE(tiling_->TileAt(0, 1)); |
| + EXPECT_FALSE(tiling_->TileAt(0, 0)); |
| + EXPECT_FALSE(tiling_->TileAt(1, 0)); |
| + EXPECT_FALSE(tiling_->TileAt(2, 0)); |
| + |
| + // Including the top row and left column again, should create the tiles. |
| + SetLiveRectAndVerifyTiles( |
| + gfx::Rect(left - 1, top - 1, 250 - left, 250 - top)); |
| + |
| + EXPECT_TRUE(tiling_->TileAt(0, 2)); |
| + EXPECT_TRUE(tiling_->TileAt(0, 1)); |
| + EXPECT_TRUE(tiling_->TileAt(0, 0)); |
| + EXPECT_TRUE(tiling_->TileAt(1, 0)); |
| + EXPECT_TRUE(tiling_->TileAt(2, 0)); |
| +} |
| + |
| +TEST_F(PictureLayerTilingIteratorTest, ResizeLiveTileRectOverSameTiles) { |
| + // The tiling has three rows and columns. |
| + Initialize(gfx::Size(100, 100), 1, gfx::Size(250, 250)); |
| + EXPECT_EQ(3, tiling_->TilingDataForTesting().num_tiles_x()); |
| + EXPECT_EQ(3, tiling_->TilingDataForTesting().num_tiles_y()); |
| + |
| + // The live tiles rect covers the whole tiling. |
| + SetLiveRectAndVerifyTiles(gfx::Rect(250, 250)); |
| + |
| + // All tiles exist. |
| + for (int i = 0; i < 3; ++i) { |
| + for (int j = 0; j < 3; ++j) |
| + EXPECT_TRUE(tiling_->TileAt(i, j)) << i << "," << j; |
| + } |
| + |
| + // Shrink the live tiles rect, but still cover all the tiles. |
| + SetLiveRectAndVerifyTiles(gfx::Rect(1, 1, 249, 249)); |
| + |
| + // All tiles still exist. |
| + for (int i = 0; i < 3; ++i) { |
| + for (int j = 0; j < 3; ++j) |
| + EXPECT_TRUE(tiling_->TileAt(i, j)) << i << "," << j; |
| + } |
| + |
| + // Grow the live tiles rect, but still cover all the same tiles. |
| + SetLiveRectAndVerifyTiles(gfx::Rect(0, 0, 250, 250)); |
| + |
| + // All tiles still exist. |
| + for (int i = 0; i < 3; ++i) { |
| + for (int j = 0; j < 3; ++j) |
| + EXPECT_TRUE(tiling_->TileAt(i, j)) << i << "," << j; |
| + } |
| +} |
| + |
| TEST_F(PictureLayerTilingIteratorTest, ResizeOverBorderPixelsDeletesTiles) { |
| // Verifies that a resize with invalidation for newly exposed pixels will |
| // deletes tiles that intersect that invalidation. |