Flutter Engine
The Flutter Engine
Classes | Functions
RecordTestUtils.h File Reference
#include "src/core/SkRecord.h"
#include "src/core/SkRecords.h"
#include "tests/Test.h"

Go to the source code of this file.

Classes

struct  ReadAs< U >
 
struct  MatchType< DrawT >
 

Functions

template<typename T >
static const Tassert_type (skiatest::Reporter *r, const SkRecord &record, int index)
 
template<typename DrawT >
int count_instances_of_type (const SkRecord &record)
 
template<typename DrawT >
int find_first_instances_of_type (const SkRecord &record)
 

Function Documentation

◆ assert_type()

template<typename T >
static const T * assert_type ( skiatest::Reporter r,
const SkRecord record,
int  index 
)
static

Definition at line 31 of file RecordTestUtils.h.

31 {
32 ReadAs<T> reader;
33 record.visit(index, reader);
34 REPORTER_ASSERT(r, T::kType == reader.type);
35 REPORTER_ASSERT(r, SkToBool(reader.ptr));
36 return reader.ptr;
37}
static constexpr bool SkToBool(const T &x)
Definition: SkTo.h:35
#define REPORTER_ASSERT(r, cond,...)
Definition: Test.h:286
auto visit(int i, F &&f) const -> decltype(f(SkRecords::NoOp()))
Definition: SkRecord.h:45
const U * ptr
SkRecords::Type type

◆ count_instances_of_type()

template<typename DrawT >
int count_instances_of_type ( const SkRecord record)

Definition at line 44 of file RecordTestUtils.h.

44 {
45 MatchType<DrawT> matcher;
46 int counter = 0;
47 for (int i = 0; i < record.count(); i++) {
48 counter += record.visit(i, matcher);
49 }
50 return counter;
51}
int count() const
Definition: SkRecord.h:38

◆ find_first_instances_of_type()

template<typename DrawT >
int find_first_instances_of_type ( const SkRecord record)

Definition at line 53 of file RecordTestUtils.h.

53 {
54 MatchType<DrawT> matcher;
55 for (int i = 0; i < record.count(); i++) {
56 if (record.visit(i, matcher)) {
57 return i;
58 }
59 }
60 return -1;
61}