1 #ifndef _XETESTCASE_HPP
2 #define _XETESTCASE_HPP
3 /*-------------------------------------------------------------------------
4 * drawElements Quality Program Test Executor
5 * ------------------------------------------
7 * Copyright 2014 The Android Open Source Project
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.
24 *//*--------------------------------------------------------------------*/
38 TESTCASETYPE_SELF_VALIDATE,
39 TESTCASETYPE_CAPABILITY,
40 TESTCASETYPE_ACCURACY,
41 TESTCASETYPE_PERFORMANCE,
46 const char* getTestCaseTypeName (TestCaseType caseType);
52 TESTNODETYPE_TEST_CASE,
63 virtual ~TestNode (void) {}
65 TestNodeType getNodeType (void) const { return m_nodeType; }
66 const char* getName (void) const { return m_name.c_str(); }
67 const TestGroup* getParent (void) const { return m_parent; }
69 void getFullPath (std::string& path) const;
70 std::string getFullPath (void) const { std::string str; getFullPath(str); return str; }
72 const TestNode* find (const char* path) const;
73 TestNode* find (const char* path);
76 TestNode (TestGroup* parent, TestNodeType nodeType, const char* name, const char* desc);
79 TestNode (const TestNode& other);
80 TestNode& operator= (const TestNode& other);
83 TestNodeType m_nodeType;
85 std::string m_description;
88 class TestGroup : public TestNode
93 int getNumChildren (void) const { return (int)m_children.size(); }
94 TestNode* getChild (int ndx) { return m_children[ndx]; }
95 const TestNode* getChild (int ndx) const { return m_children[ndx]; }
97 TestNode* findChildNode (const char* path);
98 const TestNode* findChildNode (const char* path) const;
100 TestGroup* createGroup (const char* name, const char* description);
101 TestCase* createCase (TestCaseType caseType, const char* name, const char* description);
104 TestGroup (TestGroup* parent, TestNodeType nodeType, const char* name, const char* description);
107 std::vector<TestNode*> m_children;
108 std::set<std::string> m_childNames; //!< Used for checking for duplicate test case names.
110 // For adding TestCase to m_children. \todo [2012-06-15 pyry] Is the API broken perhaps?
111 friend class TestNode;
114 class TestRoot : public TestGroup
120 class TestCase : public TestNode
125 TestCaseType getCaseType (void) const { return m_caseType; }
127 static TestCase* createAsChild (TestGroup* parent, TestCaseType caseType, const char* name, const char* description);
130 TestCase (TestGroup* parent, TestCaseType caseType, const char* name, const char* description);
133 TestCaseType m_caseType;
136 // Helper class for efficiently constructing TestCase hierarchy from test case list.
137 class TestHierarchyBuilder
140 TestHierarchyBuilder (TestRoot* root);
141 ~TestHierarchyBuilder (void);
143 TestCase* createCase (const char* path, TestCaseType caseType);
146 TestHierarchyBuilder (const TestHierarchyBuilder& other);
147 TestHierarchyBuilder& operator= (const TestHierarchyBuilder& other);
150 std::map<std::string, TestGroup*> m_groupMap;
153 // Helper class for computing and iterating test sets.
160 bool empty (void) const { return m_set.empty(); }
162 void add (const TestNode* node);
163 void addCase (const TestCase* testCase);
164 void addGroup (const TestGroup* testGroup);
166 void remove (const TestNode* node);
167 void removeCase (const TestCase* testCase);
168 void removeGroup (const TestGroup* testGroup);
170 bool hasNode (const TestNode* node) const { return m_set.find(node) != m_set.end(); }
173 std::set<const TestNode*> m_set;
176 class ConstTestNodeIterator
179 static ConstTestNodeIterator begin (const TestNode* root);
180 static ConstTestNodeIterator end (const TestNode* root);
182 ConstTestNodeIterator& operator++ (void);
183 ConstTestNodeIterator operator++ (int);
185 const TestNode* operator* (void) const;
187 bool operator!= (const ConstTestNodeIterator& other) const;
190 ConstTestNodeIterator (const TestNode* root);
195 GroupState (const TestGroup* group_) : group(group_), childNdx(0) {}
197 const TestGroup* group;
200 bool operator!= (const GroupState& other) const
202 return group != other.group || childNdx != other.childNdx;
205 bool operator== (const GroupState& other) const
207 return group == other.group && childNdx == other.childNdx;
211 const TestNode* m_root;
212 std::vector<GroupState> m_iterStack;
215 // \todo [2012-06-19 pyry] Implement following iterators:
216 // - TestNodeIterator
217 // - ConstTestSetIterator
222 #endif // _XETESTCASE_HPP