1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program OpenGL ES 3.1 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 Shared structures for ES 3.1 negative API tests
22 *//*--------------------------------------------------------------------*/
23
24 #include "es31fNegativeTestShared.hpp"
25
26 #include "tcuResultCollector.hpp"
27
28 #include "gluRenderContext.hpp"
29 #include "glwFunctions.hpp"
30
31 namespace deqp
32 {
33 namespace gles31
34 {
35 namespace Functional
36 {
37 namespace NegativeTestShared
38 {
39
40 using glw::GLenum;
41 using tcu::TestLog;
42 using std::string;
43
ErrorCase(Context & ctx,const char * name,const char * desc)44 ErrorCase::ErrorCase (Context& ctx, const char* name, const char* desc)
45 : TestCase(ctx, name, desc)
46 {
47 }
48
NegativeTestContext(ErrorCase & host,glu::RenderContext & renderCtx,const glu::ContextInfo & ctxInfo,tcu::TestLog & log,tcu::ResultCollector & results,bool enableLogging_)49 NegativeTestContext::NegativeTestContext (ErrorCase& host,
50 glu::RenderContext& renderCtx,
51 const glu::ContextInfo& ctxInfo,
52 tcu::TestLog& log,
53 tcu::ResultCollector& results,
54 bool enableLogging_)
55 : glu::CallLogWrapper (renderCtx.getFunctions(), log)
56 , m_host (host)
57 , m_renderCtx (renderCtx)
58 , m_ctxInfo (ctxInfo)
59 , m_results (results)
60 , m_openSections (0)
61 {
62 enableLogging(enableLogging_);
63 }
64
~NegativeTestContext()65 NegativeTestContext::~NegativeTestContext ()
66 {
67 while (m_openSections--)
68 getLog() << TestLog::EndSection;
69 }
70
fail(const string & msg)71 void NegativeTestContext::fail (const string& msg)
72 {
73 m_results.addResult(QP_TEST_RESULT_FAIL, msg);
74 }
75
getInteger(GLenum pname) const76 int NegativeTestContext::getInteger (GLenum pname) const
77 {
78 int retval = 0;
79 m_renderCtx.getFunctions().getIntegerv(pname, &retval);
80 return retval;
81 }
82
beginSection(const string & desc)83 void NegativeTestContext::beginSection (const string& desc)
84 {
85 if (isLoggingEnabled())
86 {
87 getLog() << TestLog::Section("callstream", desc);
88 m_openSections++;
89 }
90 }
91
endSection(void)92 void NegativeTestContext::endSection (void)
93 {
94 if (isLoggingEnabled())
95 {
96 DE_ASSERT (m_openSections > 0);
97 getLog() << TestLog::EndSection;
98 m_openSections--;
99 }
100 }
101
expectError(GLenum error)102 void NegativeTestContext::expectError (GLenum error)
103 {
104 m_host.expectError(error, error);
105 }
106
expectError(GLenum error0,GLenum error1)107 void NegativeTestContext::expectError (GLenum error0, GLenum error1)
108 {
109 m_host.expectError(error0, error1);
110 }
111
112 } // NegativeTestShared
113 } // Functional
114 } // gles31
115 } // deqp
116