6c4e24b38974df65c3ca52f83ade6a5de038f2ce
[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/shared_ptr.h>
27 #include <dpl/noncopyable.h>
28 #include <vector>
29 #include <list>
30 #include <map>
31 #include <string>
32
33 namespace DPL
34 {
35 namespace Test
36 {
37
38 class TestResultsCollectorBase;
39 typedef DPL::SharedPtr<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     struct FailStatus
49     {
50         enum Type
51         {
52             NONE,
53             FAILED,
54             IGNORED,
55             TODO,
56             INTERNAL
57         };
58     };
59
60     virtual ~TestResultsCollectorBase() {}
61
62     virtual bool Configure() { return true; }
63     virtual void Start() { }
64     virtual void Finish() { }
65     virtual void CollectCurrentTestGroupName(const std::string& /*groupName*/) {}
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 { return ""; }
73     virtual bool ParseCollectorSpecificArg (const std::string& /*arg*/)
74     {
75         return false;
76     }
77
78     static TestResultsCollectorBase* Create(const std::string& name);
79     static void RegisterCollectorConstructor(const std::string& name,
80                                              CollectorConstructorFunc constructor);
81     static std::vector<std::string> GetCollectorsNames();
82
83   private:
84     typedef std::map<std::string, CollectorConstructorFunc> ConstructorsMap;
85     static ConstructorsMap m_constructorsMap;
86 };
87
88 }
89 }
90
91 #endif /* DPL_TEST_RESULTS_COLLECTOR_H */