Chromium Code Reviews| Index: cc/trees/layer_tree_host_unittest.cc |
| =================================================================== |
| --- cc/trees/layer_tree_host_unittest.cc (revision 210393) |
| +++ cc/trees/layer_tree_host_unittest.cc (working copy) |
| @@ -34,6 +34,7 @@ |
| #include "cc/test/geometry_test_utils.h" |
| #include "cc/test/layer_tree_test.h" |
| #include "cc/test/occlusion_tracker_test_common.h" |
| +#include "cc/test/test_ui_resource_client.h" |
| #include "cc/trees/layer_tree_host_impl.h" |
| #include "cc/trees/layer_tree_impl.h" |
| #include "cc/trees/single_thread_proxy.h" |
| @@ -1107,7 +1108,7 @@ |
| MULTI_THREAD_TEST_F(LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers); |
| // Verify atomicity of commits and reuse of textures. |
| -class LayerTreeHostTestAtomicCommit : public LayerTreeHostTest { |
| +class LayerTreeHostTestDirectRendererAtomicCommit : public LayerTreeHostTest { |
| public: |
| virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { |
| // Make sure partial texture updates are turned off. |
| @@ -1160,17 +1161,15 @@ |
| case 1: |
| // Number of textures should be doubled as the first textures |
| // are used by impl thread and cannot by used for update. |
| - ASSERT_EQ(4u, context->NumTextures()); |
| + ASSERT_EQ(3u, context->NumTextures()); |
| // Number of textures used for commit should still be |
| // one for each layer. |
| EXPECT_EQ(2u, context->NumUsedTextures()); |
| // First textures should not have been used. |
| EXPECT_FALSE(context->UsedTexture(context->TextureAt(0))); |
| - EXPECT_FALSE(context->UsedTexture(context->TextureAt(1))); |
| + EXPECT_TRUE(context->UsedTexture(context->TextureAt(1))); |
| // New textures should have been used. |
| EXPECT_TRUE(context->UsedTexture(context->TextureAt(2))); |
| - EXPECT_TRUE(context->UsedTexture(context->TextureAt(3))); |
| - |
| context->ResetUsedTextures(); |
| PostSetNeedsCommitToMainThread(); |
| break; |
| @@ -1203,17 +1202,68 @@ |
| scrollbar_->SetNeedsDisplay(); |
| } |
| - virtual void AfterTest() OVERRIDE {} |
| + virtual void AfterTest() OVERRIDE { } |
| - private: |
| + protected: |
| FakeContentLayerClient client_; |
| scoped_refptr<FakeContentLayer> layer_; |
| scoped_refptr<FakeScrollbarLayer> scrollbar_; |
| int drew_frame_; |
| }; |
| -MULTI_THREAD_TEST_F(LayerTreeHostTestAtomicCommit); |
| +MULTI_THREAD_DIRECT_RENDERER_TEST_F( |
| + LayerTreeHostTestDirectRendererAtomicCommit); |
| +class LayerTreeHostTestDelegatingRendererAtomicCommit |
| + : public LayerTreeHostTestDirectRendererAtomicCommit { |
| + public: |
| + virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
| + ASSERT_EQ(0u, layer_tree_host()->settings().max_partial_texture_updates); |
| + |
| + TestWebGraphicsContext3D* context = static_cast<TestWebGraphicsContext3D*>( |
| + impl->output_surface()->context3d()); |
| + |
| + switch (impl->active_tree()->source_frame_number()) { |
| + case 0: |
| + // Number of textures should be one for each layer |
| + ASSERT_EQ(2u, context->NumTextures()); |
| + // Number of textures used for commit should be one for each layer. |
| + EXPECT_EQ(2u, context->NumUsedTextures()); |
| + // Verify that used texture is correct. |
| + EXPECT_TRUE(context->UsedTexture(context->TextureAt(0))); |
| + EXPECT_TRUE(context->UsedTexture(context->TextureAt(1))); |
| + context->ResetUsedTextures(); |
| + PostSetNeedsCommitToMainThread(); |
| + break; |
| + case 1: |
| + // Number of textures should be doubled as the first textures |
| + // are used by impl thread and cannot by used for update. |
| + ASSERT_EQ(4u, context->NumTextures()); |
| + // Number of textures used for commit should still be |
| + // one for each layer. |
| + EXPECT_EQ(2u, context->NumUsedTextures()); |
| + // First textures should not have been used. |
| + EXPECT_FALSE(context->UsedTexture(context->TextureAt(0))); |
| + EXPECT_FALSE(context->UsedTexture(context->TextureAt(1))); |
| + // New textures should have been used. |
| + EXPECT_TRUE(context->UsedTexture(context->TextureAt(2))); |
| + EXPECT_TRUE(context->UsedTexture(context->TextureAt(3))); |
| + context->ResetUsedTextures(); |
| + PostSetNeedsCommitToMainThread(); |
| + break; |
| + case 2: |
| + EndTest(); |
| + break; |
| + default: |
| + NOTREACHED(); |
| + break; |
| + } |
| + } |
| +}; |
| + |
| +MULTI_THREAD_DELEGATING_RENDERER_TEST_F( |
| + LayerTreeHostTestDelegatingRendererAtomicCommit); |
| + |
| static void SetLayerPropertiesForTesting(Layer* layer, |
| Layer* parent, |
| const gfx::Transform& transform, |
| @@ -1419,8 +1469,9 @@ |
| }; |
| // Partial updates are not possible with a delegating renderer. |
| -SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( |
| - LayerTreeHostTestAtomicCommitWithPartialUpdate); |
| +// No partial updates with impl-side painting scrollbar. |
| +// SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( |
|
enne (OOO)
2013/07/22 23:09:15
Please don't comment out this test. There's still
powei
2013/07/24 02:28:29
Done. Uncommented the test and kept the content l
|
| +// LayerTreeHostTestAtomicCommitWithPartialUpdate); |
| class LayerTreeHostTestFinishAllRendering : public LayerTreeHostTest { |
| public: |
| @@ -3165,5 +3216,99 @@ |
| MULTI_THREAD_TEST_F(LayerTreeHostTestDeferredInitialize); |
| +// Test for UI Resource management. |
| +class LayerTreeHostTestUIResource : public LayerTreeHostTest { |
| + public: |
| + virtual void BeginTest() OVERRIDE { |
| + ui_resource_client_ = new TestUIResourceClient(); |
| + PostSetNeedsCommitToMainThread(); |
| + } |
| + |
| + virtual void DidCommit() OVERRIDE { |
| + int frame = layer_tree_host()->commit_number(); |
| + switch (frame) { |
| + case 1: |
| + ui_resource_id_ = |
| + layer_tree_host()->CreateUIResource( |
| + base::Bind(&TestUIResourceClient::GetBitmap, |
| + ui_resource_client_.get())); |
| + layer_tree_host()->CreateUIResource( |
| + base::Bind(&TestUIResourceClient::GetBitmap, |
| + ui_resource_client_.get())); |
| + PostSetNeedsCommitToMainThread(); |
| + break; |
| + case 2: |
| + layer_tree_host()->DeleteUIResource(ui_resource_id_); |
| + PostSetNeedsCommitToMainThread(); |
| + break; |
| + case 3: |
| + layer_tree_host()->DeleteUIResource(ui_resource_id_); |
| + PostSetNeedsCommitToMainThread(); |
| + break; |
| + case 4: |
| + layer_tree_host()->CreateUIResource( |
| + base::Bind(&TestUIResourceClient::GetBitmap, |
| + ui_resource_client_.get())); |
| + layer_tree_host()->CreateUIResource( |
| + base::Bind(&TestUIResourceClient::GetBitmap, |
| + ui_resource_client_.get())); |
| + PostSetNeedsCommitToMainThread(); |
| + break; |
| + case 5: |
| + EndTest(); |
| + break; |
| + } |
| + } |
| + |
| + void PerformTest(LayerTreeHostImpl* impl) { |
| + TestWebGraphicsContext3D* context = static_cast<TestWebGraphicsContext3D*>( |
| + impl->output_surface()->context3d()); |
| + |
| + int frame = layer_tree_host()->commit_number(); |
| + switch (frame) { |
| + case 1: |
| + ASSERT_EQ(0u, context->NumTextures()); |
| + break; |
| + case 2: |
| + // Created two textures. |
| + ASSERT_EQ(2u, context->NumTextures()); |
| + break; |
| + case 3: |
| + // One texture left after one deletion. |
| + ASSERT_EQ(1u, context->NumTextures()); |
| + break; |
| + case 4: |
| + // Texture state should not change when delete is called on an |
| + // invalid id. |
| + ASSERT_EQ(1u, context->NumTextures()); |
| + break; |
| + case 5: |
| + // Creation after deletion: two more creates should total up to |
| + // three textures. |
| + ASSERT_EQ(3u, context->NumTextures()); |
| + break; |
| + } |
| + } |
| + |
| + virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
| + if (!layer_tree_host()->settings().impl_side_painting) |
| + PerformTest(impl); |
| + } |
| + |
| + virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
| + if (layer_tree_host()->settings().impl_side_painting) |
| + PerformTest(impl); |
| + } |
| + |
| + virtual void AfterTest() {} |
| + |
| + private: |
| + scoped_refptr<TestUIResourceClient> ui_resource_client_; |
| + UIResourceId ui_resource_id_; |
| +}; |
| + |
| +MULTI_THREAD_TEST_F(LayerTreeHostTestUIResource); |
| + |
| + |
| } // namespace |
| } // namespace cc |