#include "TestFramework.h"
#include "TestRenderUtils.h"
#include "TestUtils.h"

#include "SvgReader.h"
#include "SvgWriter.h"

#include "SvgNode.h"
#include "MediaResourceManager.h"


TEST_CASE(TestSvgToNodeConverter_Circles, "publishing")
{
    SvgReader svg_reader;
    auto svg_doc = svg_reader.read(TestUtils::getTestDataDir() / "circles.svg");

    SvgWriter svg_writer;
    svg_writer.toFile(TestUtils::getTestOutputDir(__FILE__) / "TestSvgToNodeConverter_Circles.svg", svg_doc.get());

    TestRenderer renderer;

    auto svg_node = std::make_unique<SvgNode>(Point(0.0, 0.0));
    svg_node->setContent(std::move(svg_doc));
    renderer.getScene()->addNode(svg_node.get());

    renderer.write(TestUtils::getTestOutputDir(__FILE__) / "TestSvgToNodeConverter_Circles.png");
}

TEST_CASE(TestSvgToNodeConverter_Path, "publishing")
{
    SvgReader svg_reader;
    auto svg_doc = svg_reader.read(MediaResourceManager::getSvgIconPath(Resource::Icon::Svg::HOME_MEDIUM));

    auto svg_node = std::make_unique<SvgNode>(Point(0.0, 0.0));
    svg_node->setContent(std::move(svg_doc));

    TestRenderer renderer;
    renderer.getScene()->addNode(svg_node.get());

    renderer.writeSvg(TestUtils::getTestOutputDir(__FILE__) / "TestSvgToNodeConverter_Path.svg");

    renderer.write(TestUtils::getTestOutputDir(__FILE__) / "TestSvgToNodTestSvgToNodeConverter_PathConverter.png");
}