Chromium Code Reviews| Index: tests/ResourceCacheTest.cpp |
| diff --git a/tests/ResourceCacheTest.cpp b/tests/ResourceCacheTest.cpp |
| index caa07799d02bc2e4ab8ae8bff643e182b4232965..7b447426690be7a81d49926e1d28726601e7b4d6 100644 |
| --- a/tests/ResourceCacheTest.cpp |
| +++ b/tests/ResourceCacheTest.cpp |
| @@ -174,7 +174,7 @@ static void test_no_key(skiatest::Reporter* reporter) { |
| REPORTER_ASSERT(reporter, 0 == cache2->getResourceBytes()); |
| } |
| -static void test_wrapped(skiatest::Reporter* reporter) { |
| +static void test_budgeting(skiatest::Reporter* reporter) { |
| SkAutoTUnref<GrContext> context(GrContext::CreateMockContext()); |
| REPORTER_ASSERT(reporter, SkToBool(context)); |
| if (NULL == context) { |
| @@ -200,6 +200,9 @@ static void test_wrapped(skiatest::Reporter* reporter) { |
| REPORTER_ASSERT(reporter, content->cacheAccess().setContentKey(contentKey)); |
| TestResource* wrapped = new TestResource(context->getGpu(), true); |
| scratch->setSize(12); |
| + TestResource* unbudgeted = new TestResource(context->getGpu()); |
| + unbudgeted->setSize(13); |
| + unbudgeted->cacheAccess().setBudgeted(false); |
| // Make sure we can't add a content key to the wrapped resource |
| keyData.fData8[0] = 1; |
| @@ -208,47 +211,54 @@ static void test_wrapped(skiatest::Reporter* reporter) { |
| REPORTER_ASSERT(reporter, NULL == cache2->findAndRefContentResource(contentKey2)); |
| // Make sure sizes are as we expect |
| - REPORTER_ASSERT(reporter, 3 == cache2->getResourceCount()); |
| + REPORTER_ASSERT(reporter, 4 == cache2->getResourceCount()); |
| REPORTER_ASSERT(reporter, scratch->gpuMemorySize() + content->gpuMemorySize() + |
| - wrapped->gpuMemorySize() == cache2->getResourceBytes()); |
| + wrapped->gpuMemorySize() + unbudgeted->gpuMemorySize() == |
| + cache2->getResourceBytes()); |
| REPORTER_ASSERT(reporter, 2 == cache2->getBudgetedResourceCount()); |
| REPORTER_ASSERT(reporter, scratch->gpuMemorySize() + content->gpuMemorySize() == |
| cache2->getBudgetedResourceBytes()); |
| // Our refs mean that the resources are non purgable. |
| cache2->purgeAllUnlocked(); |
| - REPORTER_ASSERT(reporter, 3 == cache2->getResourceCount()); |
| + REPORTER_ASSERT(reporter, 4 == cache2->getResourceCount()); |
| REPORTER_ASSERT(reporter, scratch->gpuMemorySize() + content->gpuMemorySize() + |
| - wrapped->gpuMemorySize() == cache2->getResourceBytes()); |
| + wrapped->gpuMemorySize() + unbudgeted->gpuMemorySize() == |
| + cache2->getResourceBytes()); |
| REPORTER_ASSERT(reporter, 2 == cache2->getBudgetedResourceCount()); |
| REPORTER_ASSERT(reporter, scratch->gpuMemorySize() + content->gpuMemorySize() == |
| cache2->getBudgetedResourceBytes()); |
| // Unreffing the wrapped resource should free it right away. |
| wrapped->unref(); |
| - REPORTER_ASSERT(reporter, 2 == cache2->getResourceCount()); |
| - REPORTER_ASSERT(reporter, scratch->gpuMemorySize() + content->gpuMemorySize() == |
| - cache2->getResourceBytes()); |
| + REPORTER_ASSERT(reporter, 3 == cache2->getResourceCount()); |
| + REPORTER_ASSERT(reporter, scratch->gpuMemorySize() + content->gpuMemorySize() + |
| + unbudgeted->gpuMemorySize() == cache2->getResourceBytes()); |
| - // Now try freeing the other two resources first |
| + // Now try freeing the budgeted resources first |
| wrapped = new TestResource(context->getGpu(), true); |
| scratch->setSize(12); |
| content->unref(); |
| cache2->purgeAllUnlocked(); |
| - REPORTER_ASSERT(reporter, 2 == cache2->getResourceCount()); |
| - REPORTER_ASSERT(reporter, scratch->gpuMemorySize() + wrapped->gpuMemorySize() == |
| - cache2->getResourceBytes()); |
| + REPORTER_ASSERT(reporter, 3 == cache2->getResourceCount()); |
| + REPORTER_ASSERT(reporter, scratch->gpuMemorySize() + wrapped->gpuMemorySize() + |
| + unbudgeted->gpuMemorySize() == cache2->getResourceBytes()); |
| REPORTER_ASSERT(reporter, 1 == cache2->getBudgetedResourceCount()); |
| REPORTER_ASSERT(reporter, scratch->gpuMemorySize() == cache2->getBudgetedResourceBytes()); |
| scratch->unref(); |
| cache2->purgeAllUnlocked(); |
| - REPORTER_ASSERT(reporter, 1 == cache2->getResourceCount()); |
| - REPORTER_ASSERT(reporter, wrapped->gpuMemorySize() == cache2->getResourceBytes()); |
| + REPORTER_ASSERT(reporter, 2 == cache2->getResourceCount()); |
| + REPORTER_ASSERT(reporter, unbudgeted->gpuMemorySize() + wrapped->gpuMemorySize() == |
| + cache2->getResourceBytes()); |
|
egdaniel
2014/11/13 20:47:32
align this
bsalomon
2014/11/13 20:53:34
Done.
|
| REPORTER_ASSERT(reporter, 0 == cache2->getBudgetedResourceCount()); |
| REPORTER_ASSERT(reporter, 0 == cache2->getBudgetedResourceBytes()); |
| wrapped->unref(); |
| + REPORTER_ASSERT(reporter, 1 == cache2->getResourceCount()); |
|
egdaniel
2014/11/13 20:47:32
I notice at this point we stop checking getBudgete
bsalomon
2014/11/13 20:53:34
Done.
|
| + REPORTER_ASSERT(reporter, unbudgeted->gpuMemorySize() == cache2->getResourceBytes()); |
| + |
| + unbudgeted->unref(); |
| REPORTER_ASSERT(reporter, 0 == cache2->getResourceCount()); |
| REPORTER_ASSERT(reporter, 0 == cache2->getResourceBytes()); |
| } |
| @@ -579,7 +589,7 @@ DEF_GPUTEST(ResourceCache, reporter, factory) { |
| // The below tests create their own mock contexts. |
| test_no_key(reporter); |
| - test_wrapped(reporter); |
| + test_budgeting(reporter); |
| test_duplicate_content_key(reporter); |
| test_duplicate_scratch_key(reporter); |
| test_purge_invalidated(reporter); |