• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef _VKTTESTGROUPUTIL_HPP
2 #define _VKTTESTGROUPUTIL_HPP
3 /*-------------------------------------------------------------------------
4  * Vulkan Conformance Tests
5  * ------------------------
6  *
7  * Copyright (c) 2016 Google Inc.
8  *
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
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
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.
20  *
21  *//*!
22  * \file
23  * \brief TestCaseGroup utilities
24  *//*--------------------------------------------------------------------*/
25 
26 #include "tcuDefs.hpp"
27 #include "tcuTestCase.hpp"
28 
29 namespace vkt
30 {
31 
32 class TestGroupHelper0 : public tcu::TestCaseGroup
33 {
34 public:
35 	typedef void (*CreateChildrenFunc) (tcu::TestCaseGroup* testGroup);
36 
37 								TestGroupHelper0	(tcu::TestContext&		testCtx,
38 													 const std::string&		name,
39 													 const std::string&		description,
40 													 CreateChildrenFunc		createChildren);
41 								~TestGroupHelper0	(void);
42 
43 	void						init				(void);
44 
45 private:
46 	const CreateChildrenFunc	m_createChildren;
47 };
48 
49 template<typename Arg0>
50 class TestGroupHelper1 : public tcu::TestCaseGroup
51 {
52 public:
53 	typedef void (*CreateChildrenFunc) (tcu::TestCaseGroup* testGroup, Arg0 arg0);
54 
TestGroupHelper1(tcu::TestContext & testCtx,const std::string & name,const std::string & description,CreateChildrenFunc createChildren,const Arg0 & arg0)55 								TestGroupHelper1	(tcu::TestContext&		testCtx,
56 													 const std::string&		name,
57 													 const std::string&		description,
58 													 CreateChildrenFunc		createChildren,
59 													 const Arg0&			arg0)
60 									: tcu::TestCaseGroup	(testCtx, name.c_str(), description.c_str())
61 									, m_createChildren		(createChildren)
62 									, m_arg0				(arg0)
63 								{}
64 
init(void)65 	void						init				(void) { m_createChildren(this, m_arg0); }
66 
67 private:
68 	const CreateChildrenFunc	m_createChildren;
69 	const Arg0					m_arg0;
70 };
71 
createTestGroup(tcu::TestContext & testCtx,const std::string & name,const std::string & description,TestGroupHelper0::CreateChildrenFunc createChildren)72 inline tcu::TestCaseGroup* createTestGroup (tcu::TestContext&						testCtx,
73 											const std::string&						name,
74 											const std::string&						description,
75 											TestGroupHelper0::CreateChildrenFunc	createChildren)
76 {
77 	return new TestGroupHelper0(testCtx, name, description, createChildren);
78 }
79 
80 template<typename Arg0>
createTestGroup(tcu::TestContext & testCtx,const std::string & name,const std::string & description,typename TestGroupHelper1<Arg0>::CreateChildrenFunc createChildren,Arg0 arg0)81 tcu::TestCaseGroup* createTestGroup (tcu::TestContext&										testCtx,
82 									 const std::string&										name,
83 									 const std::string&										description,
84 									 typename TestGroupHelper1<Arg0>::CreateChildrenFunc	createChildren,
85 									 Arg0													arg0)
86 {
87 	return new TestGroupHelper1<Arg0>(testCtx, name, description, createChildren, arg0);
88 }
89 
addTestGroup(tcu::TestCaseGroup * parent,const std::string & name,const std::string & description,TestGroupHelper0::CreateChildrenFunc createChildren)90 inline void addTestGroup (tcu::TestCaseGroup*					parent,
91 						  const std::string&					name,
92 						  const std::string&					description,
93 						  TestGroupHelper0::CreateChildrenFunc	createChildren)
94 {
95 	parent->addChild(createTestGroup(parent->getTestContext(), name, description, createChildren));
96 }
97 
98 template<typename Arg0>
addTestGroup(tcu::TestCaseGroup * parent,const std::string & name,const std::string & description,typename TestGroupHelper1<Arg0>::CreateChildrenFunc createChildren,Arg0 arg0)99 void addTestGroup (tcu::TestCaseGroup*									parent,
100 				   const std::string&									name,
101 				   const std::string&									description,
102 				   typename TestGroupHelper1<Arg0>::CreateChildrenFunc	createChildren,
103 				   Arg0													arg0)
104 {
105 	parent->addChild(createTestGroup<Arg0>(parent->getTestContext(), name, description, createChildren, arg0));
106 }
107 
108 } // vkt
109 
110 #endif // _VKTTESTGROUPUTIL_HPP
111