2010-07-20 08:41:16 +02:00
|
|
|
#define BOOST_TEST_MODULE combined_tests
|
|
|
|
|
|
|
|
// boost.test
|
|
|
|
#include <boost/test/included/unit_test.hpp>
|
|
|
|
|
|
|
|
// mapnik
|
|
|
|
#include <mapnik/map.hpp>
|
|
|
|
#include <mapnik/svg_renderer.hpp>
|
2010-07-20 19:37:42 +02:00
|
|
|
#include <mapnik/color_factory.hpp>
|
2010-07-20 08:41:16 +02:00
|
|
|
|
|
|
|
// std
|
|
|
|
#include <string>
|
|
|
|
#include <sstream>
|
2010-07-22 06:48:11 +02:00
|
|
|
#include <iterator>
|
2010-07-20 08:41:16 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This test case tests all the generators inside svg_renderer,
|
|
|
|
* verifying the correctness of the whole SVG document.
|
|
|
|
*
|
|
|
|
* The test sets the svg_renderer object with a simple Map that
|
|
|
|
* has only its dimensions specified and calls the apply()
|
|
|
|
* method to produce the output.
|
|
|
|
*
|
|
|
|
* The output stream is a stringstream (the output is generated
|
|
|
|
* into a stringstream).
|
|
|
|
*/
|
|
|
|
BOOST_AUTO_TEST_CASE(combined_test_case)
|
|
|
|
{
|
|
|
|
using namespace mapnik;
|
2010-07-22 06:48:11 +02:00
|
|
|
typedef svg_renderer<std::ostream_iterator<char> > svg_ren;
|
2010-07-20 08:41:16 +02:00
|
|
|
|
|
|
|
Map map(800, 600);
|
2010-07-20 19:37:42 +02:00
|
|
|
map.set_background(color_factory::from_string("white"));
|
2010-07-20 08:41:16 +02:00
|
|
|
|
2010-07-21 05:34:46 +02:00
|
|
|
std::ostringstream output_stream;
|
2010-07-22 06:48:11 +02:00
|
|
|
std::ostream_iterator<char> output_stream_iterator(output_stream);
|
|
|
|
svg_ren renderer(map, output_stream_iterator);
|
2010-07-20 08:41:16 +02:00
|
|
|
renderer.apply();
|
|
|
|
|
|
|
|
std::string expected_output =
|
2011-05-04 17:53:36 +02:00
|
|
|
svg_ren::XML_DECLARATION
|
|
|
|
+ "\n"
|
|
|
|
+ svg_ren::SVG_DTD
|
|
|
|
+ "\n"
|
|
|
|
+ "<svg width=\"800px\" height=\"600px\" version=\"1.1\" xmlns=\""
|
|
|
|
+ svg_ren::SVG_NAMESPACE_URL
|
|
|
|
+ "\">"
|
|
|
|
+"\n"
|
|
|
|
+"<rect x=\"0\" y=\"0\" width=\"800px\" height=\"600px\" style=\"fill: #ffffff\"/>"
|
|
|
|
+"\n"
|
|
|
|
+"</svg>";
|
2010-07-20 08:41:16 +02:00
|
|
|
|
2010-07-22 06:48:11 +02:00
|
|
|
std::string actual_output = output_stream.str();
|
2010-07-20 08:41:16 +02:00
|
|
|
BOOST_CHECK_EQUAL(actual_output, expected_output);
|
|
|
|
}
|
|
|
|
|