| Index: cc/resources/picture_pile_unittest.cc
|
| diff --git a/cc/resources/picture_pile_unittest.cc b/cc/resources/picture_pile_unittest.cc
|
| index 31e0a2a32f638eeb77b907142139dacbeb36f6eb..39a32376aebbf364dfcc8aa59db9e2fcd9e0a581 100644
|
| --- a/cc/resources/picture_pile_unittest.cc
|
| +++ b/cc/resources/picture_pile_unittest.cc
|
| @@ -39,13 +39,16 @@ class TestPicturePile : public PicturePile {
|
| class PicturePileTest : public testing::Test {
|
| public:
|
| PicturePileTest()
|
| - : pile_(new TestPicturePile()),
|
| - background_color_(SK_ColorBLUE),
|
| + : background_color_(SK_ColorBLUE),
|
| min_scale_(0.125),
|
| frame_number_(0),
|
| - contents_opaque_(false) {
|
| + contents_opaque_(false) {}
|
| +
|
| + virtual void SetUp() OVERRIDE {
|
| + pile_ = make_scoped_refptr(new TestPicturePile());
|
| pile_->SetTileGridSize(gfx::Size(1000, 1000));
|
| pile_->SetMinContentsScale(min_scale_);
|
| + client_ = FakeContentLayerClient();
|
| SetTilingSize(pile_->tiling().max_texture_size());
|
| }
|
|
|
| @@ -1003,5 +1006,51 @@ TEST_F(PicturePileTest, SmallResizePileInsideInterestRect) {
|
| invalidation.Clear();
|
| }
|
|
|
| +TEST_F(PicturePileTest, SolidRectangleIsSolid) {
|
| + // If the client has no contents, the solid state will be true
|
| + Region invalidation1(tiling_rect());
|
| + UpdateAndExpandInvalidation(&invalidation1, tiling_size(), tiling_rect());
|
| + EXPECT_TRUE(pile_->IsSolidColor());
|
| + EXPECT_EQ(SK_ColorTRANSPARENT, pile_->GetSolidColor());
|
| +
|
| + // If there is a single rect that covers the view, the solid
|
| + // state will be true
|
| + SkPaint paint;
|
| + paint.setColor(SK_ColorCYAN);
|
| + client_.add_draw_rect(tiling_rect(), paint);
|
| + Region invalidation2(tiling_rect());
|
| + UpdateAndExpandInvalidation(&invalidation2, tiling_size(), tiling_rect());
|
| + EXPECT_TRUE(pile_->IsSolidColor());
|
| + EXPECT_EQ(SK_ColorCYAN, pile_->GetSolidColor());
|
| +
|
| + // if a second smaller rect is draw that doesn't cover the viewport
|
| + // completely, the solid state will be false
|
| + gfx::Rect smallRect = tiling_rect();
|
| + smallRect.Inset(10, 10, 10, 10);
|
| + client_.add_draw_rect(smallRect, paint);
|
| + Region invalidation3(tiling_rect());
|
| + UpdateAndExpandInvalidation(&invalidation3, tiling_size(), tiling_rect());
|
| + EXPECT_FALSE(pile_->IsSolidColor());
|
| +
|
| + // if a third rect is drawn over everything, we should be solid again
|
| + paint.setColor(SK_ColorRED);
|
| + client_.add_draw_rect(tiling_rect(), paint);
|
| + Region invalidation4(tiling_rect());
|
| + UpdateAndExpandInvalidation(&invalidation4, tiling_size(), tiling_rect());
|
| + EXPECT_TRUE(pile_->IsSolidColor());
|
| + EXPECT_EQ(SK_ColorRED, pile_->GetSolidColor());
|
| +
|
| + // but if we draw too many, we don't bother doing the analysis and we should
|
| + // no longer be in a solid state
|
| + client_.add_draw_rect(tiling_rect(), paint);
|
| + client_.add_draw_rect(tiling_rect(), paint);
|
| + client_.add_draw_rect(tiling_rect(), paint);
|
| + client_.add_draw_rect(tiling_rect(), paint);
|
| + client_.add_draw_rect(tiling_rect(), paint);
|
| + Region invalidation5(tiling_rect());
|
| + UpdateAndExpandInvalidation(&invalidation5, tiling_size(), tiling_rect());
|
| + EXPECT_FALSE(pile_->IsSolidColor());
|
| +}
|
| +
|
| } // namespace
|
| } // namespace cc
|
|
|