teglApiCase.hpp revision 7bd8f7c0f982a10c6e7127ce2497ee7e208ea90e
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
34namespace deqp
35{
36namespace egl
37{
38
39class ApiCase : public TestCase, protected eglu::CallLogWrapper
40{
41public:
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
50protected:
51	virtual void		test					(void) = DE_NULL;
52
53	void				expectError				(eglw::EGLenum error);
54	void				expectBoolean			(eglw::EGLBoolean expected, eglw::EGLBoolean got);
55
56	void				expectNoContext			(eglw::EGLContext got);
57	void				expectNoSurface			(eglw::EGLSurface got);
58	void				expectNoDisplay			(eglw::EGLDisplay got);
59	void				expectNull				(const void* got);
60
61	inline void			expectTrue				(eglw::EGLBoolean got) { expectBoolean(EGL_TRUE, got); }
62	inline void			expectFalse				(eglw::EGLBoolean got) { expectBoolean(EGL_FALSE, got); }
63
64	eglw::EGLDisplay	getDisplay				(void)						{ return m_display;							}
65	bool				isAPISupported			(eglw::EGLenum api) const;
66	bool				getConfig				(eglw::EGLConfig* cfg, const eglu::FilterList& filters);
67
68private:
69	eglw::EGLDisplay							m_display;
70	std::vector<eglw::EGLenum>					m_supportedClientAPIs;
71};
72
73} // egl
74} // deqp
75
76// Helper macro for declaring ApiCases.
77#define TEGL_ADD_API_CASE(NAME, DESCRIPTION, TEST_FUNC_BODY)									\
78	do {																						\
79		class ApiCase_##NAME : public deqp::egl::ApiCase {										\
80		public:																					\
81			ApiCase_##NAME (EglTestContext& context) : ApiCase(context, #NAME, DESCRIPTION) {}	\
82		protected:																				\
83			void test (void) TEST_FUNC_BODY														\
84		};																						\
85		addChild(new ApiCase_##NAME(m_eglTestCtx));												\
86	} while (deGetFalse())
87
88#endif // _TEGLAPICASE_HPP
89