6b1f6feb2b9699351aed3fe0b642d6483b0cee20
[platform/core/test/security-tests.git] / src / framework / include / dpl / test / test_results_collector.h
1 /*
2  * Copyright (c) 2014-2015 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *    Licensed under the Apache License, Version 2.0 (the "License");
5  *    you may not use this file except in compliance with the License.
6  *    You may obtain a copy of the License at
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *    Unless required by applicable law or agreed to in writing, software
11  *    distributed under the License is distributed on an "AS IS" BASIS,
12  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *    See the License for the specific language governing permissions and
14  *    limitations under the License.
15  */
16 /*
17  * @file        test_results_collector.h
18  * @author      Lukasz Wrzosek (l.wrzosek@samsung.com)
19  * @version     1.0
20  * @brief       Header file with declaration of TestResultsCollectorBase
21  */
22
23 #ifndef DPL_TEST_RESULTS_COLLECTOR_H
24 #define DPL_TEST_RESULTS_COLLECTOR_H
25
26 #include <dpl/noncopyable.h>
27 #include <dpl/test/performance_result.h>
28
29 #include <vector>
30 #include <list>
31 #include <map>
32 #include <string>
33 #include <memory>
34
35 namespace DPL {
36 namespace Test {
37 class TestResultsCollectorBase;
38 typedef std::shared_ptr<TestResultsCollectorBase>
39 TestResultsCollectorBasePtr;
40
41 class TestResultsCollectorBase :
42     private DPL::Noncopyable
43 {
44   public:
45     typedef TestResultsCollectorBase* (*CollectorConstructorFunc)();
46     typedef std::list<std::string> TestCaseIdList;
47     enum class FailStatus
48     {
49         NONE,
50         FAILED,
51         IGNORED
52     };
53
54     virtual ~TestResultsCollectorBase() {}
55
56     virtual bool Configure()
57     {
58         return true;
59     }
60     virtual void Start() { }
61     virtual void Finish() { }
62     virtual void CollectCurrentTestGroupName(const std::string& /*groupName*/)
63     {}
64
65     virtual void CollectTestsCasesList(const TestCaseIdList& /*list*/) {}
66     virtual void CollectResult(const std::string& id,
67                                const FailStatus status = FailStatus::NONE,
68                                const std::string& reason = "",
69                                const ConstPerformanceResultPtr &performanceResult = nullptr) = 0;
70     virtual std::string CollectorSpecificHelp() const
71     {
72         return "";
73     }
74     virtual bool ParseCollectorSpecificArg (const std::string& /*arg*/)
75     {
76         return false;
77     }
78
79     static TestResultsCollectorBase* Create(const std::string& name);
80     static void RegisterCollectorConstructor(
81         const std::string& name,
82         CollectorConstructorFunc
83         constructor);
84     static std::vector<std::string> GetCollectorsNames();
85
86   private:
87     typedef std::map<std::string, CollectorConstructorFunc> ConstructorsMap;
88     static ConstructorsMap m_constructorsMap;
89 };
90 }
91 }
92
93 #endif /* DPL_TEST_RESULTS_COLLECTOR_H */