| Index: cc/trees/layer_tree_host_impl_unittest.cc
|
| ===================================================================
|
| --- cc/trees/layer_tree_host_impl_unittest.cc (revision 210393)
|
| +++ cc/trees/layer_tree_host_impl_unittest.cc (working copy)
|
| @@ -265,6 +265,8 @@
|
| void pinch_zoom_pan_viewport_and_scroll_boundary_test(
|
| float device_scale_factor);
|
|
|
| + virtual void UIResourceLostOnImplThread(UIResourceId uid) OVERRIDE {}
|
| +
|
| protected:
|
| virtual scoped_ptr<OutputSurface> CreateOutputSurface() {
|
| return CreateFakeOutputSurface();
|
| @@ -6090,5 +6092,42 @@
|
| EXPECT_EQ(not_visible_cutoff_value, current_priority_cutoff_value_);
|
| }
|
|
|
| +TEST_F(LayerTreeHostImplTest, UIResourceManagement) {
|
| + scoped_ptr<TestWebGraphicsContext3D> context =
|
| + TestWebGraphicsContext3D::Create();
|
| + TestWebGraphicsContext3D* context3d = context.get();
|
| + scoped_ptr<OutputSurface> output_surface = FakeOutputSurface::Create3d(
|
| + context.PassAs<WebKit::WebGraphicsContext3D>()).PassAs<OutputSurface>();
|
| + host_impl_->InitializeRenderer(output_surface.Pass());
|
| +
|
| + EXPECT_EQ(0u, context3d->NumTextures());
|
| +
|
| + UIResourceId ui_resource_id = 1;
|
| + scoped_refptr<UIResourceBitmap> bitmap =
|
| + UIResourceBitmap::Create(new uint8_t[1],
|
| + UIResourceBitmap::RGBA8,
|
| + gfx::Size(1, 1));
|
| + host_impl_->CreateUIResource(ui_resource_id, bitmap);
|
| + EXPECT_EQ(1u, context3d->NumTextures());
|
| + ResourceProvider::ResourceId id =
|
| + host_impl_->ResourceIdForUIResource(ui_resource_id);
|
| + EXPECT_NE(0u, id);
|
| + EXPECT_EQ(ResourceProvider::GLTexture,
|
| + host_impl_->resource_provider()->GetResourceType(id));
|
| +
|
| + // Should return zero for invalid UIResourceId. Number of textures should
|
| + // not change.
|
| + EXPECT_EQ(0u, host_impl_->ResourceIdForUIResource(-1));
|
| + EXPECT_EQ(1u, context3d->NumTextures());
|
| +
|
| + host_impl_->DeleteUIResource(ui_resource_id);
|
| + EXPECT_EQ(0u, host_impl_->ResourceIdForUIResource(ui_resource_id));
|
| + EXPECT_EQ(0u, context3d->NumTextures());
|
| +
|
| + // Should not change state for multiple deletion on one UIResourceId
|
| + host_impl_->DeleteUIResource(ui_resource_id);
|
| + EXPECT_EQ(0u, context3d->NumTextures());
|
| +}
|
| +
|
| } // namespace
|
| } // namespace cc
|
|
|