1e5c31af7Sopenharmony_ci/*------------------------------------------------------------------------- 2e5c31af7Sopenharmony_ci * drawElements Quality Program OpenGL ES 2.0 Module 3e5c31af7Sopenharmony_ci * ------------------------------------------------- 4e5c31af7Sopenharmony_ci * 5e5c31af7Sopenharmony_ci * Copyright 2014 The Android Open Source Project 6e5c31af7Sopenharmony_ci * 7e5c31af7Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 8e5c31af7Sopenharmony_ci * you may not use this file except in compliance with the License. 9e5c31af7Sopenharmony_ci * You may obtain a copy of the License at 10e5c31af7Sopenharmony_ci * 11e5c31af7Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 12e5c31af7Sopenharmony_ci * 13e5c31af7Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 14e5c31af7Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 15e5c31af7Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16e5c31af7Sopenharmony_ci * See the License for the specific language governing permissions and 17e5c31af7Sopenharmony_ci * limitations under the License. 18e5c31af7Sopenharmony_ci * 19e5c31af7Sopenharmony_ci *//*! 20e5c31af7Sopenharmony_ci * \file 21e5c31af7Sopenharmony_ci * \brief String Query tests. 22e5c31af7Sopenharmony_ci *//*--------------------------------------------------------------------*/ 23e5c31af7Sopenharmony_ci 24e5c31af7Sopenharmony_ci#include "es2fStringQueryTests.hpp" 25e5c31af7Sopenharmony_ci#include "es2fApiCase.hpp" 26e5c31af7Sopenharmony_ci#include "gluRenderContext.hpp" 27e5c31af7Sopenharmony_ci#include "glwEnums.hpp" 28e5c31af7Sopenharmony_ci#include "glwFunctions.hpp" 29e5c31af7Sopenharmony_ci#include "deString.h" 30e5c31af7Sopenharmony_ci 31e5c31af7Sopenharmony_ci#include <algorithm> 32e5c31af7Sopenharmony_ci#include <sstream> 33e5c31af7Sopenharmony_ci#include <string> 34e5c31af7Sopenharmony_ci 35e5c31af7Sopenharmony_ciusing namespace glw; // GLint and other GL types 36e5c31af7Sopenharmony_ci 37e5c31af7Sopenharmony_cinamespace deqp 38e5c31af7Sopenharmony_ci{ 39e5c31af7Sopenharmony_cinamespace gles2 40e5c31af7Sopenharmony_ci{ 41e5c31af7Sopenharmony_cinamespace Functional 42e5c31af7Sopenharmony_ci{ 43e5c31af7Sopenharmony_ci 44e5c31af7Sopenharmony_ciStringQueryTests::StringQueryTests (Context& context) 45e5c31af7Sopenharmony_ci : TestCaseGroup (context, "string", "String Query tests") 46e5c31af7Sopenharmony_ci{ 47e5c31af7Sopenharmony_ci} 48e5c31af7Sopenharmony_ci 49e5c31af7Sopenharmony_ciStringQueryTests::~StringQueryTests (void) 50e5c31af7Sopenharmony_ci{ 51e5c31af7Sopenharmony_ci} 52e5c31af7Sopenharmony_ci 53e5c31af7Sopenharmony_civoid StringQueryTests::init (void) 54e5c31af7Sopenharmony_ci{ 55e5c31af7Sopenharmony_ci using tcu::TestLog; 56e5c31af7Sopenharmony_ci 57e5c31af7Sopenharmony_ci ES2F_ADD_API_CASE(renderer, "RENDERER", 58e5c31af7Sopenharmony_ci { 59e5c31af7Sopenharmony_ci const GLubyte* string = glGetString(GL_RENDERER); 60e5c31af7Sopenharmony_ci if (string == NULL) 61e5c31af7Sopenharmony_ci m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid string"); 62e5c31af7Sopenharmony_ci }); 63e5c31af7Sopenharmony_ci ES2F_ADD_API_CASE(vendor, "VENDOR", 64e5c31af7Sopenharmony_ci { 65e5c31af7Sopenharmony_ci const GLubyte* string = glGetString(GL_VENDOR); 66e5c31af7Sopenharmony_ci if (string == NULL) 67e5c31af7Sopenharmony_ci m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid string"); 68e5c31af7Sopenharmony_ci }); 69e5c31af7Sopenharmony_ci ES2F_ADD_API_CASE(version, "VERSION", 70e5c31af7Sopenharmony_ci { 71e5c31af7Sopenharmony_ci const char* string = (const char*)glGetString(GL_VERSION); 72e5c31af7Sopenharmony_ci const char referenceString[] = "OpenGL ES "; 73e5c31af7Sopenharmony_ci 74e5c31af7Sopenharmony_ci if (string == NULL) 75e5c31af7Sopenharmony_ci TCU_FAIL("Got invalid string"); 76e5c31af7Sopenharmony_ci 77e5c31af7Sopenharmony_ci if (!deStringBeginsWith(string, referenceString)) 78e5c31af7Sopenharmony_ci TCU_FAIL("Got invalid string prefix"); 79e5c31af7Sopenharmony_ci 80e5c31af7Sopenharmony_ci { 81e5c31af7Sopenharmony_ci std::string tmpString; 82e5c31af7Sopenharmony_ci char versionDelimiter; 83e5c31af7Sopenharmony_ci int glMajor = 0; 84e5c31af7Sopenharmony_ci int glMinor = 0; 85e5c31af7Sopenharmony_ci 86e5c31af7Sopenharmony_ci std::istringstream versionStream(string); 87e5c31af7Sopenharmony_ci versionStream >> tmpString; // OpenGL 88e5c31af7Sopenharmony_ci versionStream >> tmpString; // ES 89e5c31af7Sopenharmony_ci versionStream >> glMajor; // x 90e5c31af7Sopenharmony_ci versionStream >> std::noskipws; 91e5c31af7Sopenharmony_ci versionStream >> versionDelimiter; // . 92e5c31af7Sopenharmony_ci versionStream >> glMinor; // x 93e5c31af7Sopenharmony_ci 94e5c31af7Sopenharmony_ci if (!versionStream) 95e5c31af7Sopenharmony_ci TCU_FAIL("Got invalid string format"); 96e5c31af7Sopenharmony_ci } 97e5c31af7Sopenharmony_ci }); 98e5c31af7Sopenharmony_ci ES2F_ADD_API_CASE(shading_language_version, "SHADING_LANGUAGE_VERSION", 99e5c31af7Sopenharmony_ci { 100e5c31af7Sopenharmony_ci const char* string = (const char*)glGetString(GL_SHADING_LANGUAGE_VERSION); 101e5c31af7Sopenharmony_ci const char referenceString[] = "OpenGL ES GLSL ES "; 102e5c31af7Sopenharmony_ci 103e5c31af7Sopenharmony_ci if (string == NULL) 104e5c31af7Sopenharmony_ci TCU_FAIL("Got invalid string"); 105e5c31af7Sopenharmony_ci 106e5c31af7Sopenharmony_ci if (!deStringBeginsWith(string, referenceString)) 107e5c31af7Sopenharmony_ci TCU_FAIL("Got invalid string prefix"); 108e5c31af7Sopenharmony_ci 109e5c31af7Sopenharmony_ci { 110e5c31af7Sopenharmony_ci std::string tmpString; 111e5c31af7Sopenharmony_ci char versionDelimiter; 112e5c31af7Sopenharmony_ci int glslMajor = 0; 113e5c31af7Sopenharmony_ci int glslMinor = 0; 114e5c31af7Sopenharmony_ci 115e5c31af7Sopenharmony_ci std::istringstream versionStream(string); 116e5c31af7Sopenharmony_ci versionStream >> tmpString; // OpenGL 117e5c31af7Sopenharmony_ci versionStream >> tmpString; // ES 118e5c31af7Sopenharmony_ci versionStream >> tmpString; // GLSL 119e5c31af7Sopenharmony_ci versionStream >> tmpString; // ES 120e5c31af7Sopenharmony_ci versionStream >> glslMajor; // x 121e5c31af7Sopenharmony_ci versionStream >> std::noskipws; 122e5c31af7Sopenharmony_ci versionStream >> versionDelimiter; // . 123e5c31af7Sopenharmony_ci versionStream >> glslMinor; // x 124e5c31af7Sopenharmony_ci 125e5c31af7Sopenharmony_ci if (!versionStream) 126e5c31af7Sopenharmony_ci TCU_FAIL("Got invalid string format"); 127e5c31af7Sopenharmony_ci } 128e5c31af7Sopenharmony_ci }); 129e5c31af7Sopenharmony_ci ES2F_ADD_API_CASE(extensions, "EXTENSIONS", 130e5c31af7Sopenharmony_ci { 131e5c31af7Sopenharmony_ci const char* extensions_cstring = (const char*)glGetString(GL_EXTENSIONS); 132e5c31af7Sopenharmony_ci if (extensions_cstring == NULL) 133e5c31af7Sopenharmony_ci m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid string"); 134e5c31af7Sopenharmony_ci }); 135e5c31af7Sopenharmony_ci} 136e5c31af7Sopenharmony_ci 137e5c31af7Sopenharmony_ci} // Functional 138e5c31af7Sopenharmony_ci} // gles2 139e5c31af7Sopenharmony_ci} // deqp 140