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 EGL Implementation Information Tests
22 *//*--------------------------------------------------------------------*/
24 #include "teglInfoTests.hpp"
25 #include "teglConfigList.hpp"
26 #include "tcuTestLog.hpp"
27 #include "deStringUtil.hpp"
28 #include "egluUtil.hpp"
29 #include "eglwLibrary.hpp"
30 #include "eglwEnums.hpp"
46 static int toInt (std::string str)
48 std::istringstream strStream(str);
55 class InfoCase : public TestCase
58 InfoCase (EglTestContext& eglTestCtx, const char* name, const char* description)
59 : TestCase (eglTestCtx, name, description)
60 , m_display (EGL_NO_DISPLAY)
67 DE_ASSERT(m_display == EGL_NO_DISPLAY);
68 m_display = eglu::getAndInitDisplay(m_eglTestCtx.getNativeDisplay(), &m_version);
73 m_eglTestCtx.getLibrary().terminate(m_display);
74 m_display = EGL_NO_DISPLAY;
79 eglu::Version m_version;
82 class QueryStringCase : public InfoCase
85 QueryStringCase (EglTestContext& eglTestCtx, const char* name, const char* description, EGLint query)
86 : InfoCase (eglTestCtx, name, description)
91 void validateString (const std::string& result)
93 tcu::TestLog& log = m_testCtx.getLog();
94 std::vector<std::string> tokens = de::splitString(result, ' ');
96 if (m_query == EGL_VERSION)
98 const int dispMajor = m_version.getMajor();
99 const int dispMinor = m_version.getMinor();
101 const std::vector<std::string> versionTokens = de::splitString(tokens[0], '.');
103 if (versionTokens.size() < 2)
105 log << TestLog::Message << " Fail, first part of the string must be in the format <major_version.minor_version>" << TestLog::EndMessage;
106 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid version string");
110 const int stringMajor = toInt(versionTokens[0]);
111 const int stringMinor = toInt(versionTokens[1]);
113 if (stringMajor != dispMajor || stringMinor != dispMinor)
115 log << TestLog::Message << " Fail, version numer (" << stringMajor << "." << stringMinor
116 << ") does not match the one reported by eglInitialize (" << dispMajor << "." << dispMinor << ")" << TestLog::EndMessage;
117 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Version number mismatch");
123 IterateResult iterate (void)
125 const Library& egl = m_eglTestCtx.getLibrary();
126 const char* result = egl.queryString(m_display, m_query);
127 EGLU_CHECK_MSG(egl, "eglQueryString() failed");
129 m_testCtx.getLog() << tcu::TestLog::Message << result << tcu::TestLog::EndMessage;
130 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
132 validateString(result);
141 class QueryExtensionsCase : public InfoCase
144 QueryExtensionsCase (EglTestContext& eglTestCtx)
145 : InfoCase (eglTestCtx, "extensions", "Supported Extensions")
149 IterateResult iterate (void)
151 const Library& egl = m_eglTestCtx.getLibrary();
152 vector<string> extensions = eglu::getClientExtensions(egl, m_display);
154 for (vector<string>::const_iterator i = extensions.begin(); i != extensions.end(); i++)
155 m_testCtx.getLog() << tcu::TestLog::Message << *i << tcu::TestLog::EndMessage;
157 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
163 InfoTests::InfoTests (EglTestContext& eglTestCtx)
164 : TestCaseGroup(eglTestCtx, "info", "Platform Information")
168 InfoTests::~InfoTests (void)
172 void InfoTests::init (void)
174 addChild(new QueryStringCase(m_eglTestCtx, "version", "EGL Version", EGL_VERSION));
175 addChild(new QueryStringCase(m_eglTestCtx, "vendor", "EGL Vendor", EGL_VENDOR));
176 addChild(new QueryStringCase(m_eglTestCtx, "client_apis", "Supported client APIs", EGL_CLIENT_APIS));
177 addChild(new QueryExtensionsCase(m_eglTestCtx));
178 addChild(new ConfigList(m_eglTestCtx));