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

Unified Diff: cc/resources/resource_pool_unittest.cc

Issue 2243013002: Refactor ResourcePool::AcquireResource() and add test. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Test failure. Created 4 years, 4 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
« no previous file with comments | « cc/resources/resource_pool.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/resources/resource_pool_unittest.cc
diff --git a/cc/resources/resource_pool_unittest.cc b/cc/resources/resource_pool_unittest.cc
index 53ccf4541001c9fb2a0d034a2d984e741bf03e25..5c9d0dada9369c6eb801b54423a7a1bf7aefd3f2 100644
--- a/cc/resources/resource_pool_unittest.cc
+++ b/cc/resources/resource_pool_unittest.cc
@@ -17,7 +17,6 @@
#include "testing/gtest/include/gtest/gtest.h"
namespace cc {
-namespace {
class ResourcePoolTest : public testing::Test {
public:
@@ -310,5 +309,29 @@ TEST_F(ResourcePoolTest, UpdateContentIdAndInvalidatedRect) {
resource_pool_->ReleaseResource(reacquired_resource);
}
-} // namespace
+TEST_F(ResourcePoolTest, ReuseResource) {
+ ResourceFormat format = RGBA_8888;
+ gfx::ColorSpace color_space = gfx::ColorSpace::CreateSRGB();
+
+ // Create unused resources with sizes close to 100, 100.
+ resource_pool_->ReleaseResource(
+ resource_pool_->CreateResource(gfx::Size(99, 100), format, color_space));
+ resource_pool_->ReleaseResource(
+ resource_pool_->CreateResource(gfx::Size(99, 99), format, color_space));
+ resource_pool_->ReleaseResource(
+ resource_pool_->CreateResource(gfx::Size(100, 99), format, color_space));
+ resource_pool_->ReleaseResource(
+ resource_pool_->CreateResource(gfx::Size(101, 101), format, color_space));
+ resource_pool_->CheckBusyResources();
+
+ gfx::Size size(100, 100);
+ Resource* resource = resource_pool_->ReuseResource(size, format, color_space);
+ EXPECT_EQ(nullptr, resource);
+ size = gfx::Size(100, 99);
+ resource = resource_pool_->ReuseResource(size, format, color_space);
+ EXPECT_NE(nullptr, resource);
+ ASSERT_EQ(nullptr, resource_pool_->ReuseResource(size, format, color_space));
+ resource_pool_->ReleaseResource(resource);
+}
+
} // namespace cc
« no previous file with comments | « cc/resources/resource_pool.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698