Chromium Code Reviews| Index: cc/trees/layer_tree_host_unittest.cc |
| diff --git a/cc/trees/layer_tree_host_unittest.cc b/cc/trees/layer_tree_host_unittest.cc |
| index b90831e02b4e5f3e1e4ae31858281c2207c90db6..75ae66172fa75f1c2d94fe3163febca8765e37ff 100644 |
| --- a/cc/trees/layer_tree_host_unittest.cc |
| +++ b/cc/trees/layer_tree_host_unittest.cc |
| @@ -5023,4 +5023,80 @@ class LayerTreeHostTestContinuousPainting : public LayerTreeHostTest { |
| MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting); |
| +class LayerTreeHostTestInvisibleDoesntActivate : public LayerTreeHostTest { |
| + public: |
| + LayerTreeHostTestInvisibleDoesntActivate() : activation_count_(0) {} |
| + |
| + virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { |
| + settings->impl_side_painting = true; |
| + } |
| + |
| + virtual void SetupTree() OVERRIDE { |
| + scoped_refptr<Layer> root_layer = Layer::Create(); |
| + root_layer->SetBounds(gfx::Size(1000, 1000)); |
| + |
| + // Set up a non-solid layer with a bunch of tiles. |
| + client_.set_fill_with_nonsolid_color(true); |
| + picture_layer_ = FakePictureLayer::Create(&client_); |
| + picture_layer_->SetBounds(gfx::Size(1000, 1000)); |
| + picture_layer_->SetIsDrawable(true); |
| + picture_layer_->SetNeedsDisplayRect(gfx::Rect(1000, 1000)); |
| + root_layer->AddChild(picture_layer_.get()); |
| + |
| + layer_tree_host()->SetRootLayer(root_layer); |
| + LayerTreeHostTest::SetupTree(); |
| + } |
| + |
| + virtual void BeginTest() OVERRIDE { |
| + // Kick off the test with a commit. |
| + PostSetNeedsCommitToMainThread(); |
| + } |
| + |
| + virtual void DidCommit() OVERRIDE { layer_tree_host()->SetVisible(false); } |
|
danakj
2014/09/23 21:42:10
i really liked your comment explaining about the p
vmpstr
2014/09/23 22:31:50
There shouldn't be races here.. However, I did a b
|
| + |
| + virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
| + ++activation_count_; |
| + std::vector<Tile*> tiles = impl->tile_manager()->AllTilesForTesting(); |
| + EXPECT_GT(tiles.size(), 0u); |
| + // When activating, ensure that all tiles are ready to draw with a mode |
| + // other than rasterize on demand. |
| + int resource_tiles_count = 0; |
| + for (std::vector<Tile*>::iterator it = tiles.begin(); it != tiles.end(); |
| + ++it) { |
| + Tile* tile = *it; |
| + const ManagedTileState::TileVersion& tile_version = |
| + tile->GetTileVersionForDrawing(); |
| + EXPECT_TRUE(tile_version.IsReadyToDraw()); |
| + EXPECT_NE(ManagedTileState::TileVersion::PICTURE_PILE_MODE, |
| + tile_version.mode()); |
| + resource_tiles_count += |
| + tile_version.mode() == ManagedTileState::TileVersion::RESOURCE_MODE; |
| + } |
| + EXPECT_GT(resource_tiles_count, 0); |
| + |
| + EndTest(); |
| + } |
| + |
| + virtual void DidSetVisibleOnImplTree(LayerTreeHostImpl* host_impl, |
| + bool visible) OVERRIDE { |
| + // Once invisible, we can go visible again. |
| + if (!visible) |
| + PostSetVisibleToMainThread(true); |
| + } |
| + |
| + virtual void AfterTest() OVERRIDE { |
| + // Double check that we activated once. |
| + EXPECT_EQ(1, activation_count_); |
| + } |
| + |
| + private: |
| + int activation_count_; |
| + |
| + FakeContentLayerClient client_; |
| + scoped_refptr<FakePictureLayer> picture_layer_; |
| +}; |
| + |
| +// TODO(vmpstr): Enable with single thread impl-side painting. |
| +MULTI_THREAD_TEST_F(LayerTreeHostTestInvisibleDoesntActivate); |
| + |
| } // namespace cc |