7#ifndef skiatest_Test_DEFINED
8#define skiatest_Test_DEFINED
19#if defined(SK_GANESH) || defined(SK_GRAPHITE)
42class GraphiteTestContext;
65 virtual void*
stats()
const {
return nullptr; }
90#define REPORT_FAILURE(reporter, cond, message) \
91 reporter->reportFailedWithContext(skiatest::Failure(__FILE__, __LINE__, cond, message))
122 proc,
nullptr,
nullptr,
nullptr,
nullptr};
127 proc,
nullptr,
nullptr,
nullptr,
nullptr};
135 nullptr, proc,
nullptr, optionsProc,
nullptr};
143 nullptr,
nullptr, proc,
nullptr, optionsProc};
157 (*fGaneshContextOptionsProc)(
options);
163 (*fGraphiteContextOptionsProc)(
options);
207#if defined(SK_GANESH)
286#define REPORTER_ASSERT(r, cond, ...) \
289 REPORT_FAILURE(r, #cond, SkStringPrintf(__VA_ARGS__)); \
293#define ERRORF(r, ...) \
295 REPORT_FAILURE(r, "", SkStringPrintf(__VA_ARGS__)); \
298#define INFOF(REPORTER, ...) \
300 if ((REPORTER)->verbose()) { \
301 SkDebugf(__VA_ARGS__); \
307#define DEF_CONDITIONAL_TEST(name, reporter, condition) \
308 static void test_##name(skiatest::Reporter*); \
309 skiatest::TestRegistry name##TestRegistry(Test::MakeCPU(#name, test_##name), condition); \
310 void test_##name(skiatest::Reporter* reporter)
312#define DEF_TEST(name, reporter) DEF_CONDITIONAL_TEST(name, reporter, true)
314#define DEF_TEST_DISABLED(name, reporter) DEF_CONDITIONAL_TEST(name, reporter, false)
316#ifdef SK_BUILD_FOR_UNIX
317 #define UNIX_ONLY_TEST DEF_TEST
319 #define UNIX_ONLY_TEST DEF_TEST_DISABLED
322#define DEF_SERIAL_TEST(name, reporter) \
323 static void test_##name(skiatest::Reporter*); \
324 skiatest::TestRegistry name##TestRegistry(Test::MakeCPUSerial(#name, test_##name)); \
325 void test_##name(skiatest::Reporter* reporter)
327#define DEF_GRAPHITE_TEST(name, reporter, ctsEnforcement) \
328 static void test_##name(skiatest::Reporter*); \
329 static void test_graphite_##name(skiatest::Reporter* reporter, \
330 const skiatest::graphite::TestOptions&) { \
331 test_##name(reporter); \
333 skiatest::TestRegistry name##TestRegistry(Test::MakeGraphite(#name, ctsEnforcement, \
334 test_graphite_##name)); \
335 void test_##name(skiatest::Reporter* reporter)
337#define DEF_CONDITIONAL_GRAPHITE_TEST_FOR_CONTEXTS( \
338 name, context_filter, reporter, graphite_ctx, test_ctx, opt_filter, cond, ctsEnforcement) \
339 static void test_##name(skiatest::Reporter*, skgpu::graphite::Context*, \
340 skiatest::graphite::GraphiteTestContext*); \
341 static void test_graphite_contexts_##name(skiatest::Reporter* _reporter, \
342 const skiatest::graphite::TestOptions& options) { \
343 skiatest::graphite::RunWithGraphiteTestContexts(test_##name, context_filter, \
344 _reporter, options); \
346 skiatest::TestRegistry name##TestRegistry( \
347 Test::MakeGraphite(#name, ctsEnforcement, test_graphite_contexts_##name, opt_filter), \
349 void test_##name(skiatest::Reporter* reporter, skgpu::graphite::Context* graphite_ctx, \
350 skiatest::graphite::GraphiteTestContext* test_ctx)
352#define DEF_CONDITIONAL_GRAPHITE_TEST_FOR_ALL_CONTEXTS(name, reporter, graphite_ctx, \
353 test_ctx, cond, ctsEnforcement) \
354 DEF_CONDITIONAL_GRAPHITE_TEST_FOR_CONTEXTS(name, nullptr, reporter, graphite_ctx, test_ctx, \
355 nullptr, cond, ctsEnforcement)
357#define DEF_CONDITIONAL_GRAPHITE_TEST_FOR_RENDERING_CONTEXTS( \
358 name, reporter, graphite_context, test_context, cond, ctsEnforcement) \
359 DEF_CONDITIONAL_GRAPHITE_TEST_FOR_CONTEXTS(name, \
360 skgpu::IsRenderingContext, \
368#define DEF_GRAPHITE_TEST_FOR_CONTEXTS(name, context_filter, reporter, graphite_ctx, \
369 test_ctx, ctsEnforcement) \
370 DEF_CONDITIONAL_GRAPHITE_TEST_FOR_CONTEXTS(name, context_filter, reporter, graphite_ctx, \
371 test_ctx, nullptr, true, ctsEnforcement)
373#define DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS(name, reporter, graphite_ctx, ctsEnforcement) \
374 DEF_CONDITIONAL_GRAPHITE_TEST_FOR_ALL_CONTEXTS(name, reporter, graphite_ctx, \
375 , true, ctsEnforcement)
377#define DEF_GRAPHITE_TEST_FOR_RENDERING_CONTEXTS(name, reporter, graphite_context, ctsEnforcement) \
378 DEF_CONDITIONAL_GRAPHITE_TEST_FOR_RENDERING_CONTEXTS( \
379 name, reporter, graphite_context, , true, ctsEnforcement)
381#define DEF_GRAPHITE_TEST_FOR_VULKAN_CONTEXT(name, reporter, graphite_context, ctsEnforcement) \
382 DEF_GRAPHITE_TEST_FOR_CONTEXTS(name, skiatest::IsVulkanContextType, reporter, \
383 graphite_context, , ctsEnforcement)
385#define DEF_GRAPHITE_TEST_FOR_METAL_CONTEXT(name, reporter, graphite_context, test_context) \
386 DEF_GRAPHITE_TEST_FOR_CONTEXTS(name, skiatest::IsMetalContextType, reporter, graphite_context, \
387 test_context, CtsEnforcement::kNever)
389#define DEF_GRAPHITE_TEST_FOR_DAWN_CONTEXT(name, reporter, graphite_context, test_context) \
390 DEF_GRAPHITE_TEST_FOR_CONTEXTS(name, skiatest::IsDawnContextType, reporter, graphite_context, \
391 test_context, CtsEnforcement::kNever)
393#define DEF_GANESH_TEST(name, reporter, options, ctsEnforcement) \
394 static void test_##name(skiatest::Reporter*, const GrContextOptions&); \
395 skiatest::TestRegistry name##TestRegistry( \
396 Test::MakeGanesh(#name, ctsEnforcement, test_##name, nullptr)); \
397 void test_##name(skiatest::Reporter* reporter, const GrContextOptions& options)
399#define DEF_CONDITIONAL_GANESH_TEST_FOR_CONTEXTS( \
400 name, context_filter, reporter, context_info, options_filter, condition, ctsEnforcement) \
401 static void test_##name(skiatest::Reporter*, const sk_gpu_test::ContextInfo&); \
402 static void test_gpu_contexts_##name(skiatest::Reporter* reporter, \
403 const GrContextOptions& options) { \
404 skiatest::RunWithGaneshTestContexts(test_##name, context_filter, reporter, options); \
406 skiatest::TestRegistry name##TestRegistry( \
407 Test::MakeGanesh(#name, ctsEnforcement, test_gpu_contexts_##name, options_filter), \
409 void test_##name(skiatest::Reporter* reporter, const sk_gpu_test::ContextInfo& context_info)
411#define DEF_CONDITIONAL_GANESH_TEST_FOR_ALL_CONTEXTS( \
412 name, reporter, context_info, condition, ctsEnforcement) \
413 DEF_CONDITIONAL_GANESH_TEST_FOR_CONTEXTS( \
414 name, nullptr, reporter, context_info, nullptr, condition, ctsEnforcement)
416#define DEF_CONDITIONAL_GANESH_TEST_FOR_RENDERING_CONTEXTS( \
417 name, reporter, context_info, condition, ctsEnforcement) \
418 DEF_CONDITIONAL_GANESH_TEST_FOR_CONTEXTS(name, \
419 skgpu::IsRenderingContext, \
426#define DEF_GANESH_TEST_FOR_CONTEXTS( \
427 name, context_filter, reporter, context_info, options_filter, ctsEnforcement) \
428 DEF_CONDITIONAL_GANESH_TEST_FOR_CONTEXTS( \
429 name, context_filter, reporter, context_info, options_filter, true, ctsEnforcement)
431#define DEF_GANESH_TEST_FOR_ALL_CONTEXTS(name, reporter, context_info, ctsEnforcement) \
432 DEF_GANESH_TEST_FOR_CONTEXTS(name, nullptr, reporter, context_info, nullptr, ctsEnforcement)
434#define DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS(name, reporter, context_info, ctsEnforcement) \
435 DEF_GANESH_TEST_FOR_CONTEXTS( \
436 name, skgpu::IsRenderingContext, reporter, context_info, nullptr, ctsEnforcement)
438#define DEF_GANESH_TEST_FOR_ALL_GL_CONTEXTS(name, reporter, context_info, ctsEnforcement) \
439 DEF_GANESH_TEST_FOR_CONTEXTS( \
440 name, skiatest::IsGLContextType, reporter, context_info, nullptr, ctsEnforcement)
442#define DEF_GANESH_TEST_FOR_GL_CONTEXT(name, reporter, context_info, ctsEnforcement) \
443 DEF_GANESH_TEST_FOR_CONTEXTS(name, \
444 &skiatest::IsGLContextType, \
450#define DEF_GANESH_TEST_FOR_MOCK_CONTEXT(name, reporter, context_info) \
451 DEF_GANESH_TEST_FOR_CONTEXTS(name, \
452 &skiatest::IsMockContextType, \
456 CtsEnforcement::kNever)
458#define DEF_GANESH_TEST_FOR_VULKAN_CONTEXT(name, reporter, context_info, ctsEnforcement) \
459 DEF_GANESH_TEST_FOR_CONTEXTS( \
460 name, &skiatest::IsVulkanContextType, reporter, context_info, nullptr, ctsEnforcement)
462#define DEF_GANESH_TEST_FOR_METAL_CONTEXT(name, reporter, context_info) \
463 DEF_GANESH_TEST_FOR_CONTEXTS(name, \
464 &skiatest::IsMetalContextType, \
468 CtsEnforcement::kNever)
469#define DEF_GANESH_TEST_FOR_D3D_CONTEXT(name, reporter, context_info) \
470 DEF_GANESH_TEST_FOR_CONTEXTS(name, \
471 &skiatest::IsDirect3DContextType, \
475 CtsEnforcement::kNever)
477#define DEF_GANESH_TEST_FOR_DAWN_CONTEXT(name, reporter, context_info) \
478 DEF_GANESH_TEST_FOR_CONTEXTS(name, \
479 &skiatest::IsDawnContextType, \
483 CtsEnforcement::kNever)
485#define REQUIRE_PDF_DOCUMENT(TEST_NAME, REPORTER) \
487 SkNullWStream testStream; \
488 auto testDoc = SkPDF::MakeDocument(&testStream); \
490 INFOF(REPORTER, "PDF disabled; %s test skipped.", #TEST_NAME); \
ReporterContext(Reporter *reporter, const SkString &message)
ReporterContext(Reporter *reporter, const std::string &message)
void push(const SkString &message)
void reportFailedWithContext(const skiatest::Failure &)
virtual void bumpTestCount()
virtual void reportFailed(const skiatest::Failure &)=0
virtual bool verbose() const
void push(const std::string &message)
virtual bool allowExtendedTest() const
virtual void * stats() const
SkMSec elapsedMsInt() const
DEF_SWITCHES_START aot vmservice shared library name
void(Reporter *, skgpu::graphite::Context *, skiatest::graphite::GraphiteTestContext *) GraphiteTestFn
void RunWithGraphiteTestContexts(GraphiteTestFn *, ContextTypeFilterFn *filter, Reporter *, const TestOptions &)
void(*)(Reporter *, const graphite::TestOptions &) GraphiteTestProc
void(*)(Reporter *, const GrContextOptions &) GaneshTestProc
void RunWithGaneshTestContexts(GrContextTestFn *testFn, ContextTypeFilterFn *filter, Reporter *reporter, const GrContextOptions &options)
bool IsMetalContextType(skgpu::ContextType type)
void(*)(skgpu::graphite::ContextOptions *) GraphiteContextOptionsProc
void(*)(GrContextOptions *) GaneshContextOptionsProc
bool IsGLContextType(skgpu::ContextType type)
bool ContextTypeFilterFn(GpuContextType)
bool IsMockContextType(skgpu::ContextType type)
bool IsDirect3DContextType(skgpu::ContextType type)
void(*)(Reporter *) CPUTestProc
void GrContextTestFn(Reporter *, const sk_gpu_test::ContextInfo &)
bool IsDawnContextType(skgpu::ContextType type)
bool IsVulkanContextType(skgpu::ContextType type)
Failure(const char *f, int l, const char *c, const SkString &m)
SkString toString() const
GraphiteContextOptionsProc fGraphiteContextOptionsProc
GraphiteTestProc fGraphiteProc
GaneshContextOptionsProc fGaneshContextOptionsProc
CtsEnforcement fCTSEnforcement
static Test MakeCPU(const char *name, CPUTestProc proc)
GaneshTestProc fGaneshProc
static Test MakeGraphite(const char *name, CtsEnforcement ctsEnforcement, GraphiteTestProc proc, GraphiteContextOptionsProc optionsProc=nullptr)
void ganesh(skiatest::Reporter *r, const GrContextOptions &options) const
static Test MakeCPUSerial(const char *name, CPUTestProc proc)
void modifyGrContextOptions(GrContextOptions *options)
void cpu(skiatest::Reporter *r) const
void graphite(skiatest::Reporter *r, const graphite::TestOptions &options) const
void modifyGraphiteContextOptions(skgpu::graphite::ContextOptions *options)
static Test MakeGanesh(const char *name, CtsEnforcement ctsEnforcement, GaneshTestProc proc, GaneshContextOptionsProc optionsProc=nullptr)
#define TRACE_EVENT1(category_group, name, arg1_name, arg1_val)