1 /*-------------------------------------------------------------------------
2 * OpenGL Conformance Test Suite
3 * -----------------------------
5 * Copyright (c) 2017 The Khronos Group Inc.
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.
20 * \file glcContextFlagsTests.cpp
21 * \brief Tests veryfing glGetIntegerv(GL_CONTEXT_FLAGS).
22 */ /*-------------------------------------------------------------------*/
24 #include "glcContextFlagsTests.hpp"
25 #include "gluRenderContext.hpp"
26 #include "glwEnums.hpp"
27 #include "glwFunctions.hpp"
28 #include "tcuCommandLine.hpp"
29 #include "tcuTestLog.hpp"
34 class ContextFlagsCase : public tcu::TestCase
37 glu::RenderContext* m_caseContext;
38 glu::ContextFlags m_passedFlags;
39 glw::GLint m_expectedResult;
40 glu::ApiType m_ApiType;
45 ContextFlagsCase(tcu::TestContext& testCtx, glu::ContextFlags passedFlags, glw::GLint expectedResult,
46 const char* name, const char* description, glu::ApiType apiType)
47 : tcu::TestCase(testCtx, name, description)
49 , m_passedFlags(passedFlags)
50 , m_expectedResult(expectedResult)
55 void releaseContext(void);
57 virtual void deinit(void);
58 virtual IterateResult iterate(void);
61 void ContextFlagsCase::createContext()
63 glu::RenderConfig renderCfg(glu::ContextType(m_ApiType, m_passedFlags));
65 const tcu::CommandLine& commandLine = m_testCtx.getCommandLine();
66 glu::parseRenderConfig(&renderCfg, commandLine);
68 if (commandLine.getSurfaceType() != tcu::SURFACETYPE_WINDOW)
69 throw tcu::NotSupportedError("Test not supported in non-windowed context");
71 m_caseContext = glu::createRenderContext(m_testCtx.getPlatform(), commandLine, renderCfg);
74 void ContextFlagsCase::releaseContext(void)
83 void ContextFlagsCase::deinit(void)
88 tcu::TestNode::IterateResult ContextFlagsCase::iterate(void)
93 const glw::Functions& gl = m_caseContext->getFunctions();
94 gl.getIntegerv(GL_CONTEXT_FLAGS, &flags);
95 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv");
97 if (flags != m_expectedResult)
99 m_testCtx.getLog() << tcu::TestLog::Message << "Test failed! glGet returned wrong value " << flags
100 << ", expected " << m_expectedResult << "]." << tcu::TestLog::EndMessage;
102 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
105 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
111 ContextFlagsTests::ContextFlagsTests(tcu::TestContext& testCtx, glu::ApiType apiType)
112 : tcu::TestCaseGroup(testCtx, "context_flags", "Verifies if context flags query results are as expected.")
117 void ContextFlagsTests::init()
119 tcu::TestCaseGroup::init();
123 addChild(new ContextFlagsCase(m_testCtx, glu::ContextFlags(0), 0, "no_flags_set_case",
124 "Verifies no flags case.", m_ApiType));
125 addChild(new ContextFlagsCase(m_testCtx, glu::CONTEXT_DEBUG, GL_CONTEXT_FLAG_DEBUG_BIT, "debug_flag_set_case",
126 "Verifies debug flag case..", m_ApiType));
127 addChild(new ContextFlagsCase(m_testCtx, glu::CONTEXT_ROBUST, GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT,
128 "robust_flag_set_case", "Verifies robust access flag case.", m_ApiType));
130 addChild(new ContextFlagsCase(m_testCtx, glu::CONTEXT_DEBUG | glu::CONTEXT_ROBUST,
131 GL_CONTEXT_FLAG_DEBUG_BIT | GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT,
132 "all_flags_set_case", "Verifies both debug and robust access flags case.",
138 tcu::TestCaseGroup::deinit();