]> granicus.if.org Git - graphviz/commitdiff
tests: test_edge_node_overlap_utilities: add support for writing of annotated SVG...
authorMagnus Jacobsson <Magnus.Jacobsson@berotec.se>
Wed, 24 Aug 2022 10:32:38 +0000 (12:32 +0200)
committerMagnus Jacobsson <Magnus.Jacobsson@berotec.se>
Mon, 12 Sep 2022 07:46:17 +0000 (09:46 +0200)
tests/test_edge_node_overlap_utilities.cpp
tests/test_edge_node_overlap_utilities.h

index 9698e3eb55781fe3acc5603cd927c50463fc9c93..52b780fd3ff95550537f6f2d518a35c45d0ed039 100644 (file)
@@ -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);
   }
 }
index b77b0c4a435e68a7a80926558de35e1ca4d58ae5..395bedd649afbfb4a3601fb4caa9c5db343bc4b5 100644 (file)
@@ -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