OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 #include "SkDiscardableMemoryPool.h" | 7 #include "SkDiscardableMemoryPool.h" |
8 | 8 |
9 #include "Test.h" | 9 #include "Test.h" |
10 | 10 |
11 DEF_TEST(DiscardableMemoryPool, reporter) { | 11 DEF_TEST(DiscardableMemoryPool, reporter) { |
12 SkAutoTUnref<SkDiscardableMemoryPool> pool( | 12 SkAutoTUnref<SkDiscardableMemoryPool> pool( |
13 SkDiscardableMemoryPool::Create(1, NULL)); | 13 SkDiscardableMemoryPool::Create(1, nullptr)); |
14 pool->setRAMBudget(3); | 14 pool->setRAMBudget(3); |
15 REPORTER_ASSERT(reporter, 0 == pool->getRAMUsed()); | 15 REPORTER_ASSERT(reporter, 0 == pool->getRAMUsed()); |
16 | 16 |
17 SkAutoTDelete<SkDiscardableMemory> dm1(pool->create(100)); | 17 SkAutoTDelete<SkDiscardableMemory> dm1(pool->create(100)); |
18 REPORTER_ASSERT(reporter, dm1->data() != NULL); | 18 REPORTER_ASSERT(reporter, dm1->data() != nullptr); |
19 REPORTER_ASSERT(reporter, 100 == pool->getRAMUsed()); | 19 REPORTER_ASSERT(reporter, 100 == pool->getRAMUsed()); |
20 dm1->unlock(); | 20 dm1->unlock(); |
21 REPORTER_ASSERT(reporter, 0 == pool->getRAMUsed()); | 21 REPORTER_ASSERT(reporter, 0 == pool->getRAMUsed()); |
22 REPORTER_ASSERT(reporter, !dm1->lock()); | 22 REPORTER_ASSERT(reporter, !dm1->lock()); |
23 | 23 |
24 | 24 |
25 SkAutoTDelete<SkDiscardableMemory> dm2(pool->create(200)); | 25 SkAutoTDelete<SkDiscardableMemory> dm2(pool->create(200)); |
26 REPORTER_ASSERT(reporter, 200 == pool->getRAMUsed()); | 26 REPORTER_ASSERT(reporter, 200 == pool->getRAMUsed()); |
27 pool->setRAMBudget(400); | 27 pool->setRAMBudget(400); |
28 dm2->unlock(); | 28 dm2->unlock(); |
29 REPORTER_ASSERT(reporter, 200 == pool->getRAMUsed()); | 29 REPORTER_ASSERT(reporter, 200 == pool->getRAMUsed()); |
30 REPORTER_ASSERT(reporter, dm2->lock()); | 30 REPORTER_ASSERT(reporter, dm2->lock()); |
31 dm2->unlock(); | 31 dm2->unlock(); |
32 pool->dumpPool(); | 32 pool->dumpPool(); |
33 REPORTER_ASSERT(reporter, !dm2->lock()); | 33 REPORTER_ASSERT(reporter, !dm2->lock()); |
34 REPORTER_ASSERT(reporter, 0 == pool->getRAMUsed()); | 34 REPORTER_ASSERT(reporter, 0 == pool->getRAMUsed()); |
35 } | 35 } |
OLD | NEW |