// Test purging when the max cache size is exceeded static void test_internal_purge(skiatest::Reporter* reporter, const sk_sp<SkSpecialImage>& image) { SkASSERT(image->getSize()); const size_t kCacheSize = image->getSize() + 10; SkAutoTUnref<SkImageFilter::Cache> cache(SkImageFilter::Cache::Create(kCacheSize)); SkIRect clip = SkIRect::MakeWH(100, 100); SkImageFilter::Cache::Key key1(0, SkMatrix::I(), clip, image->uniqueID(), image->subset()); SkImageFilter::Cache::Key key2(1, SkMatrix::I(), clip, image->uniqueID(), image->subset()); SkIPoint offset = SkIPoint::Make(3, 4); cache->set(key1, image.get(), offset); SkIPoint foundOffset; REPORTER_ASSERT(reporter, cache->get(key1, &foundOffset)); // This should knock the first one out of the cache cache->set(key2, image.get(), offset); REPORTER_ASSERT(reporter, cache->get(key2, &foundOffset)); REPORTER_ASSERT(reporter, !cache->get(key1, &foundOffset)); }