Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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)
 

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)
 

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
#define DEF_CONDITIONAL_GANESH_TEST_FOR_CONTEXTS( name, context_filter, reporter, context_info, options_filter, condition, ctsEnforcement)
Definition Test.h:399
const char * name
Definition fuchsia.cc:50

Definition at line 411 of file Test.h.

485 { \
486 SkNullWStream testStream; \
487 auto testDoc = SkPDF::MakeDocument(&testStream); \
488 if (!testDoc) { \
489 INFOF(REPORTER, "PDF disabled; %s test skipped.", #TEST_NAME); \
490 return; \
491 } \
492 } while (false)
493
494#endif
SK_API sk_sp< SkDocument > MakeDocument(SkWStream *stream, const Metadata &metadata)

◆ 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, \
skiatest::RunWithGaneshTestContexts(test_##name, context_filter, reporter, options); \
} \
skiatest::TestRegistry name##TestRegistry( \
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
static Test MakeGanesh(const char *name, CtsEnforcement ctsEnforcement, GaneshTestProc proc, GaneshContextOptionsProc optionsProc=nullptr)
Definition Test.h:130

Definition at line 399 of file Test.h.

403 { \
404 skiatest::RunWithGaneshTestContexts(test_##name, context_filter, reporter, options); \
405 } \
407 Test::MakeGanesh(#name, ctsEnforcement, test_gpu_contexts_##name, options_filter), \
408 condition); \
409 void test_##name(skiatest::Reporter* reporter, const sk_gpu_test::ContextInfo& context_info)
sk_tools::Registry< Test > TestRegistry
Definition Test.h:205

◆ 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 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, \
skiatest::graphite::RunWithGraphiteTestContexts(test_##name, context_filter, \
_reporter, options); \
} \
skiatest::TestRegistry name##TestRegistry( \
Test::MakeGraphite(#name, ctsEnforcement, test_graphite_contexts_##name, opt_filter), \
cond); \
static Test MakeGraphite(const char *name, CtsEnforcement ctsEnforcement, GraphiteTestProc proc, GraphiteContextOptionsProc optionsProc=nullptr)
Definition Test.h:138

Definition at line 337 of file Test.h.

342 { \
343 skiatest::graphite::RunWithGraphiteTestContexts(test_##name, context_filter, \
344 _reporter, options); \
345 } \
347 Test::MakeGraphite(#name, ctsEnforcement, test_graphite_contexts_##name, opt_filter), \
348 cond); \
349 void test_##name(skiatest::Reporter* reporter, skgpu::graphite::Context* graphite_ctx, \

◆ 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); \
static Test MakeCPU(const char *name, CPUTestProc proc)
Definition Test.h:120

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&); \
skiatest::TestRegistry name##TestRegistry( \
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); \
} \
skiatest::TestRegistry name##TestRegistry(Test::MakeGraphite(#name, ctsEnforcement, \
test_graphite_##name)); \

Definition at line 327 of file Test.h.

330 { \
331 test_##name(reporter); \
332 } \
334 test_graphite_##name)); \
335 void test_##name(skiatest::Reporter* reporter)

◆ 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*); \
static Test MakeCPUSerial(const char *name, CPUTestProc proc)
Definition Test.h:125

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 static SkString SkStringPrintf()
Definition SkString.h:287

Definition at line 293 of file Test.h.

294 { \
295 REPORT_FAILURE(r, "", SkStringPrintf(__VA_ARGS__)); \
296 } while (0)

◆ INFOF

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

Definition at line 298 of file Test.h.

299 { \
300 if ((REPORTER)->verbose()) { \
301 SkDebugf(__VA_ARGS__); \
302 } \
303 } while (0)

◆ 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.

287 { \
288 if (!(cond)) { \
289 REPORT_FAILURE(r, #cond, SkStringPrintf(__VA_ARGS__)); \
290 } \
291 } while (0)

◆ 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)

Definition at line 485 of file Test.h.

486 { \
487 SkNullWStream testStream; \
488 auto testDoc = SkPDF::MakeDocument(&testStream); \
489 if (!testDoc) { \
490 INFOF(REPORTER, "PDF disabled; %s test skipped.", #TEST_NAME); \
491 return; \
492 } \
493 } while (false)

◆ UNIX_ONLY_TEST

#define UNIX_ONLY_TEST   DEF_TEST_DISABLED

Definition at line 319 of file Test.h.