File: 20-anchor.t

package info (click to toggle)
libsvg-perl 2.52-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 412 kB
  • sloc: perl: 2,433; makefile: 2
file content (57 lines) | stat: -rwxr-xr-x 1,451 bytes parent folder | download | duplicates (2)
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
56
57
use strict;
use warnings;

use Test::More tests => 6;
use SVG;

# test: style

my $svg = SVG->new;
my $defs = $svg->defs();

# generate an anchor
my $tag0 = $svg->anchor(
    -href=>'http://here.com/some/simpler/SVG.svg'
);
# add a circle to the anchor. The circle can be clicked on.
$tag0->circle(cx=>10,cy=>10,r=>1);

# more complex anchor with both URL and target
$svg->comment("anchor with: -href, target");
my $tag1 = $svg->anchor(
      -href   => 'http://example.com/some/page.html',
      target => 'new_window_1',
);
$tag1->circle(cx=>10,cy=>10,r=>1);

$svg->comment("anchor with: -href, -title, -actuate, -show");
my $tag2 = $svg->anchor(
    -href => 'http://example.com/some/other/page.html',
    -actuate => 'onLoad',
    -title => 'demotitle',
    -show=> 'embed',
);
$tag2->circle(cx=>10,cy=>10,r=>1);

my $out = $tag0->xmlify;
like($out, qr{http://here\.com/some/simpler/SVG\.svg}, "anchor 3: xlink href");

$out = $tag1->xmlify;
like($out, qr/target="new_window_1"/, "anchor 4: target");

$out = $tag2->xmlify;
like($out, qr/xlink:title="demotitle"/, "anchor 6: title");
$out = $tag2->xmlify;
like($out, qr/actuate/, "anchor 7: actuate");

$out = $tag2->xmlify;
like($out, qr/xlink:show="embed"/, "anchor 8: show");

my $tag3 = $svg->a(
    -href   => 'http://example.com/some/page.html',
    -title => 'direct_a_tag',
    target => 'new_window_1',);

$out = $tag3->xmlify;
like($out, qr/direct_a_tag/, "anchor 9: direct a method");