Index: cc/layers/picture_layer_impl_unittest.cc |
diff --git a/cc/layers/picture_layer_impl_unittest.cc b/cc/layers/picture_layer_impl_unittest.cc |
index 2b9457b019fe60f6862711d97893cd87f7bda4c0..a9e4c26829002ee2bcf5096efdd0d620c818f747 100644 |
--- a/cc/layers/picture_layer_impl_unittest.cc |
+++ b/cc/layers/picture_layer_impl_unittest.cc |
@@ -270,6 +270,71 @@ class PictureLayerImplTest : public testing::Test { |
} |
} |
+ void TestQuadsForSolidColor(bool test_for_solid) { |
danakj
2014/09/15 16:26:35
This code is soo far away from the actual tests. C
hendrikw
2014/09/15 16:59:40
Acknowledged.
|
+ base::TimeTicks time_ticks; |
+ time_ticks += base::TimeDelta::FromMilliseconds(1); |
+ host_impl_.SetCurrentBeginFrameArgs( |
+ CreateBeginFrameArgsForTesting(time_ticks)); |
+ |
+ gfx::Size tile_size(100, 100); |
+ gfx::Size layer_bounds(200, 200); |
+ gfx::Rect layer_rect(layer_bounds); |
+ |
+ FakeContentLayerClient client; |
+ scoped_refptr<PictureLayer> layer = PictureLayer::Create(&client); |
+ scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(); |
+ host->SetRootLayer(layer); |
+ PicturePile* pile = layer->GetPicturePileForTesting(); |
+ |
+ host_impl_.SetViewportSize(layer_bounds); |
+ |
+ int frame_number = 0; |
+ FakeRenderingStatsInstrumentation stats_instrumentation; |
+ |
+ client.set_fill_with_nonsolid_color(!test_for_solid); |
+ |
+ Region invalidation(layer_rect); |
+ pile->UpdateAndExpandInvalidation(&client, |
+ &invalidation, |
+ SK_ColorWHITE, |
+ false, |
+ false, |
+ layer_bounds, |
+ layer_rect, |
+ frame_number++, |
+ Picture::RECORD_NORMALLY, |
+ &stats_instrumentation); |
+ |
+ scoped_refptr<PicturePileImpl> pending_pile = |
+ PicturePileImpl::CreateFromOther(pile); |
+ |
+ SetupPendingTree(pending_pile); |
+ ActivateTree(); |
+ |
+ if (test_for_solid) { |
+ EXPECT_EQ(0, active_layer_->tilings()->num_tilings()); |
+ } else { |
+ active_layer_->set_fixed_tile_size(tile_size); |
+ host_impl_.active_tree()->UpdateDrawProperties(); |
+ std::vector<Tile*> tiles = |
vmpstr
2014/09/15 15:45:07
you should ASSERT_TRUE(active_layer_->tilings());
hendrikw
2014/09/15 16:59:40
Acknowledged.
But a failure in a test doesn't pre
danakj
2014/09/15 17:01:22
An EXPECT_FOO failure continues the test. An ASSER
|
+ active_layer_->tilings()->tiling_at(0)->AllTilesForTesting(); |
+ EXPECT_FALSE(tiles.empty()); |
+ host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); |
+ } |
+ |
+ MockOcclusionTracker<LayerImpl> occlusion_tracker; |
+ scoped_ptr<RenderPass> render_pass = RenderPass::Create(); |
+ AppendQuadsData data; |
+ active_layer_->WillDraw(DRAW_MODE_SOFTWARE, NULL); |
+ active_layer_->AppendQuads(render_pass.get(), occlusion_tracker, &data); |
+ active_layer_->DidDraw(NULL); |
+ |
+ DrawQuad::Material expected = test_for_solid |
+ ? DrawQuad::Material::SOLID_COLOR |
+ : DrawQuad::Material::TILED_CONTENT; |
+ EXPECT_EQ(expected, render_pass->quad_list.front()->material); |
+ } |
+ |
FakeImplProxy proxy_; |
TestSharedBitmapManager shared_bitmap_manager_; |
FakeLayerTreeHostImpl host_impl_; |
@@ -4222,5 +4287,13 @@ TEST_F(PictureLayerImplTest, RecycledTwinLayer) { |
EXPECT_FALSE(active_layer_->GetRecycledTwinLayer()); |
} |
+TEST_F(PictureLayerImplTest, DrawSolidQuads) { |
+ TestQuadsForSolidColor(true); |
+} |
+ |
+TEST_F(PictureLayerImplTest, DrawNonSolidQuads) { |
+ TestQuadsForSolidColor(false); |
+} |
+ |
} // namespace |
} // namespace cc |