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