1179a8f5f7feab052e24596d0d04ab5cf2ccab5e0kkinnunen/*
2179a8f5f7feab052e24596d0d04ab5cf2ccab5e0kkinnunen * Copyright 2015 Google Inc.
3179a8f5f7feab052e24596d0d04ab5cf2ccab5e0kkinnunen *
4179a8f5f7feab052e24596d0d04ab5cf2ccab5e0kkinnunen * Use of this source code is governed by a BSD-style license that can be
5179a8f5f7feab052e24596d0d04ab5cf2ccab5e0kkinnunen * found in the LICENSE file.
6179a8f5f7feab052e24596d0d04ab5cf2ccab5e0kkinnunen */
7179a8f5f7feab052e24596d0d04ab5cf2ccab5e0kkinnunen
8179a8f5f7feab052e24596d0d04ab5cf2ccab5e0kkinnunen#include "Test.h"
9179a8f5f7feab052e24596d0d04ab5cf2ccab5e0kkinnunen
10179a8f5f7feab052e24596d0d04ab5cf2ccab5e0kkinnunen#if SK_SUPPORT_GPU
11179a8f5f7feab052e24596d0d04ab5cf2ccab5e0kkinnunen#include "GrContext.h"
12273c0f5e87397c40d22bb7e3ee078bb46a3f6860bsalomon#include "gl/GLTestContext.h"
13179a8f5f7feab052e24596d0d04ab5cf2ccab5e0kkinnunen#endif
14179a8f5f7feab052e24596d0d04ab5cf2ccab5e0kkinnunen
15179a8f5f7feab052e24596d0d04ab5cf2ccab5e0kkinnunen
16179a8f5f7feab052e24596d0d04ab5cf2ccab5e0kkinnunen// This is an example of a normal test.
17179a8f5f7feab052e24596d0d04ab5cf2ccab5e0kkinnunenDEF_TEST(TestNormal, reporter) {
18179a8f5f7feab052e24596d0d04ab5cf2ccab5e0kkinnunen    REPORTER_ASSERT(reporter, reporter);
19179a8f5f7feab052e24596d0d04ab5cf2ccab5e0kkinnunen}
20179a8f5f7feab052e24596d0d04ab5cf2ccab5e0kkinnunen
21179a8f5f7feab052e24596d0d04ab5cf2ccab5e0kkinnunen// This is an example of a GPU test that uses common GrContextFactory factory to do the test.
22179a8f5f7feab052e24596d0d04ab5cf2ccab5e0kkinnunen#if SK_SUPPORT_GPU
23179a8f5f7feab052e24596d0d04ab5cf2ccab5e0kkinnunenDEF_GPUTEST(TestGpuFactory, reporter, factory) {
24179a8f5f7feab052e24596d0d04ab5cf2ccab5e0kkinnunen    REPORTER_ASSERT(reporter, reporter);
25179a8f5f7feab052e24596d0d04ab5cf2ccab5e0kkinnunen    REPORTER_ASSERT(reporter, factory);
26179a8f5f7feab052e24596d0d04ab5cf2ccab5e0kkinnunen}
27179a8f5f7feab052e24596d0d04ab5cf2ccab5e0kkinnunen#endif
28179a8f5f7feab052e24596d0d04ab5cf2ccab5e0kkinnunen
29179a8f5f7feab052e24596d0d04ab5cf2ccab5e0kkinnunen// This is an example of a GPU test that tests a property that should work for all GPU contexts.
30179a8f5f7feab052e24596d0d04ab5cf2ccab5e0kkinnunen// Note: Some of the contexts might not produce a rendering output.
31179a8f5f7feab052e24596d0d04ab5cf2ccab5e0kkinnunen#if SK_SUPPORT_GPU
32ab527a5bbfb1eae4f99a1435d349a44d00477d82egdanielDEF_GPUTEST_FOR_ALL_CONTEXTS(TestGpuAllContexts, reporter, ctxInfo) {
33179a8f5f7feab052e24596d0d04ab5cf2ccab5e0kkinnunen    REPORTER_ASSERT(reporter, reporter);
348b7451aaf6b1c71e9d343a4df107893db277b6aabsalomon    REPORTER_ASSERT(reporter, ctxInfo.grContext());
35179a8f5f7feab052e24596d0d04ab5cf2ccab5e0kkinnunen}
36179a8f5f7feab052e24596d0d04ab5cf2ccab5e0kkinnunen#endif
37179a8f5f7feab052e24596d0d04ab5cf2ccab5e0kkinnunen
38179a8f5f7feab052e24596d0d04ab5cf2ccab5e0kkinnunen// This is an example of a GPU test that tests a property that should work for all GPU contexts that
39179a8f5f7feab052e24596d0d04ab5cf2ccab5e0kkinnunen// produce a rendering output.
40179a8f5f7feab052e24596d0d04ab5cf2ccab5e0kkinnunen#if SK_SUPPORT_GPU
4168d9134bec16e91c4a6cde071bcaa579bc0801a7bsalomonDEF_GPUTEST_FOR_RENDERING_CONTEXTS(TestGpuRenderingContexts, reporter, ctxInfo) {
42179a8f5f7feab052e24596d0d04ab5cf2ccab5e0kkinnunen    REPORTER_ASSERT(reporter, reporter);
438b7451aaf6b1c71e9d343a4df107893db277b6aabsalomon    REPORTER_ASSERT(reporter, ctxInfo.grContext());
44179a8f5f7feab052e24596d0d04ab5cf2ccab5e0kkinnunen}
45179a8f5f7feab052e24596d0d04ab5cf2ccab5e0kkinnunen#endif
46179a8f5f7feab052e24596d0d04ab5cf2ccab5e0kkinnunen
47179a8f5f7feab052e24596d0d04ab5cf2ccab5e0kkinnunen// This is an example of a GPU test that tests a property that uses the null GPU context.  It should
48179a8f5f7feab052e24596d0d04ab5cf2ccab5e0kkinnunen// be used if the test tests some behavior that is mocked with the null context.
49179a8f5f7feab052e24596d0d04ab5cf2ccab5e0kkinnunen#if SK_SUPPORT_GPU
50758586c7f11a6b3529bd4a1c9b4e982a0d0b0582bsalomonDEF_GPUTEST_FOR_NULLGL_CONTEXT(TestGpuNullContext, reporter, ctxInfo) {
51179a8f5f7feab052e24596d0d04ab5cf2ccab5e0kkinnunen    REPORTER_ASSERT(reporter, reporter);
528b7451aaf6b1c71e9d343a4df107893db277b6aabsalomon    REPORTER_ASSERT(reporter, ctxInfo.grContext());
53179a8f5f7feab052e24596d0d04ab5cf2ccab5e0kkinnunen}
54179a8f5f7feab052e24596d0d04ab5cf2ccab5e0kkinnunen#endif
55