mapnik/test/visual/report.hpp

129 lines
2.8 KiB
C++
Raw Permalink Normal View History

2015-02-17 17:28:49 +01:00
/*****************************************************************************
*
* This file is part of Mapnik (c++ mapping toolkit)
*
2017-05-05 13:02:01 +02:00
* Copyright (C) 2017 Artem Pavlenko
2015-02-17 17:28:49 +01:00
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
#ifndef CONSOLE_REPORT_HPP
#define CONSOLE_REPORT_HPP
// stl
#include <iostream>
#include <mapnik/util/variant.hpp>
#include "config.hpp"
namespace visual_tests
{
class console_report
{
public:
2015-07-07 14:35:28 +02:00
console_report(bool _show_duration) : s(std::clog), show_duration(_show_duration)
2015-02-17 17:28:49 +01:00
{
}
console_report(std::ostream & _s) : s(_s)
2015-02-17 17:28:49 +01:00
{
}
void report(result const & r);
unsigned summary(result_list const & results);
protected:
void report_state(result const & r);
void report_failures(result_list const & results);
2015-02-17 17:28:49 +01:00
std::ostream & s;
2015-07-07 14:35:28 +02:00
bool show_duration;
2015-02-17 17:28:49 +01:00
};
class console_short_report : public console_report
{
public:
console_short_report(bool _show_duration) : console_report(_show_duration)
2015-02-17 17:28:49 +01:00
{
}
2015-10-01 21:10:29 +02:00
console_short_report(std::ostream & _s) : console_report(_s)
2015-02-17 17:28:49 +01:00
{
}
void report(result const & r);
};
class html_report
{
public:
html_report(std::ostream & _s) : s(_s)
2015-02-17 17:28:49 +01:00
{
}
void report(result const & r, boost::filesystem::path const & output_dir);
void summary(result_list const & results, boost::filesystem::path const & output_dir);
protected:
std::ostream & s;
};
using report_type = mapnik::util::variant<console_report, console_short_report>;
class report_visitor
{
public:
report_visitor(result const & r)
: result_(r)
{
}
template <typename T>
void operator()(T & report) const
{
return report.report(result_);
}
private:
result const & result_;
};
class summary_visitor
{
public:
summary_visitor(result_list const & r)
: result_(r)
{
}
template <typename T>
unsigned operator()(T & report) const
{
return report.summary(result_);
}
private:
result_list const & result_;
};
void html_summary(result_list const & results, boost::filesystem::path output_dir);
}
#endif