Flutter Engine
The Flutter Engine
Classes | Namespaces | Macros | Typedefs | Functions
Test.h File Reference
#include "include/core/SkString.h"
#include "include/core/SkTypes.h"
#include "include/private/base/SkNoncopyable.h"
#include "include/private/base/SkTArray.h"
#include "src/core/SkTraceEvent.h"
#include "tests/CtsEnforcement.h"
#include "tests/TestType.h"
#include "tools/Registry.h"
#include <atomic>
#include <cstdint>
#include <string>

Go to the source code of this file.

Classes

struct  skiatest::Failure
 
class  skiatest::Reporter
 
class  skiatest::ReporterContext
 
struct  skiatest::Test
 
class  skiatest::Timer
 

Namespaces

namespace  sk_gpu_test
 
namespace  skgpu
 
namespace  skgpu::graphite
 
namespace  skiatest
 
namespace  skiatest::graphite
 

Macros

#define REPORT_FAILURE(reporter, cond, message)    reporter->reportFailedWithContext(skiatest::Failure(__FILE__, __LINE__, cond, message))
 
#define REPORTER_ASSERT(r, cond, ...)
 
#define ERRORF(r, ...)
 
#define INFOF(REPORTER, ...)
 
#define DEF_CONDITIONAL_TEST(name, reporter, condition)
 
#define DEF_TEST(name, reporter)   DEF_CONDITIONAL_TEST(name, reporter, true)
 
#define DEF_TEST_DISABLED(name, reporter)   DEF_CONDITIONAL_TEST(name, reporter, false)
 
#define UNIX_ONLY_TEST   DEF_TEST_DISABLED
 
#define DEF_SERIAL_TEST(name, reporter)
 
#define DEF_GRAPHITE_TEST(name, reporter, ctsEnforcement)
 
#define DEF_CONDITIONAL_GRAPHITE_TEST_FOR_CONTEXTS( name, context_filter, reporter, graphite_ctx, test_ctx, opt_filter, cond, ctsEnforcement)
 
#define DEF_CONDITIONAL_GRAPHITE_TEST_FOR_ALL_CONTEXTS(name, reporter, graphite_ctx, test_ctx, cond, ctsEnforcement)
 
#define DEF_CONDITIONAL_GRAPHITE_TEST_FOR_RENDERING_CONTEXTS( name, reporter, graphite_context, test_context, cond, ctsEnforcement)
 
#define DEF_GRAPHITE_TEST_FOR_CONTEXTS(name, context_filter, reporter, graphite_ctx, test_ctx, ctsEnforcement)
 
#define DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS(name, reporter, graphite_ctx, ctsEnforcement)
 
#define DEF_GRAPHITE_TEST_FOR_RENDERING_CONTEXTS(name, reporter, graphite_context, ctsEnforcement)
 
#define DEF_GRAPHITE_TEST_FOR_VULKAN_CONTEXT(name, reporter, graphite_context, ctsEnforcement)
 
#define DEF_GRAPHITE_TEST_FOR_METAL_CONTEXT(name, reporter, graphite_context, test_context)
 
#define DEF_GRAPHITE_TEST_FOR_DAWN_CONTEXT(name, reporter, graphite_context, test_context)
 
#define DEF_GANESH_TEST(name, reporter, options, ctsEnforcement)
 
#define DEF_CONDITIONAL_GANESH_TEST_FOR_CONTEXTS( name, context_filter, reporter, context_info, options_filter, condition, ctsEnforcement)
 
#define DEF_CONDITIONAL_GANESH_TEST_FOR_ALL_CONTEXTS( name, reporter, context_info, condition, ctsEnforcement)
 
#define DEF_CONDITIONAL_GANESH_TEST_FOR_RENDERING_CONTEXTS( name, reporter, context_info, condition, ctsEnforcement)
 
#define DEF_GANESH_TEST_FOR_CONTEXTS( name, context_filter, reporter, context_info, options_filter, ctsEnforcement)
 
#define DEF_GANESH_TEST_FOR_ALL_CONTEXTS(name, reporter, context_info, ctsEnforcement)    DEF_GANESH_TEST_FOR_CONTEXTS(name, nullptr, reporter, context_info, nullptr, ctsEnforcement)
 
#define DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS(name, reporter, context_info, ctsEnforcement)
 
#define DEF_GANESH_TEST_FOR_ALL_GL_CONTEXTS(name, reporter, context_info, ctsEnforcement)
 
