1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
#!/usr/bin/env perl
# Test group output
use Test::More;
use strict;
BEGIN
{
plan tests => 9;
chdir 't' if -d 't';
use lib '../lib';
use_ok ("Graph::Easy") or die($@);
};
use Graph::Easy::Edge::Cell qw/EDGE_END_E EDGE_END_N EDGE_END_S EDGE_END_W EDGE_HOR/;
#############################################################################
my $graph = Graph::Easy->new();
is (ref($graph), 'Graph::Easy');
is ($graph->error(), '', 'no error yet');
# this will load As_svg:
my $svg = $graph->as_svg();
#############################################################################
# add a group and three nodes, one invisible
my $group = $graph->add_group('Cities');
my $last;
for my $name (qw/Bonn Berlin Rostock/)
{
my $node = $graph->add_node($name);
$node->set_attribute('shape','invisible') if $name eq 'Rostock';
$group->add_node($node);
$graph->add_edge($last,$node) if defined $last;
$last = $node;
}
$group->add_node( $graph->add_node('Wismut') );
$graph->add_edge('Berlin','Wismut');
$svg = $graph->as_svg();
like ($svg, qr/Bonn/, 'contains Bonn');
like ($svg, qr/Wismut/, 'contains Wismut');
like ($svg, qr/Berlin/, 'contains Berlin');
unlike ($svg, qr/Rostock<\/text/, "doesn't contains invisible Rostock");
like ($svg, qr/<line x1=".*stroke-dasharray="6,\s*2/, 'contains some border');
like ($svg, qr/<rect .*stroke="none"/, 'contains a rect with no stroke for edge backgrounds');
|