08099f476bbc034dc0d117912bb9d7a316029278
[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      Marcin Niesluchowski (m.niesluchow@samsung.com)
19  * @author      Lukasz Wrzosek (l.wrzosek@samsung.com)
20  * @version     1.0
21  * @brief       Header file with declaration of TestResultsCollectorBase
22  */
23
24 #ifndef DPL_TEST_RESULTS_COLLECTOR_H
25 #define DPL_TEST_RESULTS_COLLECTOR_H
26
27 #include <dpl/noncopyable.h>
28 #include <dpl/test/test_result.h>
29
30 #include <vector>
31 #include <list>
32 #include <map>
33 #include <string>
34 #include <memory>
35
36 namespace DPL {
37 namespace Test {
38 class TestResultsCollectorBase;
39 typedef std::shared_ptr<TestResultsCollectorBase>
40 TestResultsCollectorBasePtr;
41
42 class TestResultsCollectorBase :
43     private DPL::Noncopyable
44 {
45   public:
46     typedef TestResultsCollectorBase* (*CollectorConstructorFunc)();
47     typedef std::list<std::string> TestCaseIdList;
48
49     virtual ~TestResultsCollectorBase() {}
50
51     virtual bool Configure()
52     {
53         return true;
54     }
55     virtual void Start() { }
56     virtual void Finish() { }
57     virtual void CollectCurrentTestGroupName(const std::string& /*groupName*/)
58     {}
59
60     virtual void CollectTestsCasesList(const TestCaseIdList& /*list*/) {}
61     virtual void CollectResult(const std::string& id, const TestResult &result) = 0;
62     virtual std::string CollectorSpecificHelp() const
63     {
64         return "";
65     }
66     virtual bool ParseCollectorSpecificArg (const std::string& /*arg*/)
67     {
68         return false;
69     }
70
71     static TestResultsCollectorBase* Create(const std::string& name);
72     static void RegisterCollectorConstructor(
73         const std::string& name,
74         CollectorConstructorFunc
75         constructor);
76     static std::vector<std::string> GetCollectorsNames();
77
78   private:
79     typedef std::map<std::string, CollectorConstructorFunc> ConstructorsMap;
80     static ConstructorsMap m_constructorsMap;
81 };
82 }
83 }
84
85 #endif /* DPL_TEST_RESULTS_COLLECTOR_H */