1*35238bceSAndroid Build Coastguard Worker /*-------------------------------------------------------------------------
2*35238bceSAndroid Build Coastguard Worker * drawElements Quality Program EGL Module
3*35238bceSAndroid Build Coastguard Worker * ---------------------------------------
4*35238bceSAndroid Build Coastguard Worker *
5*35238bceSAndroid Build Coastguard Worker * Copyright 2014 The Android Open Source Project
6*35238bceSAndroid Build Coastguard Worker *
7*35238bceSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License");
8*35238bceSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License.
9*35238bceSAndroid Build Coastguard Worker * You may obtain a copy of the License at
10*35238bceSAndroid Build Coastguard Worker *
11*35238bceSAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0
12*35238bceSAndroid Build Coastguard Worker *
13*35238bceSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software
14*35238bceSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS,
15*35238bceSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16*35238bceSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and
17*35238bceSAndroid Build Coastguard Worker * limitations under the License.
18*35238bceSAndroid Build Coastguard Worker *
19*35238bceSAndroid Build Coastguard Worker *//*!
20*35238bceSAndroid Build Coastguard Worker * \file
21*35238bceSAndroid Build Coastguard Worker * \brief EGL Implementation Information Tests
22*35238bceSAndroid Build Coastguard Worker *//*--------------------------------------------------------------------*/
23*35238bceSAndroid Build Coastguard Worker
24*35238bceSAndroid Build Coastguard Worker #include "teglInfoTests.hpp"
25*35238bceSAndroid Build Coastguard Worker #include "teglConfigList.hpp"
26*35238bceSAndroid Build Coastguard Worker #include "tcuTestLog.hpp"
27*35238bceSAndroid Build Coastguard Worker #include "deStringUtil.hpp"
28*35238bceSAndroid Build Coastguard Worker #include "egluUtil.hpp"
29*35238bceSAndroid Build Coastguard Worker #include "eglwLibrary.hpp"
30*35238bceSAndroid Build Coastguard Worker #include "eglwEnums.hpp"
31*35238bceSAndroid Build Coastguard Worker
32*35238bceSAndroid Build Coastguard Worker #include <vector>
33*35238bceSAndroid Build Coastguard Worker #include <string>
34*35238bceSAndroid Build Coastguard Worker #include <sstream>
35*35238bceSAndroid Build Coastguard Worker
36*35238bceSAndroid Build Coastguard Worker namespace deqp
37*35238bceSAndroid Build Coastguard Worker {
38*35238bceSAndroid Build Coastguard Worker namespace egl
39*35238bceSAndroid Build Coastguard Worker {
40*35238bceSAndroid Build Coastguard Worker
41*35238bceSAndroid Build Coastguard Worker using std::string;
42*35238bceSAndroid Build Coastguard Worker using std::vector;
43*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
44*35238bceSAndroid Build Coastguard Worker using namespace eglw;
45*35238bceSAndroid Build Coastguard Worker
toInt(std::string str)46*35238bceSAndroid Build Coastguard Worker static int toInt(std::string str)
47*35238bceSAndroid Build Coastguard Worker {
48*35238bceSAndroid Build Coastguard Worker std::istringstream strStream(str);
49*35238bceSAndroid Build Coastguard Worker
50*35238bceSAndroid Build Coastguard Worker int out;
51*35238bceSAndroid Build Coastguard Worker strStream >> out;
52*35238bceSAndroid Build Coastguard Worker return out;
53*35238bceSAndroid Build Coastguard Worker }
54*35238bceSAndroid Build Coastguard Worker
55*35238bceSAndroid Build Coastguard Worker class InfoCase : public TestCase
56*35238bceSAndroid Build Coastguard Worker {
57*35238bceSAndroid Build Coastguard Worker public:
InfoCase(EglTestContext & eglTestCtx,const char * name,const char * description)58*35238bceSAndroid Build Coastguard Worker InfoCase(EglTestContext &eglTestCtx, const char *name, const char *description)
59*35238bceSAndroid Build Coastguard Worker : TestCase(eglTestCtx, name, description)
60*35238bceSAndroid Build Coastguard Worker , m_display(EGL_NO_DISPLAY)
61*35238bceSAndroid Build Coastguard Worker , m_version(0, 0)
62*35238bceSAndroid Build Coastguard Worker {
63*35238bceSAndroid Build Coastguard Worker }
64*35238bceSAndroid Build Coastguard Worker
init(void)65*35238bceSAndroid Build Coastguard Worker void init(void)
66*35238bceSAndroid Build Coastguard Worker {
67*35238bceSAndroid Build Coastguard Worker DE_ASSERT(m_display == EGL_NO_DISPLAY);
68*35238bceSAndroid Build Coastguard Worker m_display = eglu::getAndInitDisplay(m_eglTestCtx.getNativeDisplay(), &m_version);
69*35238bceSAndroid Build Coastguard Worker }
70*35238bceSAndroid Build Coastguard Worker
deinit(void)71*35238bceSAndroid Build Coastguard Worker void deinit(void)
72*35238bceSAndroid Build Coastguard Worker {
73*35238bceSAndroid Build Coastguard Worker m_eglTestCtx.getLibrary().terminate(m_display);
74*35238bceSAndroid Build Coastguard Worker m_display = EGL_NO_DISPLAY;
75*35238bceSAndroid Build Coastguard Worker }
76*35238bceSAndroid Build Coastguard Worker
77*35238bceSAndroid Build Coastguard Worker protected:
78*35238bceSAndroid Build Coastguard Worker EGLDisplay m_display;
79*35238bceSAndroid Build Coastguard Worker eglu::Version m_version;
80*35238bceSAndroid Build Coastguard Worker };
81*35238bceSAndroid Build Coastguard Worker
82*35238bceSAndroid Build Coastguard Worker class QueryStringCase : public InfoCase
83*35238bceSAndroid Build Coastguard Worker {
84*35238bceSAndroid Build Coastguard Worker public:
QueryStringCase(EglTestContext & eglTestCtx,const char * name,const char * description,EGLint query)85*35238bceSAndroid Build Coastguard Worker QueryStringCase(EglTestContext &eglTestCtx, const char *name, const char *description, EGLint query)
86*35238bceSAndroid Build Coastguard Worker : InfoCase(eglTestCtx, name, description)
87*35238bceSAndroid Build Coastguard Worker , m_query(query)
88*35238bceSAndroid Build Coastguard Worker {
89*35238bceSAndroid Build Coastguard Worker }
90*35238bceSAndroid Build Coastguard Worker
validateString(const std::string & result)91*35238bceSAndroid Build Coastguard Worker void validateString(const std::string &result)
92*35238bceSAndroid Build Coastguard Worker {
93*35238bceSAndroid Build Coastguard Worker tcu::TestLog &log = m_testCtx.getLog();
94*35238bceSAndroid Build Coastguard Worker std::vector<std::string> tokens = de::splitString(result, ' ');
95*35238bceSAndroid Build Coastguard Worker
96*35238bceSAndroid Build Coastguard Worker if (m_query == EGL_VERSION)
97*35238bceSAndroid Build Coastguard Worker {
98*35238bceSAndroid Build Coastguard Worker const int dispMajor = m_version.getMajor();
99*35238bceSAndroid Build Coastguard Worker const int dispMinor = m_version.getMinor();
100*35238bceSAndroid Build Coastguard Worker
101*35238bceSAndroid Build Coastguard Worker const std::vector<std::string> versionTokens = de::splitString(tokens[0], '.');
102*35238bceSAndroid Build Coastguard Worker
103*35238bceSAndroid Build Coastguard Worker if (versionTokens.size() < 2)
104*35238bceSAndroid Build Coastguard Worker {
105*35238bceSAndroid Build Coastguard Worker log << TestLog::Message
106*35238bceSAndroid Build Coastguard Worker << " Fail, first part of the string must be in the format <major_version.minor_version>"
107*35238bceSAndroid Build Coastguard Worker << TestLog::EndMessage;
108*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid version string");
109*35238bceSAndroid Build Coastguard Worker }
110*35238bceSAndroid Build Coastguard Worker else
111*35238bceSAndroid Build Coastguard Worker {
112*35238bceSAndroid Build Coastguard Worker const int stringMajor = toInt(versionTokens[0]);
113*35238bceSAndroid Build Coastguard Worker const int stringMinor = toInt(versionTokens[1]);
114*35238bceSAndroid Build Coastguard Worker
115*35238bceSAndroid Build Coastguard Worker if (stringMajor != dispMajor || stringMinor != dispMinor)
116*35238bceSAndroid Build Coastguard Worker {
117*35238bceSAndroid Build Coastguard Worker log << TestLog::Message << " Fail, version numer (" << stringMajor << "." << stringMinor
118*35238bceSAndroid Build Coastguard Worker << ") does not match the one reported by eglInitialize (" << dispMajor << "." << dispMinor
119*35238bceSAndroid Build Coastguard Worker << ")" << TestLog::EndMessage;
120*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Version number mismatch");
121*35238bceSAndroid Build Coastguard Worker }
122*35238bceSAndroid Build Coastguard Worker }
123*35238bceSAndroid Build Coastguard Worker }
124*35238bceSAndroid Build Coastguard Worker }
125*35238bceSAndroid Build Coastguard Worker
iterate(void)126*35238bceSAndroid Build Coastguard Worker IterateResult iterate(void)
127*35238bceSAndroid Build Coastguard Worker {
128*35238bceSAndroid Build Coastguard Worker const Library &egl = m_eglTestCtx.getLibrary();
129*35238bceSAndroid Build Coastguard Worker const char *result = egl.queryString(m_display, m_query);
130*35238bceSAndroid Build Coastguard Worker EGLU_CHECK_MSG(egl, "eglQueryString() failed");
131*35238bceSAndroid Build Coastguard Worker
132*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << tcu::TestLog::Message << result << tcu::TestLog::EndMessage;
133*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
134*35238bceSAndroid Build Coastguard Worker
135*35238bceSAndroid Build Coastguard Worker validateString(result);
136*35238bceSAndroid Build Coastguard Worker
137*35238bceSAndroid Build Coastguard Worker return STOP;
138*35238bceSAndroid Build Coastguard Worker }
139*35238bceSAndroid Build Coastguard Worker
140*35238bceSAndroid Build Coastguard Worker private:
141*35238bceSAndroid Build Coastguard Worker EGLint m_query;
142*35238bceSAndroid Build Coastguard Worker };
143*35238bceSAndroid Build Coastguard Worker
144*35238bceSAndroid Build Coastguard Worker class QueryExtensionsCase : public InfoCase
145*35238bceSAndroid Build Coastguard Worker {
146*35238bceSAndroid Build Coastguard Worker public:
QueryExtensionsCase(EglTestContext & eglTestCtx)147*35238bceSAndroid Build Coastguard Worker QueryExtensionsCase(EglTestContext &eglTestCtx) : InfoCase(eglTestCtx, "extensions", "Supported Extensions")
148*35238bceSAndroid Build Coastguard Worker {
149*35238bceSAndroid Build Coastguard Worker }
150*35238bceSAndroid Build Coastguard Worker
iterate(void)151*35238bceSAndroid Build Coastguard Worker IterateResult iterate(void)
152*35238bceSAndroid Build Coastguard Worker {
153*35238bceSAndroid Build Coastguard Worker const Library &egl = m_eglTestCtx.getLibrary();
154*35238bceSAndroid Build Coastguard Worker vector<string> extensions = eglu::getDisplayExtensions(egl, m_display);
155*35238bceSAndroid Build Coastguard Worker
156*35238bceSAndroid Build Coastguard Worker for (vector<string>::const_iterator i = extensions.begin(); i != extensions.end(); i++)
157*35238bceSAndroid Build Coastguard Worker m_testCtx.getLog() << tcu::TestLog::Message << *i << tcu::TestLog::EndMessage;
158*35238bceSAndroid Build Coastguard Worker
159*35238bceSAndroid Build Coastguard Worker m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
160*35238bceSAndroid Build Coastguard Worker
161*35238bceSAndroid Build Coastguard Worker return STOP;
162*35238bceSAndroid Build Coastguard Worker }
163*35238bceSAndroid Build Coastguard Worker };
164*35238bceSAndroid Build Coastguard Worker
InfoTests(EglTestContext & eglTestCtx)165*35238bceSAndroid Build Coastguard Worker InfoTests::InfoTests(EglTestContext &eglTestCtx) : TestCaseGroup(eglTestCtx, "info", "Platform Information")
166*35238bceSAndroid Build Coastguard Worker {
167*35238bceSAndroid Build Coastguard Worker }
168*35238bceSAndroid Build Coastguard Worker
~InfoTests(void)169*35238bceSAndroid Build Coastguard Worker InfoTests::~InfoTests(void)
170*35238bceSAndroid Build Coastguard Worker {
171*35238bceSAndroid Build Coastguard Worker }
172*35238bceSAndroid Build Coastguard Worker
init(void)173*35238bceSAndroid Build Coastguard Worker void InfoTests::init(void)
174*35238bceSAndroid Build Coastguard Worker {
175*35238bceSAndroid Build Coastguard Worker addChild(new QueryStringCase(m_eglTestCtx, "version", "EGL Version", EGL_VERSION));
176*35238bceSAndroid Build Coastguard Worker addChild(new QueryStringCase(m_eglTestCtx, "vendor", "EGL Vendor", EGL_VENDOR));
177*35238bceSAndroid Build Coastguard Worker addChild(new QueryStringCase(m_eglTestCtx, "client_apis", "Supported client APIs", EGL_CLIENT_APIS));
178*35238bceSAndroid Build Coastguard Worker addChild(new QueryExtensionsCase(m_eglTestCtx));
179*35238bceSAndroid Build Coastguard Worker addChild(new ConfigList(m_eglTestCtx));
180*35238bceSAndroid Build Coastguard Worker }
181*35238bceSAndroid Build Coastguard Worker
182*35238bceSAndroid Build Coastguard Worker } // namespace egl
183*35238bceSAndroid Build Coastguard Worker } // namespace deqp
184