#define DEF_GANESH_TEST_FOR_GL_CONTEXT(name, reporter, context_info, ctsEnforcement)
 
#define DEF_GANESH_TEST_FOR_MOCK_CONTEXT(name, reporter, context_info)
 
#define DEF_GANESH_TEST_FOR_VULKAN_CONTEXT(name, reporter, context_info, ctsEnforcement)
 
#define DEF_GANESH_TEST_FOR_METAL_CONTEXT(name, reporter, context_info)
 
#define DEF_GANESH_TEST_FOR_D3D_CONTEXT(name, reporter, context_info)
 
#define DEF_GANESH_TEST_FOR_DAWN_CONTEXT(name, reporter, context_info)
 
#define REQUIRE_PDF_DOCUMENT(TEST_NAME, REPORTER)
 

Typedefs

using skiatest::CPUTestProc = void(*)(Reporter *)
 
using skiatest::GaneshTestProc = void(*)(Reporter *, const GrContextOptions &)
 
using skiatest::GaneshContextOptionsProc = void(*)(GrContextOptions *)
 
using skiatest::GraphiteTestProc = void(*)(Reporter *, const graphite::TestOptions &)
 
using skiatest::GraphiteContextOptionsProc = void(*)(skgpu::graphite::ContextOptions *)
 
using skiatest::TestRegistry = sk_tools::Registry< Test >
 
using skiatest::GpuContextType = nullptr_t
 
typedef void skiatest::GrContextTestFn(Reporter *, const sk_gpu_test::ContextInfo &)
 
typedef bool skiatest::ContextTypeFilterFn(GpuContextType)
 
using skiatest::graphite::GraphiteTestFn = void(Reporter *, skgpu::graphite::Context *, skiatest::graphite::GraphiteTestContext *)
 

Functions

SkString skiatest::GetTmpDir ()
 
void skiatest::RunWithGaneshTestContexts (GrContextTestFn *testFn, ContextTypeFilterFn *filter, Reporter *reporter, const GrContextOptions &options)
 
bool skiatest::IsGLContextType (GpuContextType)
 
bool skiatest::IsVulkanContextType (GpuContextType)
 
bool skiatest::IsMetalContextType (GpuContextType)
 
bool skiatest::IsDawnContextType (GpuContextType)
 
bool skiatest::IsDirect3DContextType (GpuContextType)
 
bool skiatest::IsMockContextType (GpuContextType)
 
void skiatest::graphite::RunWithGraphiteTestContexts (GraphiteTestFn *, ContextTypeFilterFn *filter, Reporter *, const TestOptions &)
 

Macro Definition Documentation

◆ DEF_CONDITIONAL_GANESH_TEST_FOR_ALL_CONTEXTS

#define DEF_CONDITIONAL_GANESH_TEST_FOR_ALL_CONTEXTS (   name,
  reporter,
  context_info,
  condition,
  ctsEnforcement 
)
Value:
name, nullptr, reporter, context_info, nullptr, condition, ctsEnforcement)
reporter
Definition: FontMgrTest.cpp:39
#define DEF_CONDITIONAL_GANESH_TEST_FOR_CONTEXTS( name, context_filter, reporter, context_info, options_filter, condition, ctsEnforcement)
Definition: Test.h:399
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32

Definition at line 411 of file Test.h.

◆ DEF_CONDITIONAL_GANESH_TEST_FOR_CONTEXTS

#define DEF_CONDITIONAL_GANESH_TEST_FOR_CONTEXTS (   name,
  context_filter,
  reporter,
  context_info,
  options_filter,
  condition,
  ctsEnforcement 
)
Value:
static void test_##name(skiatest::Reporter*, const sk_gpu_test::ContextInfo&); \
static void test_gpu_contexts_##name(skiatest::Reporter* reporter, \
} \
Test::MakeGanesh(#name, ctsEnforcement, test_gpu_contexts_##name, options_filter), \
condition); \
void test_##name(skiatest::Reporter* reporter, const sk_gpu_test::ContextInfo& context_info)
const char * options
sk_tools::Registry< Test > TestRegistry
Definition: Test.h:205
void RunWithGaneshTestContexts(GrContextTestFn *testFn, ContextTypeFilterFn *filter, Reporter *reporter, const GrContextOptions &options)

Definition at line 399 of file Test.h.

