Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions
DiscardableMemoryPoolTest.cpp File Reference
#include "include/core/SkRefCnt.h"
#include "include/private/chromium/SkDiscardableMemory.h"
#include "src/lazy/SkDiscardableMemoryPool.h"
#include "tests/Test.h"
#include <memory>

Go to the source code of this file.

Functions

 DEF_TEST (DiscardableMemoryPool, reporter)
 

Function Documentation

◆ DEF_TEST()

DEF_TEST ( DiscardableMemoryPool  ,
reporter   
)

Definition at line 15 of file DiscardableMemoryPoolTest.cpp.

15 {
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
reporter
#define REPORTER_ASSERT(r, cond,...)
Definition Test.h:286
static sk_sp< SkDiscardableMemoryPool > Make(size_t size)