Flutter Engine
The Flutter Engine
DiscardableMemoryPoolTest.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2013 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
11#include "tests/Test.h"
12
13#include <memory>
14
15DEF_TEST(DiscardableMemoryPool, reporter) {
17 pool->setRAMBudget(3);
18 REPORTER_ASSERT(reporter, 0 == pool->getRAMUsed());
19
20 std::unique_ptr<SkDiscardableMemory> dm1(pool->create(100));
21 REPORTER_ASSERT(reporter, dm1->data() != nullptr);
22 REPORTER_ASSERT(reporter, 100 == pool->getRAMUsed());
23 dm1->unlock();
24 REPORTER_ASSERT(reporter, 0 == pool->getRAMUsed());
25 REPORTER_ASSERT(reporter, !dm1->lock());
26
27
28 std::unique_ptr<SkDiscardableMemory> dm2(pool->create(200));
29 REPORTER_ASSERT(reporter, 200 == pool->getRAMUsed());
30 pool->setRAMBudget(400);
31 dm2->unlock();
32 REPORTER_ASSERT(reporter, 200 == pool->getRAMUsed());
33 REPORTER_ASSERT(reporter, dm2->lock());
34 dm2->unlock();
35 pool->dumpPool();
36 REPORTER_ASSERT(reporter, !dm2->lock());
37 REPORTER_ASSERT(reporter, 0 == pool->getRAMUsed());
38}
AutoreleasePool pool
DEF_TEST(DiscardableMemoryPool, reporter)
reporter
Definition: FontMgrTest.cpp:39
#define REPORTER_ASSERT(r, cond,...)
Definition: Test.h:286
static sk_sp< SkDiscardableMemoryPool > Make(size_t size)