[gnumeric] Tests: add test for graph image export.



commit d302cca0cba4f894f627c4655a1c974923e0ede5
Author: Morten Welinder <terra gnome org>
Date:   Sun Nov 3 14:06:42 2019 -0500

    Tests: add test for graph image export.

 test/Makefile.am              |  1 +
 test/t6910-graph-image-svg.pl | 81 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 82 insertions(+)
---
diff --git a/test/Makefile.am b/test/Makefile.am
index 8adbfbca1..629c75d17 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -119,6 +119,7 @@ TESTS =     t1000-statfuns.pl                       \
        t6522-hlink.pl                          \
        t6590-samples.pl                        \
        t6900-sylk.pl                           \
+       t6910-graph-image-svg.pl                \
        t7000-goal-seek.pl                      \
        t7100-solver-blend.pl                   \
        t7101-solver-afiro.pl                   \
diff --git a/test/t6910-graph-image-svg.pl b/test/t6910-graph-image-svg.pl
new file mode 100755
index 000000000..3cfb2df55
--- /dev/null
+++ b/test/t6910-graph-image-svg.pl
@@ -0,0 +1,81 @@
+#!/usr/bin/perl -w
+# -----------------------------------------------------------------------------
+
+use strict;
+use lib ($0 =~ m|^(.*/)| ? $1 : ".");
+use GnumericTest;
+
+&message ("Check that the svg image export works.");
+
+my $xmllint = &GnumericTest::find_program ("xmllint");
+
+my @sources = ("$samples/chart-tests.gnumeric");
+
+my $tmpdir = $0;
+$tmpdir =~ s|^.*/||;
+$tmpdir =~ s|\.pl$|-tmp|;
+if (-e $tmpdir || ($tmpdir =~ m{/}) || ($tmpdir eq '')) {
+    print STDERR "$0: unexpected $tmpdir present\n";
+    die "Fail\n";
+}
+END { rmdir $tmpdir; }
+
+my $nskipped = 0;
+my $ngood = 0;
+my $nbad = 0;
+
+foreach my $src (@sources) {
+    if (!-r $src) {
+       $nskipped++;
+       next;
+    }
+
+    print STDERR "Checking $src\n";
+
+    if (!mkdir $tmpdir) {
+       print STDERR "$0: failed to create $tmpdir\n";
+       die "Fail\n";
+    }
+
+    system ("$ssconvert --export-graphs $src $tmpdir/image-%n.svg");
+    my @images = sort <$tmpdir/image-[0-9]*.svg>;
+    if (@images == 0) {
+       print STDERR "ssconvert failed to produce images in $tmpdir\n";
+       die "Fail\n";
+    }
+    &GnumericTest::junkfile ($_) foreach (reverse @images);
+
+    my $good = 1;
+    foreach my $image (@images) {
+       my $out = `$xmllint --nonet --noout $image 2>&1`;
+       if ($out ne '') {
+           print STDERR "While checking $image:\n";
+           &GnumericTest::dump_indented ($out);
+           $good = 0;
+           last;
+       }
+       &GnumericTest::removejunk ($image);
+    }
+    if ($good) {
+       print STDERR "Checked ", scalar @images, " generated image files.\n";
+       $ngood++;
+       if (!rmdir $tmpdir) {
+           print STDERR "$0: failed to remove $tmpdir\n";
+           die "Fail\n";
+       }
+    } else {
+       $nbad++;
+    }
+}
+
+&GnumericTest::report_skip ("No source files present") if $nbad + $ngood == 0;
+
+if ($nskipped > 0) {
+    print STDERR "$nskipped files skipped.\n";
+}
+
+if ($nbad > 0) {
+    die "Fail\n";
+} else {
+    print STDERR "Pass\n";
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]