skia2/tests/DiscardableMemoryPool.cpp
commit-bot@chromium.org e2eac8b2fd Move macros from TestClassDef.h to Test.h
Motivation: those macros don't make any sense without the definitions
in Test.h.

BUG=
R=mtklein@google.com

Author: halcanary@google.com

Review URL: https://codereview.chromium.org/138563004

git-svn-id: http://skia.googlecode.com/svn/trunk@13074 2bbb7eff-a529-9590-31e7-b0007b416f81
2014-01-14 21:04:37 +00:00

36 lines
1.1 KiB
C++

/*
* Copyright 2013 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "SkDiscardableMemoryPool.h"
#include "Test.h"
DEF_TEST(DiscardableMemoryPool, reporter) {
SkAutoTUnref<SkDiscardableMemoryPool> pool(
SkNEW_ARGS(SkDiscardableMemoryPool, (1, NULL)));
pool->setRAMBudget(3);
REPORTER_ASSERT(reporter, 0 == pool->getRAMUsed());
SkAutoTDelete<SkDiscardableMemory> dm1(pool->create(100));
REPORTER_ASSERT(reporter, dm1->data() != NULL);
REPORTER_ASSERT(reporter, 100 == pool->getRAMUsed());
dm1->unlock();
REPORTER_ASSERT(reporter, 0 == pool->getRAMUsed());
REPORTER_ASSERT(reporter, !dm1->lock());
SkAutoTDelete<SkDiscardableMemory> dm2(pool->create(200));
REPORTER_ASSERT(reporter, 200 == pool->getRAMUsed());
pool->setRAMBudget(400);
dm2->unlock();
REPORTER_ASSERT(reporter, 200 == pool->getRAMUsed());
REPORTER_ASSERT(reporter, dm2->lock());
dm2->unlock();
pool->dumpPool();
REPORTER_ASSERT(reporter, !dm2->lock());
REPORTER_ASSERT(reporter, 0 == pool->getRAMUsed());
}