Flutter Engine
The Flutter Engine
Functions | Variables
skqp.cpp File Reference
#include "tools/skqp/src/skqp.h"
#include "gm/gm.h"
#include "include/core/SkGraphics.h"
#include "include/core/SkStream.h"
#include "include/core/SkSurface.h"
#include "include/gpu/GrContextOptions.h"
#include "include/gpu/GrDirectContext.h"
#include "src/core/SkOSFile.h"
#include "src/utils/SkOSPath.h"
#include "tests/Test.h"
#include "tests/TestHarness.h"
#include "tools/Resources.h"
#include "tools/fonts/FontToolUtils.h"
#include <algorithm>
#include <regex>

Go to the source code of this file.

Functions

static std::vector< SkQP::UnitTestget_unit_tests (int enforcedAndroidAPILevel)
 
static std::vector< SkQP::SkSLErrorTestget_sksl_error_tests (SkQPAssetManager *assetManager, int enforcedAndroidAPILevel)
 
TestHarness CurrentTestHarness ()
 
template<typename T >
void write (SkWStream *wStream, const T &text)
 

Variables

static constexpr char kUnitTestReportPath [] = "unit_tests.txt"
 
static const std::pair< std::regex, CtsEnforcementsExclusionRulesForSkSLTests []
 

Function Documentation

◆ CurrentTestHarness()

TestHarness CurrentTestHarness ( )

Definition at line 108 of file skqp.cpp.

108 {
109 return TestHarness::kSkQP;
110}

◆ get_sksl_error_tests()

static std::vector< SkQP::SkSLErrorTest > get_sksl_error_tests ( SkQPAssetManager assetManager,
int  enforcedAndroidAPILevel 
)
static

Definition at line 70 of file skqp.cpp.

71 {
72 std::vector<SkQP::SkSLErrorTest> skslErrorTests;
73 auto iterateFn = [&](const char* directory, const char* extension) {
74 std::vector<std::string> paths = assetManager->iterateDir(directory, extension);
75 for (const std::string& path : paths) {
77 for (auto& exclusionEntry : sExclusionRulesForSkSLTests) {
78 if (std::regex_match(name.c_str(), exclusionEntry.first) &&
79 exclusionEntry.second.eval(enforcedAndroidAPILevel) ==
81 continue;
82 }
83 }
84 sk_sp<SkData> shaderText = GetResourceAsData(path.c_str());
85 if (!shaderText) {
86 continue;
87 }
88 skslErrorTests.push_back({
89 name.c_str(),
90 std::string(static_cast<const char*>(shaderText->data()), shaderText->size())
91 });
92 }
93 };
94
95 // Android only supports runtime shaders, not fragment shaders, color filters or blenders.
96 iterateFn("sksl/errors/", ".rts");
97 iterateFn("sksl/runtime_errors/", ".rts");
98
99 auto lt = [](const SkQP::SkSLErrorTest& a, const SkQP::SkSLErrorTest& b) {
100 return a.name < b.name;
101 };
102 std::sort(skslErrorTests.begin(), skslErrorTests.end(), lt);
103 return skslErrorTests;
104}
sk_sp< SkData > GetResourceAsData(const char *resource)
Definition: Resources.cpp:42
static std::vector< SkPDFIndirectReference > sort(const THashSet< SkPDFIndirectReference > &src)
const void * data() const
Definition: SkData.h:37
size_t size() const
Definition: SkData.h:30
static SkString Basename(const char *fullPath)
Definition: SkOSPath.cpp:23
virtual std::vector< std::string > iterateDir(const char *directory, const char *extension)=0
static bool b
struct MyStruct a[10]
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition: switches.h:57
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32
static const std::pair< std::regex, CtsEnforcement > sExclusionRulesForSkSLTests[]
Definition: skqp.cpp:65

◆ get_unit_tests()

static std::vector< SkQP::UnitTest > get_unit_tests ( int  enforcedAndroidAPILevel)
static

Definition at line 43 of file skqp.cpp.

43 {
44 std::vector<SkQP::UnitTest> unitTests;
46 const auto ctsMode = test.fCTSEnforcement.eval(enforcedAndroidAPILevel);
47 if (ctsMode != CtsEnforcement::RunMode::kSkip) {
49 "Non-GPU test was included in SkQP: %s\n", test.fName);
50 unitTests.push_back(&test);
51 }
52 }
53 auto lt = [](SkQP::UnitTest u, SkQP::UnitTest v) { return strcmp(u->fName, v->fName) < 0; };
54 std::sort(unitTests.begin(), unitTests.end(), lt);
55 return unitTests;
56}
#define SkASSERTF(cond, fmt,...)
Definition: SkAssert.h:117
const char * fName
Definition: Test.h:146

◆ write()

template<typename T >
void write ( SkWStream wStream,
const T text 
)
inline

Definition at line 188 of file skqp.cpp.

188 {
189 wStream->write(text.c_str(), text.size());
190}
virtual bool write(const void *buffer, size_t size)=0
std::u16string text

Variable Documentation

◆ kUnitTestReportPath

constexpr char kUnitTestReportPath[] = "unit_tests.txt"
staticconstexpr

Definition at line 40 of file skqp.cpp.

◆ sExclusionRulesForSkSLTests

const std::pair<std::regex, CtsEnforcement> sExclusionRulesForSkSLTests[]
static
Initial value:

SkSL error tests are used by CTS to verify that Android's RuntimeShader API fails when certain shader programs are compiled. Unlike unit tests these error tests are defined in resource files not source code. As such, we are unable to mark each test with a CtsEnforcement value. This list of exclusion rules excludes tests based on their file name so that we can have some form of control for which Android version an SkSL error test is expected to run.

Definition at line 65 of file skqp.cpp.