1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program EGL Module
3 * ---------------------------------------
5 * Copyright 2014 The Android Open Source Project
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
21 * \brief API test case.
22 *//*--------------------------------------------------------------------*/
24 #include "teglApiCase.hpp"
25 #include "egluUtil.hpp"
26 #include "egluStrUtil.hpp"
27 #include "eglwLibrary.hpp"
28 #include "eglwEnums.hpp"
29 #include "deSTLUtil.hpp"
40 ApiCase::ApiCase (EglTestContext& eglTestCtx, const char* name, const char* description)
41 : TestCase (eglTestCtx, name, description)
42 , CallLogWrapper(eglTestCtx.getLibrary(), eglTestCtx.getTestContext().getLog())
43 , m_display (EGL_NO_DISPLAY)
47 ApiCase::~ApiCase (void)
51 void ApiCase::init (void)
53 m_display = eglu::getAndInitDisplay(m_eglTestCtx.getNativeDisplay());
54 m_supportedClientAPIs = eglu::getClientAPIs(m_eglTestCtx.getLibrary(), m_display);
57 void ApiCase::deinit (void)
59 const Library& egl = m_eglTestCtx.getLibrary();
60 egl.terminate(m_display);
62 m_display = EGL_NO_DISPLAY;
63 m_supportedClientAPIs.clear();
66 ApiCase::IterateResult ApiCase::iterate (void)
68 // Initialize result to pass.
69 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
71 // Enable call logging.
80 bool ApiCase::isAPISupported (eglw::EGLenum api) const
82 return de::contains(m_supportedClientAPIs.begin(), m_supportedClientAPIs.end(), api);
85 void ApiCase::expectError (EGLenum expected)
87 EGLenum err = m_eglTestCtx.getLibrary().getError();
90 m_testCtx.getLog() << TestLog::Message << "// ERROR expected: " << eglu::getErrorStr(expected) << ", Got: " << eglu::getErrorStr(err) << TestLog::EndMessage;
91 if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
92 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid error");
96 void ApiCase::expectEitherError (EGLenum expectedA, EGLenum expectedB)
98 EGLenum err = m_eglTestCtx.getLibrary().getError();
99 if (err != expectedA && err != expectedB)
101 m_testCtx.getLog() << TestLog::Message << "// ERROR expected: " << eglu::getErrorStr(expectedA) << " or " << eglu::getErrorStr(expectedB) << ", Got: " << eglu::getErrorStr(err) << TestLog::EndMessage;
102 if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
103 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid error");
107 void ApiCase::expectBoolean (EGLBoolean expected, EGLBoolean got)
111 m_testCtx.getLog() << TestLog::Message << "// ERROR expected: " << eglu::getBooleanStr(expected) << ", Got: " << eglu::getBooleanStr(got) << TestLog::EndMessage;
112 if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
113 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid value");
117 void ApiCase::expectNoContext (EGLContext got)
119 if (got != EGL_NO_CONTEXT)
121 m_testCtx.getLog() << TestLog::Message << "// ERROR expected: EGL_NO_CONTEXT" << TestLog::EndMessage;
122 if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
123 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid value");
124 eglDestroyContext(getDisplay(), got);
128 void ApiCase::expectNoSurface (EGLSurface got)
130 if (got != EGL_NO_SURFACE)
132 m_testCtx.getLog() << TestLog::Message << "// ERROR expected: EGL_NO_SURFACE" << TestLog::EndMessage;
133 if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
134 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid value");
135 eglDestroySurface(getDisplay(), got);
139 void ApiCase::expectNoDisplay (EGLDisplay got)
141 if (got != EGL_NO_DISPLAY)
143 m_testCtx.getLog() << TestLog::Message << "// ERROR expected: EGL_NO_DISPLAY" << TestLog::EndMessage;
144 if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
145 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid value");
149 void ApiCase::expectNull (const void* got)
153 m_testCtx.getLog() << TestLog::Message << "// ERROR expected: NULL" << TestLog::EndMessage;
154 if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
155 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid value");
159 bool ApiCase::getConfig (EGLConfig* config, const eglu::FilterList& filters)
163 *config = eglu::chooseSingleConfig(m_eglTestCtx.getLibrary(), m_display, filters);
166 catch (const tcu::NotSupportedError&)