1use strict;
2use warnings;
3
4use Test::More tests => 6;
5use SVG;
6
7# test: style
8
9my $svg  = SVG->new;
10my $defs = $svg->defs();
11
12# generate an anchor
13my $tag0 = $svg->anchor( -href => 'http://here.com/some/simpler/SVG.svg' );
14
15# add a circle to the anchor. The circle can be clicked on.
16$tag0->circle( cx => 10, cy => 10, r => 1 );
17
18# more complex anchor with both URL and target
19$svg->comment("anchor with: -href, target");
20my $tag1 = $svg->anchor(
21    -href  => 'http://example.com/some/page.html',
22    target => 'new_window_1',
23);
24$tag1->circle( cx => 10, cy => 10, r => 1 );
25
26$svg->comment("anchor with: -href, -title, -actuate, -show");
27my $tag2 = $svg->anchor(
28    -href    => 'http://example.com/some/other/page.html',
29    -actuate => 'onLoad',
30    -title   => 'demotitle',
31    -show    => 'embed',
32);
33$tag2->circle( cx => 10, cy => 10, r => 1 );
34
35my $out = $tag0->xmlify;
36like(
37    $out,
38    qr{http://here\.com/some/simpler/SVG\.svg},
39    "anchor 3: xlink href"
40);
41
42$out = $tag1->xmlify;
43like( $out, qr/target="new_window_1"/, "anchor 4: target" );
44
45$out = $tag2->xmlify;
46like( $out, qr/xlink:title="demotitle"/, "anchor 6: title" );
47$out = $tag2->xmlify;
48like( $out, qr/actuate/, "anchor 7: actuate" );
49
50$out = $tag2->xmlify;
51like( $out, qr/xlink:show="embed"/, "anchor 8: show" );
52
53my $tag3 = $svg->a(
54    -href  => 'http://example.com/some/page.html',
55    -title => 'direct_a_tag',
56    target => 'new_window_1',
57);
58
59$out = $tag3->xmlify;
60like( $out, qr/direct_a_tag/, "anchor 9: direct a method" );
61
62