◆ DEF_CONDITIONAL_GANESH_TEST_FOR_RENDERING_CONTEXTS

#define DEF_CONDITIONAL_GANESH_TEST_FOR_RENDERING_CONTEXTS (   name,
  reporter,
  context_info,
  condition,
  ctsEnforcement 
)
Value:
context_info, \
nullptr, \
condition, \
ctsEnforcement)
bool IsRenderingContext(skgpu::ContextType type)
Definition: ContextType.cpp:88

Definition at line 416 of file Test.h.

◆ DEF_CONDITIONAL_GRAPHITE_TEST_FOR_ALL_CONTEXTS

#define DEF_CONDITIONAL_GRAPHITE_TEST_FOR_ALL_CONTEXTS (   name,
  reporter,
  graphite_ctx,
  test_ctx,
  cond,
  ctsEnforcement 
)
Value:
DEF_CONDITIONAL_GRAPHITE_TEST_FOR_CONTEXTS(name, nullptr, reporter, graphite_ctx, test_ctx, \
nullptr, cond, ctsEnforcement)
#define DEF_CONDITIONAL_GRAPHITE_TEST_FOR_CONTEXTS( name, context_filter, reporter, graphite_ctx, test_ctx, opt_filter, cond, ctsEnforcement)
Definition: Test.h:337

Definition at line 352 of file Test.h.

◆ DEF_CONDITIONAL_GRAPHITE_TEST_FOR_CONTEXTS

#define DEF_CONDITIONAL_GRAPHITE_TEST_FOR_CONTEXTS (   name,
  context_filter,
  reporter,
  graphite_ctx,
  test_ctx,
  opt_filter,
  cond,
  ctsEnforcement 
)
Value:
static void test_graphite_contexts_##name(skiatest::Reporter* _reporter, \
_reporter, options); \
} \
Test::MakeGraphite(#name, ctsEnforcement, test_graphite_contexts_##name, opt_filter), \
cond); \
sk_sp< SkSpecialImage > MakeGraphite(skgpu::graphite::Recorder *recorder, const SkIRect &subset, sk_sp< SkImage > image, const SkSurfaceProps &props)
void RunWithGraphiteTestContexts(GraphiteTestFn *, ContextTypeFilterFn *filter, Reporter *, const TestOptions &)

Definition at line 337 of file Test.h.

◆ DEF_CONDITIONAL_GRAPHITE_TEST_FOR_RENDERING_CONTEXTS

#define DEF_CONDITIONAL_GRAPHITE_TEST_FOR_RENDERING_CONTEXTS (   name,
  reporter,
  graphite_context,
  test_context,
  cond,
  ctsEnforcement 
)
Value:
graphite_context, \
test_context, \
nullptr, \
cond, \
ctsEnforcement)

Definition at line 357 of file Test.h.

◆ DEF_CONDITIONAL_TEST

#define DEF_CONDITIONAL_TEST (   name,
  reporter,
  condition 
)
Value:
static void test_##name(skiatest::Reporter*); \
skiatest::TestRegistry name##TestRegistry(Test::MakeCPU(#name, test_##name), condition); \

Definition at line 307 of file Test.h.

◆ DEF_GANESH_TEST

#define DEF_GANESH_TEST (   name,
  reporter,
  options,
  ctsEnforcement 
)
Value:
static void test_##name(skiatest::Reporter*, const GrContextOptions&); \
Test::MakeGanesh(#name, ctsEnforcement, test_##name, nullptr)); \

Definition at line 393 of file Test.h.

◆ DEF_GANESH_TEST_FOR_ALL_CONTEXTS

#define DEF_GANESH_TEST_FOR_ALL_CONTEXTS (   name,
  reporter,
  context_info,
  ctsEnforcement 
)     DEF_GANESH_TEST_FOR_CONTEXTS(name, nullptr, reporter, context_info, nullptr, ctsEnforcement)

Definition at line 431 of file Test.h.

◆ DEF_GANESH_TEST_FOR_ALL_GL_CONTEXTS

#define DEF_GANESH_TEST_FOR_ALL_GL_CONTEXTS (   name,
  reporter,
  context_info,
  ctsEnforcement 
)
Value:
name, skiatest::IsGLContextType, reporter, context_info, nullptr, ctsEnforcement)
#define DEF_GANESH_TEST_FOR_CONTEXTS( name, context_filter, reporter, context_info, options_filter, ctsEnforcement)
Definition: Test.h:426
bool IsGLContextType(skgpu::ContextType type)

