1 #ifndef _TCUTESTPACKAGE_HPP
2 #define _TCUTESTPACKAGE_HPP
3 /*-------------------------------------------------------------------------
4 * drawElements Quality Program Tester Core
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.
23 * \brief Base class for a test case.
24 *//*--------------------------------------------------------------------*/
26 #include "tcuDefs.hpp"
27 #include "tcuTestCase.hpp"
32 /*--------------------------------------------------------------------*//*!
33 * \brief Test case execution interface.
35 * TestCaseExecutor provides package-specific resources & initialization
38 * \todo [2015-03-18 pyry] Replace with following API:
43 * TestInstance (TestContext& testCtx);
44 * tcu::TestResult iterate (void);
47 * class TestInstanceFactory (???)
50 * TestInstance* createInstance (const TestCase* testCase, const std::string& path);
52 *//*--------------------------------------------------------------------*/
53 class TestCaseExecutor
56 virtual ~TestCaseExecutor (void) {}
58 virtual void init (TestCase* testCase, const std::string& path) = 0;
59 virtual void deinit (TestCase* testCase) = 0;
60 virtual TestNode::IterateResult iterate (TestCase* testCase) = 0;
63 /*--------------------------------------------------------------------*//*!
64 * \brief Base class for test packages.
66 * Test packages are root-level test groups. They also provide package-
67 * specific test case executor, see TestCaseExecutor.
68 *//*--------------------------------------------------------------------*/
69 class TestPackage : public TestNode
72 TestPackage (TestContext& testCtx, const char* name, const char* description);
73 virtual ~TestPackage (void);
75 virtual TestCaseExecutor* createExecutor (void) const = 0;
78 virtual Archive* getArchive (void) { return DE_NULL; }
80 virtual IterateResult iterate (void);
83 // TestPackageRegistry
85 typedef TestPackage* (*TestPackageCreateFunc) (TestContext& testCtx);
87 class TestPackageRegistry
92 PackageInfo (std::string name_, TestPackageCreateFunc createFunc_) : name(name_), createFunc(createFunc_) {}
95 TestPackageCreateFunc createFunc;
98 static TestPackageRegistry* getSingleton (void);
99 static void destroy (void);
101 void registerPackage (const char* name, TestPackageCreateFunc createFunc);
102 const std::vector<PackageInfo*>& getPackageInfos (void) const;
103 PackageInfo* getPackageInfoByName (const char* name) const;
104 TestPackage* createPackage (const char* name, TestContext& testCtx) const;
107 TestPackageRegistry (void);
108 ~TestPackageRegistry (void);
110 static TestPackageRegistry* getOrDestroy (bool isCreate);
113 std::vector<PackageInfo*> m_packageInfos;
116 // TestPackageDescriptor
118 class TestPackageDescriptor
121 TestPackageDescriptor (const char* name, TestPackageCreateFunc createFunc);
122 ~TestPackageDescriptor (void);
127 class TestPackageRoot : public TestNode
130 TestPackageRoot (TestContext& testCtx);
131 TestPackageRoot (TestContext& testCtx, const std::vector<TestNode*>& children);
132 TestPackageRoot (TestContext& testCtx, const TestPackageRegistry* packageRegistry);
133 virtual ~TestPackageRoot (void);
135 virtual IterateResult iterate (void);
140 #endif // _TCUTESTPACKAGE_HPP