Flutter Engine
The Flutter Engine
MetaDataTest.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2011 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
9#include "tests/Test.h"
10#include "tools/SkMetaData.h"
11
12#include <array>
13#include <cstddef>
14#include <cstdint>
15#include <cstring>
16
17DEF_TEST(MetaData, reporter) {
18 SkMetaData m1;
19
20 REPORTER_ASSERT(reporter, !m1.findS32("int"));
21 REPORTER_ASSERT(reporter, !m1.findScalar("scalar"));
24
25 m1.setS32("int", 12345);
26 m1.setScalar("scalar", SK_Scalar1 * 42);
27 m1.setPtr("ptr", &m1);
28 m1.setBool("true", true);
29 m1.setBool("false", false);
30
31 int32_t n;
32 SkScalar s;
33
34 m1.setScalar("scalar", SK_Scalar1/2);
35
36 REPORTER_ASSERT(reporter, m1.findS32("int", &n) && n == 12345);
37 REPORTER_ASSERT(reporter, m1.findScalar("scalar", &s) && s == SK_Scalar1/2);
38 REPORTER_ASSERT(reporter, m1.hasBool("true", true));
39 REPORTER_ASSERT(reporter, m1.hasBool("false", false));
40
41 SkMetaData::Iter iter(m1);
42 const char* name;
43
44 static const struct {
45 const char* fName;
46 SkMetaData::Type fType;
47 int fCount;
48 } gElems[] = {
49 { "int", SkMetaData::kS32_Type, 1 },
50 { "scalar", SkMetaData::kScalar_Type, 1 },
51 { "ptr", SkMetaData::kPtr_Type, 1 },
52 { "true", SkMetaData::kBool_Type, 1 },
53 { "false", SkMetaData::kBool_Type, 1 }
54 };
55
56 size_t loop = 0;
57 int count;
59 while ((name = iter.next(&t, &count)) != nullptr)
60 {
61 int match = 0;
62 for (unsigned i = 0; i < std::size(gElems); i++)
63 {
64 if (!strcmp(name, gElems[i].fName))
65 {
66 match += 1;
67 REPORTER_ASSERT(reporter, gElems[i].fType == t);
69 }
70 }
72 loop += 1;
73 }
74 REPORTER_ASSERT(reporter, loop == std::size(gElems));
75
80
81 REPORTER_ASSERT(reporter, !m1.findS32("int"));
82 REPORTER_ASSERT(reporter, !m1.findScalar("scalar"));
83 REPORTER_ASSERT(reporter, !m1.findBool("true"));
84 REPORTER_ASSERT(reporter, !m1.findBool("false"));
85}
const char * fName
reporter
Definition: FontMgrTest.cpp:39
int count
Definition: FontMgrTest.cpp:50
DEF_TEST(MetaData, reporter)
#define SK_Scalar1
Definition: SkScalar.h:18
#define REPORTER_ASSERT(r, cond,...)
Definition: Test.h:286
const char * next(Type *, int *count)
Definition: SkMetaData.cpp:227
bool hasBool(const char name[], bool value) const
Definition: SkMetaData.h:40
bool removeBool(const char name[])
Definition: SkMetaData.cpp:212
bool findScalar(const char name[], SkScalar *value=nullptr) const
Definition: SkMetaData.cpp:109
@ kScalar_Type
Definition: SkMetaData.h:58
void setS32(const char name[], int32_t value)
Definition: SkMetaData.cpp:24
void setPtr(const char name[], void *value)
Definition: SkMetaData.cpp:42
bool removeScalar(const char name[])
Definition: SkMetaData.cpp:202
bool removeS32(const char name[])
Definition: SkMetaData.cpp:197
void setBool(const char name[], bool value)
Definition: SkMetaData.cpp:46
void setScalar(const char name[], SkScalar value)
Definition: SkMetaData.cpp:29
bool findBool(const char name[], bool *value=nullptr) const
Definition: SkMetaData.cpp:149
bool findS32(const char name[], int32_t *value=nullptr) const
Definition: SkMetaData.cpp:96
float SkScalar
Definition: extension.cpp:12
struct MyStruct s
def match(bench, filt)
Definition: benchmark.py:23
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259