cb29921416486d3f0fb5268057ac6348ef41e010
[platform/core/test/security-tests.git] / tests / framework / include / dpl / test / test_results_collector.h
1 /*
2  * Copyright (c) 2011 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 <vector>
28 #include <list>
29 #include <map>
30 #include <chrono>
31 #include <string>
32 #include <memory>
33
34 namespace DPL {
35 namespace Test {
36 class TestResultsCollectorBase;
37 typedef std::shared_ptr<TestResultsCollectorBase>
38 TestResultsCollectorBasePtr;
39
40 class TestResultsCollectorBase :
41     private DPL::Noncopyable
42 {
43   public:
44     typedef TestResultsCollectorBase* (*CollectorConstructorFunc)();
45     typedef std::list<std::string> TestCaseIdList;
46     struct FailStatus
47     {
48         enum Type
49         {
50             NONE,
51             FAILED,
52             IGNORED,
53             INTERNAL
54         };
55     };
56
57     virtual ~TestResultsCollectorBase() {}
58
59     virtual bool Configure()
60     {
61         return true;
62     }
63     virtual void Start() { }
64     virtual void Finish() { }
65     virtual void CollectCurrentTestGroupName(const std::string& /*groupName*/)
66     {}
67
68     virtual void CollectTestsCasesList(const TestCaseIdList& /*list*/) {}
69     virtual void CollectResult(const std::string& id,
70                                const std::string& description,
71                                const FailStatus::Type status = FailStatus::NONE,
72                                const std::string& reason = "",
73                                const bool& isPerformanceTest = false,
74                                const std::chrono::system_clock::duration& performanceTime = std::chrono::microseconds::zero(),
75                                const std::chrono::system_clock::duration& performanceMaxTime = std::chrono::microseconds::zero()) = 0;
76     virtual std::string CollectorSpecificHelp() const
77     {
78         return "";
79     }
80     virtual bool ParseCollectorSpecificArg (const std::string& /*arg*/)
81     {
82         return false;
83     }
84
85     static TestResultsCollectorBase* Create(const std::string& name);
86     static void RegisterCollectorConstructor(
87         const std::string& name,
88         CollectorConstructorFunc
89         constructor);
90     static std::vector<std::string> GetCollectorsNames();
91
92   private:
93     typedef std::map<std::string, CollectorConstructorFunc> ConstructorsMap;
94     static ConstructorsMap m_constructorsMap;
95 };
96 }
97 }
98
99 #endif /* DPL_TEST_RESULTS_COLLECTOR_H */