Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3322)

Unified Diff: cc/trees/layer_tree_host_impl_unittest.cc

Issue 18191020: UI Resource Manager (Closed) Base URL: https://src.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: cc/trees/layer_tree_host_impl_unittest.cc
===================================================================
--- cc/trees/layer_tree_host_impl_unittest.cc (revision 214760)
+++ cc/trees/layer_tree_host_impl_unittest.cc (working copy)
@@ -6241,5 +6241,42 @@
EXPECT_EQ(not_visible_cutoff_value, current_priority_cutoff_value_);
}
+TEST_F(LayerTreeHostImplTest, UIResourceManagement) {
aelias_OOO_until_Jul13 2013/07/31 21:00:30 Add a test case for two creations with the same UI
powei 2013/07/31 21:29:39 Done.
+ 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);
enne (OOO) 2013/07/31 22:02:40 Could you delete an invalid resource id here too?
powei 2013/08/01 00:05:10 Done.
+ 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

Powered by Google App Engine
This is Rietveld 408576698