1 #ifndef _VKTTESTGROUPUTIL_HPP
2 #define _VKTTESTGROUPUTIL_HPP
3 /*-------------------------------------------------------------------------
4 * Vulkan Conformance Tests
5 * ------------------------
7 * Copyright (c) 2016 Google Inc.
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
23 * \brief TestCaseGroup utilities
24 *//*--------------------------------------------------------------------*/
26 #include "tcuDefs.hpp"
27 #include "tcuTestCase.hpp"
32 class TestGroupHelper0 : public tcu::TestCaseGroup
35 typedef void (*CreateChildrenFunc) (tcu::TestCaseGroup* testGroup);
36 typedef void (*CleanupGroupFunc) (tcu::TestCaseGroup* testGroup);
38 TestGroupHelper0 (tcu::TestContext& testCtx,
39 const std::string& name,
40 const std::string& description,
41 CreateChildrenFunc createChildren,
42 CleanupGroupFunc cleanupGroup)
43 : tcu::TestCaseGroup(testCtx, name.c_str(), description.c_str())
44 , m_createChildren(createChildren)
45 , m_cleanupGroup(cleanupGroup)
49 ~TestGroupHelper0 (void)
55 m_createChildren(this);
65 const CreateChildrenFunc m_createChildren;
66 const CleanupGroupFunc m_cleanupGroup;
69 template<typename Arg0>
70 class TestGroupHelper1 : public tcu::TestCaseGroup
73 typedef void (*CreateChildrenFunc) (tcu::TestCaseGroup* testGroup, Arg0 arg0);
74 typedef void (*CleanupGroupFunc) (tcu::TestCaseGroup* testGroup, Arg0 arg0);
76 TestGroupHelper1 (tcu::TestContext& testCtx,
77 const std::string& name,
78 const std::string& description,
79 CreateChildrenFunc createChildren,
81 CleanupGroupFunc cleanupGroup)
82 : tcu::TestCaseGroup (testCtx, name.c_str(), description.c_str())
83 , m_createChildren (createChildren)
84 , m_cleanupGroup (cleanupGroup)
88 void init (void) { m_createChildren(this, m_arg0); }
89 void deinit (void) { if (m_cleanupGroup) m_cleanupGroup(this, m_arg0); }
92 const CreateChildrenFunc m_createChildren;
93 const CleanupGroupFunc m_cleanupGroup;
97 template<typename Arg0, typename Arg1>
98 class TestGroupHelper2 : public tcu::TestCaseGroup
101 typedef void(*CreateChildrenFunc) (tcu::TestCaseGroup* testGroup, Arg0 arg0, Arg1 arg1);
102 typedef void(*CleanupGroupFunc) (tcu::TestCaseGroup* testGroup, Arg0 arg0, Arg1 arg1);
104 TestGroupHelper2(tcu::TestContext& testCtx,
105 const std::string& name,
106 const std::string& description,
107 CreateChildrenFunc createChildren,
110 CleanupGroupFunc cleanupGroup)
111 : tcu::TestCaseGroup (testCtx, name.c_str(), description.c_str())
112 , m_createChildren (createChildren)
113 , m_cleanupGroup (cleanupGroup)
118 void init (void) { m_createChildren(this, m_arg0, m_arg1); }
119 void deinit (void) { if (m_cleanupGroup) m_cleanupGroup(this, m_arg0, m_arg1); }
122 const CreateChildrenFunc m_createChildren;
123 const CleanupGroupFunc m_cleanupGroup;
128 inline tcu::TestCaseGroup* createTestGroup (tcu::TestContext& testCtx,
129 const std::string& name,
130 const std::string& description,
131 TestGroupHelper0::CreateChildrenFunc createChildren,
132 TestGroupHelper0::CleanupGroupFunc cleanupGroup = DE_NULL)
134 return new TestGroupHelper0(testCtx, name, description, createChildren, cleanupGroup);
137 template<typename Arg0>
138 tcu::TestCaseGroup* createTestGroup (tcu::TestContext& testCtx,
139 const std::string& name,
140 const std::string& description,
141 typename TestGroupHelper1<Arg0>::CreateChildrenFunc createChildren,
143 typename TestGroupHelper1<Arg0>::CleanupGroupFunc cleanupGroup = DE_NULL)
145 return new TestGroupHelper1<Arg0>(testCtx, name, description, createChildren, arg0, cleanupGroup);
147 template<typename Arg0, typename Arg1>
148 tcu::TestCaseGroup* createTestGroup (tcu::TestContext& testCtx,
149 const std::string& name,
150 const std::string& description,
151 typename TestGroupHelper2<Arg0, Arg1>::CreateChildrenFunc createChildren,
154 typename TestGroupHelper2<Arg0, Arg1>::CleanupGroupFunc cleanupGroup = DE_NULL)
156 return new TestGroupHelper2<Arg0, Arg1>(testCtx, name, description, createChildren, arg0, arg1, cleanupGroup);
159 inline void addTestGroup (tcu::TestCaseGroup* parent,
160 const std::string& name,
161 const std::string& description,
162 TestGroupHelper0::CreateChildrenFunc createChildren)
164 parent->addChild(createTestGroup(parent->getTestContext(), name, description, createChildren));
167 template<typename Arg0>
168 void addTestGroup (tcu::TestCaseGroup* parent,
169 const std::string& name,
170 const std::string& description,
171 typename TestGroupHelper1<Arg0>::CreateChildrenFunc createChildren,
173 typename TestGroupHelper1<Arg0>::CleanupGroupFunc cleanupGroup = DE_NULL)
175 parent->addChild(createTestGroup<Arg0>(parent->getTestContext(), name, description, createChildren, arg0, cleanupGroup));
178 template<typename Arg0, typename Arg1>
179 void addTestGroup(tcu::TestCaseGroup* parent,
180 const std::string& name,
181 const std::string& description,
182 typename TestGroupHelper2<Arg0,Arg1>::CreateChildrenFunc createChildren,
185 typename TestGroupHelper2<Arg0,Arg1>::CleanupGroupFunc cleanupGroup = DE_NULL)
187 parent->addChild(createTestGroup<Arg0,Arg1>(parent->getTestContext(), name, description, createChildren, arg0, arg1, cleanupGroup));
192 #endif // _VKTTESTGROUPUTIL_HPP