Always apply flat qualifier to double inputs, same as int/uint
[platform/upstream/VK-GL-CTS.git] / external / openglcts / modules / common / glcContextFlagsTests.cpp
1 /*-------------------------------------------------------------------------
2  * OpenGL Conformance Test Suite
3  * -----------------------------
4  *
5  * Copyright (c) 2017 The Khronos Group Inc.
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 glcContextFlagsTests.cpp
21  * \brief Tests veryfing glGetIntegerv(GL_CONTEXT_FLAGS).
22  */ /*-------------------------------------------------------------------*/
23
24 #include "glcContextFlagsTests.hpp"
25 #include "gluRenderContext.hpp"
26 #include "glwEnums.hpp"
27 #include "glwFunctions.hpp"
28 #include "tcuCommandLine.hpp"
29 #include "tcuTestLog.hpp"
30
31 namespace glcts
32 {
33
34 class ContextFlagsCase : public tcu::TestCase
35 {
36 private:
37         glu::RenderContext* m_caseContext;
38         glu::ContextFlags   m_passedFlags;
39         glw::GLint                      m_expectedResult;
40         glu::ApiType            m_ApiType;
41
42         void createContext();
43
44 public:
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)
48                 , m_caseContext(NULL)
49                 , m_passedFlags(passedFlags)
50                 , m_expectedResult(expectedResult)
51                 , m_ApiType(apiType)
52         {
53         }
54
55         void releaseContext(void);
56
57         virtual void              deinit(void);
58         virtual IterateResult iterate(void);
59 };
60
61 void ContextFlagsCase::createContext()
62 {
63         glu::RenderConfig renderCfg(glu::ContextType(m_ApiType, m_passedFlags));
64
65         const tcu::CommandLine& commandLine = m_testCtx.getCommandLine();
66         glu::parseRenderConfig(&renderCfg, commandLine);
67
68         if (commandLine.getSurfaceType() != tcu::SURFACETYPE_WINDOW)
69                 throw tcu::NotSupportedError("Test not supported in non-windowed context");
70
71         m_caseContext = glu::createRenderContext(m_testCtx.getPlatform(), commandLine, renderCfg);
72 }
73
74 void ContextFlagsCase::releaseContext(void)
75 {
76         if (m_caseContext)
77         {
78                 delete m_caseContext;
79                 m_caseContext = NULL;
80         }
81 }
82
83 void ContextFlagsCase::deinit(void)
84 {
85         releaseContext();
86 }
87
88 tcu::TestNode::IterateResult ContextFlagsCase::iterate(void)
89 {
90         createContext();
91
92         glw::GLint                        flags = 0;
93         const glw::Functions& gl = m_caseContext->getFunctions();
94         gl.getIntegerv(GL_CONTEXT_FLAGS, &flags);
95         GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv");
96
97         if (flags != m_expectedResult)
98         {
99                 m_testCtx.getLog() << tcu::TestLog::Message << "Test failed! glGet returned wrong  value " << flags
100                                                    << ", expected " << m_expectedResult << "]." << tcu::TestLog::EndMessage;
101
102                 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
103         }
104         else
105                 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
106
107         releaseContext();
108         return STOP;
109 }
110
111 ContextFlagsTests::ContextFlagsTests(tcu::TestContext& testCtx, glu::ApiType apiType)
112         : tcu::TestCaseGroup(testCtx, "context_flags", "Verifies if context flags query results are as expected.")
113         , m_ApiType(apiType)
114 {
115 }
116
117 void ContextFlagsTests::init()
118 {
119         tcu::TestCaseGroup::init();
120
121         try
122         {
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));
129
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.",
133                                                                           m_ApiType));
134         }
135         catch (...)
136         {
137                 // Destroy context.
138                 tcu::TestCaseGroup::deinit();
139                 throw;
140         }
141 }
142
143 } // glcts namespace