Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1156)

Unified Diff: cc/resources/picture_layer_tiling_unittest.cc

Issue 12865017: Makes tile-creation lazy (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressing last round of feedback Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/resources/picture_layer_tiling_set_unittest.cc ('k') | cc/resources/picture_pile_base.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..70109bddd7bb04820bdd0769ad63b9e92a7fe743 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,21 @@ 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);
+
+ std::vector<Tile*> tiles = tiling_->AllTilesForTesting();
+ for (std::vector<Tile*>::iterator iter = tiles.begin();
+ iter != tiles.end();
+ ++iter) {
+ EXPECT_TRUE(live_tiles_rect.Intersects((*iter)->content_rect()));
+ }
}
void VerifyTilesExactlyCoverRect(
@@ -92,11 +125,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 +491,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
« no previous file with comments | « cc/resources/picture_layer_tiling_set_unittest.cc ('k') | cc/resources/picture_pile_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698