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..487209fdd9431c753125e2437efb5a57e7f024c4 100644 |
| --- a/cc/trees/layer_tree_host_unittest.cc |
| +++ b/cc/trees/layer_tree_host_unittest.cc |
| @@ -5023,4 +5023,81 @@ 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); |
| + layer_tree_host()->SetViewportSize(gfx::Size(1000, 1000)); |
|
danakj
2014/09/23 20:55:29
the base class does this for you based on the root
vmpstr
2014/09/23 21:39:32
Done.
|
| + LayerTreeHostTest::SetupTree(); |
| + } |
| + |
| + virtual void BeginTest() OVERRIDE { |
| + // Kick off the test with a commit. |
| + PostSetNeedsCommitToMainThread(); |
| + } |
| + |
| + virtual void WillCommit() OVERRIDE { |
| + // As soon as we're in the will commit state (created a pending tree), go |
| + // invisible. |
| + PostSetVisibleToMainThread(false); |
|
danakj
2014/09/23 20:55:29
you're on the main thread, you can layer_tree_host
vmpstr
2014/09/23 21:39:32
Done.
|
| + } |
| + |
| + 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. |
| + 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, |
|
danakj
2014/09/23 20:55:28
can you EXPECT that some tiles are RESOURCE mode (
vmpstr
2014/09/23 21:39:32
Done.
|
| + tile_version.mode()); |
| + } |
| + |
| + // We can finish the test now. |
|
danakj
2014/09/23 20:55:28
remove, this doesn't explain anything
vmpstr
2014/09/23 21:39:31
Done.
|
| + 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_; |
| +}; |
| + |
| +MULTI_THREAD_TEST_F(LayerTreeHostTestInvisibleDoesntActivate); |
|
danakj
2014/09/23 20:55:28
Can you TODO to enable with single thread impl-sid
vmpstr
2014/09/23 21:39:32
Done.
|
| + |
| } // namespace cc |