• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
8 #include "tests/Test.h"
9 
10 #include "include/gpu/GrDirectContext.h"
11 #include "tools/gpu/gl/GLTestContext.h"
12 
13 // This is an example of a normal test.
DEF_TEST(TestNormal,reporter)14 DEF_TEST(TestNormal, reporter) {
15     REPORTER_ASSERT(reporter, reporter);
16 }
17 
18 // This is an example of a conditional test with a true condition.
19 DEF_CONDITIONAL_TEST(TestTrueCondition, reporter, 1 == 1) {
20     REPORTER_ASSERT(reporter, reporter);
21 }
22 
23 // This is an example of a conditional test with a false condition.
24 DEF_CONDITIONAL_TEST(TestFalseCondition, reporter, 1 == 0) {
25     ERRORF(reporter, "DEF_CONDITIONAL_TEST executed a test with a false condition");
26 }
27 
28 // This is an example of a GPU test that uses GrContextOptions to do the test.
DEF_GPUTEST(TestGpuFactory,reporter,factory)29 DEF_GPUTEST(TestGpuFactory, reporter, factory) {
30     REPORTER_ASSERT(reporter, reporter);
31 }
32 
33 // This is an example of a GPU test that tests a property that should work for all GPU contexts.
34 // Note: Some of the contexts might not produce a rendering output.
DEF_GPUTEST_FOR_ALL_CONTEXTS(TestGpuAllContexts,reporter,ctxInfo)35 DEF_GPUTEST_FOR_ALL_CONTEXTS(TestGpuAllContexts, reporter, ctxInfo) {
36     REPORTER_ASSERT(reporter, reporter);
37     REPORTER_ASSERT(reporter, ctxInfo.directContext());
38 }
39 
40 // This is an example of a GPU test that tests a property that should work for all GPU contexts that
41 // produce a rendering output.
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(TestGpuRenderingContexts,reporter,ctxInfo)42 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(TestGpuRenderingContexts, reporter, ctxInfo) {
43     REPORTER_ASSERT(reporter, reporter);
44     REPORTER_ASSERT(reporter, ctxInfo.directContext());
45 }
46 
47 // This is an example of a GPU test that tests a property that uses the mock context.  It should
48 // be used if the test tests some behavior that is mocked with the mock context.
DEF_GPUTEST_FOR_MOCK_CONTEXT(TestMockContext,reporter,ctxInfo)49 DEF_GPUTEST_FOR_MOCK_CONTEXT(TestMockContext, reporter, ctxInfo) {
50     REPORTER_ASSERT(reporter, reporter);
51     REPORTER_ASSERT(reporter, ctxInfo.directContext());
52 }
53 
54 // Conditional GPU tests will only execute if the provided condition parameter is true.
DEF_CONDITIONAL_GPUTEST_FOR_ALL_CONTEXTS(TestGpuAllContextsWithTrueCondition,reporter,ctxInfo,true)55 DEF_CONDITIONAL_GPUTEST_FOR_ALL_CONTEXTS(TestGpuAllContextsWithTrueCondition,
56                                          reporter, ctxInfo, true) {
57     REPORTER_ASSERT(reporter, reporter);
58     REPORTER_ASSERT(reporter, ctxInfo.directContext());
59 }
60 
DEF_CONDITIONAL_GPUTEST_FOR_ALL_CONTEXTS(TestGpuAllContextsWithFalseCondition,reporter,ctxInfo,false)61 DEF_CONDITIONAL_GPUTEST_FOR_ALL_CONTEXTS(TestGpuAllContextsWithFalseCondition,
62                                          reporter, ctxInfo, false) {
63     ERRORF(reporter, "DEF_CONDITIONAL_GPUTEST_FOR_ALL_CONTEXTS ran with a false condition");
64 }
65 
DEF_CONDITIONAL_GPUTEST_FOR_RENDERING_CONTEXTS(TestGpuRenderingContextsWithTrueCondition,reporter,ctxInfo,true)66 DEF_CONDITIONAL_GPUTEST_FOR_RENDERING_CONTEXTS(TestGpuRenderingContextsWithTrueCondition,
67                                                reporter, ctxInfo, true) {
68     REPORTER_ASSERT(reporter, reporter);
69     REPORTER_ASSERT(reporter, ctxInfo.directContext());
70 }
71 
DEF_CONDITIONAL_GPUTEST_FOR_RENDERING_CONTEXTS(TestGpuRenderingContextsWithFalseCondition,reporter,ctxInfo,false)72 DEF_CONDITIONAL_GPUTEST_FOR_RENDERING_CONTEXTS(TestGpuRenderingContextsWithFalseCondition,
73                                                reporter, ctxInfo, false) {
74     ERRORF(reporter, "DEF_CONDITIONAL_GPUTEST_FOR_RENDERING_CONTEXTS ran with a false condition");
75 }
76 
77