Definition at line 438 of file Test.h.

◆ DEF_GANESH_TEST_FOR_CONTEXTS

#define DEF_GANESH_TEST_FOR_CONTEXTS (   name,
  context_filter,
  reporter,
  context_info,
  options_filter,
  ctsEnforcement 
)
Value:
name, context_filter, reporter, context_info, options_filter, true, ctsEnforcement)

Definition at line 426 of file Test.h.

◆ DEF_GANESH_TEST_FOR_D3D_CONTEXT

#define DEF_GANESH_TEST_FOR_D3D_CONTEXT (   name,
  reporter,
  context_info 
)
Value:
context_info, \
nullptr, \
bool IsDirect3DContextType(skgpu::ContextType type)

Definition at line 469 of file Test.h.

◆ DEF_GANESH_TEST_FOR_DAWN_CONTEXT

#define DEF_GANESH_TEST_FOR_DAWN_CONTEXT (   name,
  reporter,
  context_info 
)
Value:
context_info, \
nullptr, \
bool IsDawnContextType(skgpu::ContextType type)

Definition at line 477 of file Test.h.

◆ DEF_GANESH_TEST_FOR_GL_CONTEXT

#define DEF_GANESH_TEST_FOR_GL_CONTEXT (   name,
  reporter,
  context_info,
  ctsEnforcement 
)
Value:
context_info, \
nullptr, \
ctsEnforcement)

Definition at line 442 of file Test.h.

◆ DEF_GANESH_TEST_FOR_METAL_CONTEXT

#define DEF_GANESH_TEST_FOR_METAL_CONTEXT (   name,
  reporter,
  context_info 
)
Value:
context_info, \
nullptr, \
bool IsMetalContextType(skgpu::ContextType type)

Definition at line 462 of file Test.h.

◆ DEF_GANESH_TEST_FOR_MOCK_CONTEXT

#define DEF_GANESH_TEST_FOR_MOCK_CONTEXT (   name,
  reporter,
  context_info 
)
Value:
context_info, \
nullptr, \
bool IsMockContextType(skgpu::ContextType type)

Definition at line 450 of file Test.h.

◆ DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS

#define DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS (   name,
  reporter,
  context_info,
  ctsEnforcement 
)
Value:
name, skgpu::IsRenderingContext, reporter, context_info, nullptr, ctsEnforcement)

Definition at line 434 of file Test.h.

◆ DEF_GANESH_TEST_FOR_VULKAN_CONTEXT

#define DEF_GANESH_TEST_FOR_VULKAN_CONTEXT (   name,
  reporter,
  context_info,
  ctsEnforcement 
)
Value:
name, &skiatest::IsVulkanContextType, reporter, context_info, nullptr, ctsEnforcement)
bool IsVulkanContextType(skgpu::ContextType type)

Definition at line 458 of file Test.h.

◆ DEF_GRAPHITE_TEST

#define DEF_GRAPHITE_TEST (   name,
  reporter,
  ctsEnforcement 
)
Value:
static void test_##name(skiatest::Reporter*); \
static void test_graphite_##name(skiatest::Reporter* reporter, \
test_##name(reporter); \
} \
test_graphite_##name)); \

Definition at line 327 of file Test.h.

◆ DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS

#define DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS (   name,
  reporter,
  graphite_ctx,
  ctsEnforcement 
)
Value:
/*anonymous test_ctx*/, true, ctsEnforcement)
#define DEF_CONDITIONAL_GRAPHITE_TEST_FOR_ALL_CONTEXTS(name, reporter, graphite_ctx, test_ctx, cond, ctsEnforcement)
Definition: Test.h:352

Definition at line 373 of file Test.h.

◆ DEF_GRAPHITE_TEST_FOR_CONTEXTS

#define DEF_GRAPHITE_TEST_FOR_CONTEXTS (   name,
  context_filter,
  reporter,
  graphite_ctx,
  test_ctx,
  ctsEnforcement 
)
Value:
DEF_CONDITIONAL_GRAPHITE_TEST_FOR_CONTEXTS(name, context_filter, reporter, graphite_ctx, \
test_ctx, nullptr, true, ctsEnforcement)

Definition at line 368 of file Test.h.

◆ DEF_GRAPHITE_TEST_FOR_DAWN_CONTEXT

