16bfa5a9d0ba74352531fb565149dc88fcad820a
[platform/core/test/security-tests.git] / src / framework / include / dpl / test / test_results_collector_xml.h
1 /*
2  * Copyright (c) 2014 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_xml.h
18  * @author      Marcin Niesluchowski (m.niesluchow@samsung.com)
19  * @version     1.0
20  * @brief       Header file containing XmlCollector class declaration
21  */
22
23 #ifndef DPL_TEST_RESULTS_COLLECTOR_XML_H
24 #define DPL_TEST_RESULTS_COLLECTOR_XML_H
25
26 #include <dpl/scoped_fclose.h>
27 #include <dpl/test/statistic.h>
28 #include <dpl/test/test_results_collector.h>
29
30 namespace DPL {
31 namespace Test {
32
33 class XmlCollector :
34     public TestResultsCollectorBase
35 {
36 public:
37     static TestResultsCollectorBase* Constructor();
38
39 private:
40     XmlCollector();
41
42     virtual std::string CollectorSpecificHelp() const;
43     virtual bool ParseCollectorSpecificArg(const std::string& arg);
44     virtual bool Configure();
45     virtual void Start();
46     virtual void CollectCurrentTestGroupName(const std::string& name);
47     virtual void CollectResult(const std::string& id,
48                                const FailStatus status = FailStatus::NONE,
49                                const std::string& reason = "",
50                                const bool& isPerformanceTest = false,
51                                const std::chrono::system_clock::duration& performanceTime
52                                    = std::chrono::microseconds::zero(),
53                                const std::chrono::system_clock::duration& performanceMaxTime
54                                    = std::chrono::microseconds::zero());
55     virtual void Finish();
56
57     void GroupStart(const std::size_t pos, const std::string& name);
58     std::size_t GetCurrentGroupPosition() const;
59     void UpdateGroupHeader(const std::size_t groupPosition,
60                            const unsigned int tests,
61                            const unsigned int failures,
62                            const unsigned int skipped);
63     void UpdateElementAttribute(const std::size_t elementPosition,
64                                 const std::string& name,
65                                 const std::string& value);
66     std::string UIntToString(const unsigned int value);
67     void GroupFinish(const std::size_t groupPosition);
68     void PrintfErrorMessage(const char* type, const std::string& message);
69     void PrintfIgnoredMessage(const char* type, const std::string& message);
70     void FlushOutput();
71     std::string EscapeSpecialCharacters(std::string s);
72
73     std::string m_filename;
74     ScopedFClose m_fp;
75     Statistic m_stats;
76     std::string m_outputBuffer;
77     std::string m_resultBuffer;
78     bool m_verbosity;
79 };
80
81 } // namespace Test
82 } // namespace DPL
83
84 #endif // DPL_TEST_RESULTS_COLLECTOR_XML_H