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

Unified Diff: cc/tiles/gpu_image_decode_cache_unittest.cc

Issue 2795803002: Clear Image Decode Cache on Navigation (Closed)
Patch Set: fix conversion Created 3 years, 8 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/tiles/gpu_image_decode_cache.cc ('k') | cc/tiles/image_controller_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/tiles/gpu_image_decode_cache_unittest.cc
diff --git a/cc/tiles/gpu_image_decode_cache_unittest.cc b/cc/tiles/gpu_image_decode_cache_unittest.cc
index 82ca3b207acc5010a73db38df5dbe2f901ff39a3..b7e8477c2d50c24739dde33f4e565e75b57e2b52 100644
--- a/cc/tiles/gpu_image_decode_cache_unittest.cc
+++ b/cc/tiles/gpu_image_decode_cache_unittest.cc
@@ -1552,5 +1552,39 @@ TEST(GpuImageDecodeCacheTest, SmallCacheNormalWorkingSet) {
}
}
+TEST(GpuImageDecodeCacheTest, ClearCache) {
+ auto context_provider = TestContextProvider::Create();
+ context_provider->BindToCurrentThread();
+ TestGpuImageDecodeCache cache(context_provider.get());
+ bool is_decomposable = true;
+ SkFilterQuality quality = kHigh_SkFilterQuality;
+
+ for (int i = 0; i < 10; ++i) {
+ sk_sp<SkImage> image = CreateImage(100, 100);
+ DrawImage draw_image(
+ image, SkIRect::MakeWH(image->width(), image->height()), quality,
+ CreateMatrix(SkSize::Make(1.0f, 1.0f), is_decomposable));
+ scoped_refptr<TileTask> task;
+ bool need_unref = cache.GetTaskForImageAndRef(
+ draw_image, ImageDecodeCache::TracingInfo(), &task);
+ EXPECT_TRUE(need_unref);
+ EXPECT_TRUE(task);
+ TestTileTaskRunner::ProcessTask(task->dependencies()[0].get());
+ TestTileTaskRunner::ProcessTask(task.get());
+ cache.UnrefImage(draw_image);
+ }
+
+ // We should now have data image in our cache.
+ EXPECT_GT(cache.GetBytesUsedForTesting(), 0u);
+ EXPECT_EQ(cache.GetNumCacheEntriesForTesting(), 10u);
+
+ // Tell our cache to clear resources.
+ cache.ClearCache();
+
+ // We should now have nothing in our cache.
+ EXPECT_EQ(cache.GetBytesUsedForTesting(), 0u);
+ EXPECT_EQ(cache.GetNumCacheEntriesForTesting(), 0u);
+}
+
} // namespace
} // namespace cc
« no previous file with comments | « cc/tiles/gpu_image_decode_cache.cc ('k') | cc/tiles/image_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698