1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program OpenGL ES 2.0 Module
3 * -------------------------------------------------
4 *
5 * Copyright 2014 The Android Open Source Project
6 *
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
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
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.
18 *
19 *//*!
20 * \file
21 * \brief String Query tests.
22 *//*--------------------------------------------------------------------*/
23
24 #include "es2fStringQueryTests.hpp"
25 #include "es2fApiCase.hpp"
26 #include "gluRenderContext.hpp"
27 #include "glwEnums.hpp"
28 #include "glwFunctions.hpp"
29 #include "deString.h"
30
31 #include <algorithm>
32 #include <sstream>
33 #include <string>
34
35 using namespace glw; // GLint and other GL types
36
37 namespace deqp
38 {
39 namespace gles2
40 {
41 namespace Functional
42 {
43
StringQueryTests(Context & context)44 StringQueryTests::StringQueryTests (Context& context)
45 : TestCaseGroup (context, "string", "String Query tests")
46 {
47 }
48
~StringQueryTests(void)49 StringQueryTests::~StringQueryTests (void)
50 {
51 }
52
init(void)53 void StringQueryTests::init (void)
54 {
55 using tcu::TestLog;
56
57 ES2F_ADD_API_CASE(renderer, "RENDERER",
58 {
59 const GLubyte* string = glGetString(GL_RENDERER);
60 if (string == NULL)
61 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid string");
62 });
63 ES2F_ADD_API_CASE(vendor, "VENDOR",
64 {
65 const GLubyte* string = glGetString(GL_VENDOR);
66 if (string == NULL)
67 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid string");
68 });
69 ES2F_ADD_API_CASE(version, "VERSION",
70 {
71 const char* string = (const char*)glGetString(GL_VERSION);
72 const char referenceString[] = "OpenGL ES ";
73
74 if (string == NULL)
75 TCU_FAIL("Got invalid string");
76
77 if (!deStringBeginsWith(string, referenceString))
78 TCU_FAIL("Got invalid string prefix");
79
80 {
81 std::string tmpString;
82 char versionDelimiter;
83 int glMajor = 0;
84 int glMinor = 0;
85
86 std::istringstream versionStream(string);
87 versionStream >> tmpString; // OpenGL
88 versionStream >> tmpString; // ES
89 versionStream >> glMajor; // x
90 versionStream >> std::noskipws;
91 versionStream >> versionDelimiter; // .
92 versionStream >> glMinor; // x
93
94 if (!versionStream)
95 TCU_FAIL("Got invalid string format");
96 }
97 });
98 ES2F_ADD_API_CASE(shading_language_version, "SHADING_LANGUAGE_VERSION",
99 {
100 const char* string = (const char*)glGetString(GL_SHADING_LANGUAGE_VERSION);
101 const char referenceString[] = "OpenGL ES GLSL ES ";
102
103 if (string == NULL)
104 TCU_FAIL("Got invalid string");
105
106 if (!deStringBeginsWith(string, referenceString))
107 TCU_FAIL("Got invalid string prefix");
108
109 {
110 std::string tmpString;
111 char versionDelimiter;
112 int glslMajor = 0;
113 int glslMinor = 0;
114
115 std::istringstream versionStream(string);
116 versionStream >> tmpString; // OpenGL
117 versionStream >> tmpString; // ES
118 versionStream >> tmpString; // GLSL
119 versionStream >> tmpString; // ES
120 versionStream >> glslMajor; // x
121 versionStream >> std::noskipws;
122 versionStream >> versionDelimiter; // .
123 versionStream >> glslMinor; // x
124
125 if (!versionStream)
126 TCU_FAIL("Got invalid string format");
127 }
128 });
129 ES2F_ADD_API_CASE(extensions, "EXTENSIONS",
130 {
131 const char* extensions_cstring = (const char*)glGetString(GL_EXTENSIONS);
132 if (extensions_cstring == NULL)
133 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid string");
134 });
135 }
136
137 } // Functional
138 } // gles2
139 } // deqp
140