summaryrefslogtreecommitdiff
path: root/vcore/src/dpl/test/include/dpl/test/test_results_collector.h
blob: 5d86ef67a5bc13b73f47bfd64a97027d31467ae4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/*
 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */
/*
 * @file        test_results_collector.h
 * @author      Lukasz Wrzosek (l.wrzosek@samsung.com)
 * @version     1.0
 * @brief       Header file with declaration of TestResultsCollectorBase
 */

#ifndef DPL_TEST_RESULTS_COLLECTOR_H
#define DPL_TEST_RESULTS_COLLECTOR_H

#include <dpl/noncopyable.h>
#include <dpl/availability.h>
#include <vector>
#include <list>
#include <map>
#include <string>
#include <memory>

namespace VcoreDPL {
namespace Test {
class TestResultsCollectorBase;
typedef std::shared_ptr<TestResultsCollectorBase>
TestResultsCollectorBasePtr;

class TestResultsCollectorBase :
    private VcoreDPL::Noncopyable
{
  public:
    typedef TestResultsCollectorBase* (*CollectorConstructorFunc)();
    typedef std::list<std::string> TestCaseIdList;
    struct FailStatus
    {
        enum Type
        {
            NONE,
            FAILED,
            IGNORED,
            INTERNAL
        };
    };

    virtual ~TestResultsCollectorBase() {}

    virtual bool Configure()
    {
        return true;
    }
    virtual void Start(int count) { DPL_UNUSED_PARAM(count); }
    virtual void Finish() { }
    virtual void CollectCurrentTestGroupName(const std::string& /*groupName*/)
    {}

    virtual void CollectTestsCasesList(const TestCaseIdList& /*list*/) {}
    virtual void CollectResult(const std::string& id,
                               const std::string& description,
                               const FailStatus::Type status = FailStatus::NONE,
                               const std::string& reason = "") = 0;
    virtual std::string CollectorSpecificHelp() const
    {
        return "";
    }
    virtual bool ParseCollectorSpecificArg (const std::string& /*arg*/)
    {
        return false;
    }

    static TestResultsCollectorBase* Create(const std::string& name);
    static void RegisterCollectorConstructor(
        const std::string& name,
        CollectorConstructorFunc
        constructor);
    static std::vector<std::string> GetCollectorsNames();

  private:
    typedef std::map<std::string, CollectorConstructorFunc> ConstructorsMap;
    static ConstructorsMap m_constructorsMap;
};
}
}

#endif /* DPL_TEST_RESULTS_COLLECTOR_H */