Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
TestTest.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2015 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
11struct GrContextOptions;
12
13// This is an example of a normal test. It should not require any GPU backends, that is, it is a
14// CPU test.
18
19// This is an example of a conditional test with a true condition.
20DEF_CONDITIONAL_TEST(TestTrueCondition, reporter, 1 == 1) {
22}
23
24// This is an example of a conditional test with a false condition.
25DEF_CONDITIONAL_TEST(TestFalseCondition, reporter, 1 == 0) {
26 ERRORF(reporter, "DEF_CONDITIONAL_TEST executed a test with a false condition");
27}
28
29// This is an example of a GPU test that runs if any Ganesh backend is compiled in. The test itself
30// is responsible for making the relevant GrDirectContext (e.g. using
31// sk_gpu_test::GrContextFactory).
35
36// This is an example of a GPU test that tests a property that should work for all Ganesh contexts.
37// Note: Some of the contexts might not produce a rendering output.
40 REPORTER_ASSERT(reporter, ctxInfo.directContext());
41}
42
43// This is an example of a GPU test that tests a property that should work for all Ganesh contexts
44// that produce a rendering output.
47 ctxInfo,
50 REPORTER_ASSERT(reporter, ctxInfo.directContext());
51}
52
53// This is an example of a GPU test that tests a property that uses the mock Ganesh context.
54// It should be used if the test tests some behavior that is mocked with the mock context.
55DEF_GANESH_TEST_FOR_MOCK_CONTEXT(TestMockContext, reporter, ctxInfo) {
57 REPORTER_ASSERT(reporter, ctxInfo.directContext());
58}
59
60// Conditional variant of DEF_GANESH_TEST_FOR_ALL_CONTEXTS. It will only execute if the provided
61// condition parameter is true.
63 TestGpuAllContextsWithTrueCondition, reporter, ctxInfo, true, CtsEnforcement::kNever) {
65 REPORTER_ASSERT(reporter, ctxInfo.directContext());
66}
67
69 TestGpuAllContextsWithFalseCondition, reporter, ctxInfo, false, CtsEnforcement::kNever) {
70 ERRORF(reporter, "DEF_CONDITIONAL_GANESH_TEST_FOR_ALL_CONTEXTS ran with a false condition");
71}
72
73// Conditional variant of DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS. It will only execute if the
74// provided condition parameter is true.
75DEF_CONDITIONAL_GANESH_TEST_FOR_RENDERING_CONTEXTS(TestGpuRenderingContextsWithTrueCondition,
77 ctxInfo,
78 true,
81 REPORTER_ASSERT(reporter, ctxInfo.directContext());
82}
83
84DEF_CONDITIONAL_GANESH_TEST_FOR_RENDERING_CONTEXTS(TestGpuRenderingContextsWithFalseCondition,
86 ctxInfo,
87 false,
90 "DEF_CONDITIONAL_GANESH_TEST_FOR_RENDERING_CONTEXTS ran "
91 "with a false condition");
92}
93
reporter
float e1
#define DEF_CONDITIONAL_TEST(name, reporter, condition)
Definition Test.h:307
#define DEF_CONDITIONAL_GANESH_TEST_FOR_RENDERING_CONTEXTS( name, reporter, context_info, condition, ctsEnforcement)
Definition Test.h:416
#define DEF_GANESH_TEST(name, reporter, options, ctsEnforcement)
Definition Test.h:393
#define DEF_GANESH_TEST_FOR_MOCK_CONTEXT(name, reporter, context_info)
Definition Test.h:450
#define DEF_TEST(name, reporter)
Definition Test.h:312
#define REPORTER_ASSERT(r, cond,...)
Definition Test.h:286
#define ERRORF(r,...)
Definition Test.h:293
#define DEF_CONDITIONAL_GANESH_TEST_FOR_ALL_CONTEXTS( name, reporter, context_info, condition, ctsEnforcement)
Definition Test.h:411
#define DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS(name, reporter, context_info, ctsEnforcement)
Definition Test.h:434
#define DEF_GANESH_TEST_FOR_ALL_CONTEXTS(name, reporter, context_info, ctsEnforcement)
Definition Test.h:431
constexpr CtsEnforcement & withWorkarounds(ApiLevel workaroundVersion)