xref: /aosp_15_r20/external/deqp/modules/egl/teglApiCase.hpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
1 #ifndef _TEGLAPICASE_HPP
2 #define _TEGLAPICASE_HPP
3 /*-------------------------------------------------------------------------
4  * drawElements Quality Program EGL Module
5  * ---------------------------------------
6  *
7  * Copyright 2014 The Android Open Source Project
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  *//*!
22  * \file
23  * \brief API test case.
24  *//*--------------------------------------------------------------------*/
25 
26 #include "tcuDefs.hpp"
27 #include "teglTestCase.hpp"
28 #include "egluCallLogWrapper.hpp"
29 #include "egluConfigFilter.hpp"
30 #include "eglwEnums.hpp"
31 
32 #include <vector>
33 
34 namespace deqp
35 {
36 namespace egl
37 {
38 
39 class ApiCase : public TestCase, protected eglu::CallLogWrapper
40 {
41 public:
42     ApiCase(EglTestContext &eglTestCtx, const char *name, const char *description);
43     virtual ~ApiCase(void);
44 
45     void init(void);
46     void deinit(void);
47 
48     IterateResult iterate(void);
49 
50 protected:
51     virtual void test(void) = DE_NULL;
52 
53     void expectError(eglw::EGLenum error);
54     void expectEitherError(eglw::EGLenum errorA, eglw::EGLenum errorB);
55     void expectBoolean(eglw::EGLBoolean expected, eglw::EGLBoolean got);
56 
57     void expectNoContext(eglw::EGLContext got);
58     void expectNoSurface(eglw::EGLSurface got);
59     void expectNoDisplay(eglw::EGLDisplay got);
60     void expectNull(const void *got);
61 
expectTrue(eglw::EGLBoolean got)62     inline void expectTrue(eglw::EGLBoolean got)
63     {
64         expectBoolean(EGL_TRUE, got);
65     }
expectFalse(eglw::EGLBoolean got)66     inline void expectFalse(eglw::EGLBoolean got)
67     {
68         expectBoolean(EGL_FALSE, got);
69     }
70 
getDisplay(void)71     eglw::EGLDisplay getDisplay(void)
72     {
73         return m_display;
74     }
75     bool isAPISupported(eglw::EGLenum api) const;
76     bool getConfig(eglw::EGLConfig *cfg, const eglu::FilterList &filters);
77 
78 private:
79     eglw::EGLDisplay m_display;
80     std::vector<eglw::EGLenum> m_supportedClientAPIs;
81 };
82 
83 } // namespace egl
84 } // namespace deqp
85 
86 // Helper macro for declaring ApiCases.
87 #define TEGL_ADD_API_CASE(NAME, DESCRIPTION, TEST_FUNC_BODY)                               \
88     do                                                                                     \
89     {                                                                                      \
90         class ApiCase_##NAME : public deqp::egl::ApiCase                                   \
91         {                                                                                  \
92         public:                                                                            \
93             ApiCase_##NAME(EglTestContext &context) : ApiCase(context, #NAME, DESCRIPTION) \
94             {                                                                              \
95             }                                                                              \
96                                                                                            \
97         protected:                                                                         \
98             void test(void) TEST_FUNC_BODY /* NOLINT(TEST_FUNC_BODY) */                    \
99         };                                                                                 \
100         addChild(new ApiCase_##NAME(m_eglTestCtx));                                        \
101     } while (false)
102 
103 #endif // _TEGLAPICASE_HPP
104