From: Magnus Jacobsson Date: Wed, 24 Aug 2022 10:32:38 +0000 (+0200) Subject: tests: test_edge_node_overlap_utilities: add support for writing of annotated SVG... X-Git-Tag: 6.0.2~43^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=42e68cb21a0fb27f722f8a8ed12290f3a17558c3;p=graphviz tests: test_edge_node_overlap_utilities: add support for writing of annotated SVG files for manual inspection --- diff --git a/tests/test_edge_node_overlap_utilities.cpp b/tests/test_edge_node_overlap_utilities.cpp index 9698e3eb5..52b780fd3 100644 --- a/tests/test_edge_node_overlap_utilities.cpp +++ b/tests/test_edge_node_overlap_utilities.cpp @@ -69,7 +69,8 @@ static bool check_analyzed_svg(SVGAnalyzer &svg_analyzer, /// write SVG files for manual analysis if any of the above checks failed or if /// we explicitly have requested it -static void write_svg_files(const SVGAnalyzer &svg_analyzer, +static void write_svg_files(SVGAnalyzer &svg_analyzer, + const check_options &check_options, const write_options &write_options) { const std::filesystem::path test_artifacts_directory = "test_artifacts"; @@ -88,6 +89,19 @@ static void write_svg_files(const SVGAnalyzer &svg_analyzer, const auto recreated_svg = svg_analyzer.svg_string(); write_to_file(test_artifacts_directory, filename, recreated_svg); } + + if (write_options.write_annotated_svg) { + // annotate the SVG recreated by the SVG analyzer with bounding boxes + // and write to file + svg_analyzer.add_bboxes(); + svg_analyzer.add_outline_bboxes(); + svg_analyzer.add_node_edge_outline_bbox_overlaps( + check_options.max_node_edge_overlap); + const std::filesystem::path filename = + write_options.filename_base + "_annotated.svg"; + write_to_file(test_artifacts_directory, filename, + svg_analyzer.svg_string()); + } } void test_edge_node_overlap(const std::string &dot, @@ -114,6 +128,6 @@ void test_edge_node_overlap(const std::string &dot, const auto success = check_analyzed_svg(svg_analyzer, check_options); if (!success || write_options.write_svg_on_success) { - write_svg_files(svg_analyzer, write_options); + write_svg_files(svg_analyzer, check_options, write_options); } } diff --git a/tests/test_edge_node_overlap_utilities.h b/tests/test_edge_node_overlap_utilities.h index b77b0c4a4..395bedd64 100644 --- a/tests/test_edge_node_overlap_utilities.h +++ b/tests/test_edge_node_overlap_utilities.h @@ -13,7 +13,8 @@ struct write_options { std::string filename_base = "test_edge_node_overlap"; bool write_svg_on_success = false; bool write_original_svg = false; - bool write_recreated_svg = true; + bool write_recreated_svg = false; + bool write_annotated_svg = true; }; /// generate an SVG graph from the `dot` source and check that edges don't