#define DEF_GRAPHITE_TEST_FOR_DAWN_CONTEXT (   name,
  reporter,
  graphite_context,
  test_context 
)
Value:
test_context, CtsEnforcement::kNever)
#define DEF_GRAPHITE_TEST_FOR_CONTEXTS(name, context_filter, reporter, graphite_ctx, test_ctx, ctsEnforcement)
Definition: Test.h:368

Definition at line 389 of file Test.h.

◆ DEF_GRAPHITE_TEST_FOR_METAL_CONTEXT

#define DEF_GRAPHITE_TEST_FOR_METAL_CONTEXT (   name,
  reporter,
  graphite_context,
  test_context 
)
Value:

Definition at line 385 of file Test.h.

◆ DEF_GRAPHITE_TEST_FOR_RENDERING_CONTEXTS

#define DEF_GRAPHITE_TEST_FOR_RENDERING_CONTEXTS (   name,
  reporter,
  graphite_context,
  ctsEnforcement 
)
Value:
name, reporter, graphite_context, /*anonymous test_ctx*/, true, ctsEnforcement)
#define DEF_CONDITIONAL_GRAPHITE_TEST_FOR_RENDERING_CONTEXTS( name, reporter, graphite_context, test_context, cond, ctsEnforcement)
Definition: Test.h:357

Definition at line 377 of file Test.h.

◆ DEF_GRAPHITE_TEST_FOR_VULKAN_CONTEXT

#define DEF_GRAPHITE_TEST_FOR_VULKAN_CONTEXT (   name,
  reporter,
  graphite_context,
  ctsEnforcement 
)
Value:
graphite_context, /*anonymous test_ctx*/, ctsEnforcement)

Definition at line 381 of file Test.h.

◆ DEF_SERIAL_TEST

#define DEF_SERIAL_TEST (   name,
  reporter 
)
Value:
static void test_##name(skiatest::Reporter*); \
skiatest::TestRegistry name##TestRegistry(Test::MakeCPUSerial(#name, test_##name)); \

Definition at line 322 of file Test.h.

◆ DEF_TEST

#define DEF_TEST (   name,
  reporter 
)    DEF_CONDITIONAL_TEST(name, reporter, true)

Definition at line 312 of file Test.h.

◆ DEF_TEST_DISABLED

#define DEF_TEST_DISABLED (   name,
  reporter 
)    DEF_CONDITIONAL_TEST(name, reporter, false)

Definition at line 314 of file Test.h.

◆ ERRORF

#define ERRORF (   r,
  ... 
)
Value:
do { \
REPORT_FAILURE(r, "", SkStringPrintf(__VA_ARGS__)); \
} while (0)
SK_API SkString SkStringPrintf(const char *format,...) SK_PRINTF_LIKE(1
Creates a new string and writes into it using a printf()-style format.

Definition at line 293 of file Test.h.

◆ INFOF

#define INFOF (   REPORTER,
  ... 
)
Value:
do { \
if ((REPORTER)->verbose()) { \
SkDebugf(__VA_ARGS__); \
} \
} while (0)

Definition at line 298 of file Test.h.

◆ REPORT_FAILURE

#define REPORT_FAILURE (   reporter,
  cond,
  message 
)     reporter->reportFailedWithContext(skiatest::Failure(__FILE__, __LINE__, cond, message))

Definition at line 90 of file Test.h.

◆ REPORTER_ASSERT

#define REPORTER_ASSERT (   r,
  cond,
  ... 
)
Value:
do { \
if (!(cond)) { \
REPORT_FAILURE(r, #cond, SkStringPrintf(__VA_ARGS__)); \
} \
} while (0)

Definition at line 286 of file Test.h.

◆ REQUIRE_PDF_DOCUMENT

#define REQUIRE_PDF_DOCUMENT (   TEST_NAME,
  REPORTER 
)
Value:
do { \
SkNullWStream testStream; \
auto testDoc = SkPDF::MakeDocument(&testStream); \
if (!testDoc) { \
INFOF(REPORTER, "PDF disabled; %s test skipped.", #TEST_NAME); \
return; \
} \
} while (false)
SK_API sk_sp< SkDocument > MakeDocument(SkWStream *stream, const Metadata &metadata)

Definition at line 485 of file Test.h.

◆ UNIX_ONLY_TEST

#define UNIX_ONLY_TEST   DEF_TEST_DISABLED

Definition at line 319 of file Test.h.