Add new framebuffer fetch extension tests am: 2a609fb223
[platform/upstream/VK-GL-CTS.git] / modules / gles2 / functional / es2fApiCase.cpp
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 API test case.
22  *//*--------------------------------------------------------------------*/
23
24 #include "es2fApiCase.hpp"
25 #include "gluStrUtil.hpp"
26 #include "gluRenderContext.hpp"
27
28 #include <algorithm>
29
30 using std::string;
31 using std::vector;
32
33 namespace deqp
34 {
35 namespace gles2
36 {
37 namespace Functional
38 {
39
40 ApiCase::ApiCase (Context& context, const char* name, const char* description)
41         : TestCase              (context, name, description)
42         , CallLogWrapper(context.getRenderContext().getFunctions(), context.getTestContext().getLog())
43         , m_log                 (context.getTestContext().getLog())
44 {
45 }
46
47 ApiCase::~ApiCase (void)
48 {
49 }
50
51 ApiCase::IterateResult ApiCase::iterate (void)
52 {
53         // Initialize result to pass.
54         m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
55
56         // Enable call logging.
57         enableLogging(true);
58
59         // Run test.
60         test();
61
62         return STOP;
63 }
64
65 void ApiCase::expectError (deUint32 expected)
66 {
67         deUint32 err = glGetError();
68         if (err != expected)
69         {
70                 m_testCtx.getLog() << tcu::TestLog::Message << "// ERROR: expected " << glu::getErrorStr(expected) << tcu::TestLog::EndMessage;
71                 if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
72                         m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid error");
73         }
74 }
75
76 void ApiCase::expectError (deUint32 expected0, deUint32 expected1)
77 {
78         deUint32 err = glGetError();
79         if (err != expected0 && err != expected1)
80         {
81                 m_log << tcu::TestLog::Message << "// ERROR: expected " << glu::getErrorStr(expected0) << " or " << glu::getErrorStr(expected1) << tcu::TestLog::EndMessage;
82                 if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
83                         m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid error");
84         }
85 }
86
87 void ApiCase::checkBooleans (deUint8 value, deUint8 expected)
88 {
89         checkBooleans((deInt32)value, expected);
90 }
91
92 void ApiCase::checkBooleans (deInt32 value, deUint8 expected)
93 {
94         if (value != (deInt32)expected)
95         {
96                 m_log << tcu::TestLog::Message << "// ERROR: expected " << (expected    ? "GL_TRUE" : "GL_FALSE") << tcu::TestLog::EndMessage;
97                 if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
98                         m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value");
99         }
100 }
101
102 void ApiCase::getSupportedExtensions (const deUint32 numSupportedValues, const deUint32 extension, std::vector<int>& values)
103 {
104         deInt32 numFormats;
105         GLU_CHECK_CALL(glGetIntegerv(numSupportedValues, &numFormats));
106         if (numFormats == 0)
107         {
108                 m_testCtx.getLog() << tcu::TestLog::Message << "// No supported extensions available." << tcu::TestLog::EndMessage;
109                 return;
110         }
111         values.resize(numFormats);
112         GLU_CHECK_CALL(glGetIntegerv(extension, &values[0]));
113 }
114
115 } // Functional
116 } // gles2
117 } // deqp