Flutter Engine
The Flutter Engine
Functions
StrikeForGPUTest.cpp File Reference
#include "include/core/SkData.h"
#include "include/core/SkFont.h"
#include "include/core/SkRefCnt.h"
#include "src/core/SkReadBuffer.h"
#include "src/core/SkStrike.h"
#include "src/core/SkStrikeCache.h"
#include "src/core/SkStrikeSpec.h"
#include "src/core/SkWriteBuffer.h"
#include "src/text/StrikeForGPU.h"
#include "tests/Test.h"
#include "tools/fonts/FontToolUtils.h"
#include <cstdint>
#include <memory>
#include <optional>
#include <utility>

Go to the source code of this file.

Functions

 DEF_TEST (SkStrikePromise_Basic, reporter)
 

Function Documentation

◆ DEF_TEST()

DEF_TEST ( SkStrikePromise_Basic  ,
reporter   
)

Definition at line 27 of file StrikeForGPUTest.cpp.

27 {
28 auto strikeCache = std::make_unique<SkStrikeCache>();
30
31 class Pinner : public ::SkStrikePinner {
32 public:
33 // Changing canDelete to return true causes this test to expectedly fail.
34 bool canDelete() override { return false; }
35 };
36
37 intptr_t toCompareWith;
39
40 // Ensure that the ref in srcPromise is dropped.
41 {
42 // Make a strike with a Pinner.
43 auto strike = strikeCache->createStrike(strikeSpec, nullptr, std::make_unique<Pinner>());
44 toCompareWith = reinterpret_cast<intptr_t>(strike.get());
45 SkStrikePromise srcPromise(std::move(strike));
46 SkBinaryWriteBuffer writeBuffer({});
47 srcPromise.flatten(writeBuffer);
48 data = writeBuffer.snapshotAsData();
49 }
50
51 // Remove all unpinned strikes.
52 strikeCache->purgeAll();
53
54 SkReadBuffer readBuffer{data->data(), data->size()};
55 std::optional<SkStrikePromise> dstPromise = SkStrikePromise::MakeFromBuffer(
56 readBuffer, nullptr, strikeCache.get());
57
58 REPORTER_ASSERT(reporter, dstPromise.has_value());
60 reinterpret_cast<intptr_t>(dstPromise->strike()) == toCompareWith);
61}
reporter
Definition: FontMgrTest.cpp:39
#define REPORTER_ASSERT(r, cond,...)
Definition: Test.h:286
virtual bool canDelete()=0
static std::tuple< SkStrikeSpec, SkScalar > MakeCanonicalized(const SkFont &font, const SkPaint *paint=nullptr)
SkFont DefaultFont()
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63