File: 07-clickeresque.t

package info (click to toggle)
liblayout-manager-perl 0.35-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 364 kB
  • sloc: perl: 1,977; makefile: 2
file content (68 lines) | stat: -rw-r--r-- 2,254 bytes parent folder | download | duplicates (5)
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
58
59
60
61
62
63
64
65
66
67
68
use Test::More tests => 22;

use Geometry::Primitive::Point;
use Layout::Manager::Compass;
use Layout::Manager::Single;
use Graphics::Primitive::Container;
use Graphics::Primitive::Component;

BEGIN {
    use_ok('Layout::Manager::Compass');
}

my $legend = new Graphics::Primitive::Component(
    minimum_height => 10, minimum_width => 10
);
my $yaxis = new Graphics::Primitive::Component(
    minimum_height => 10, minimum_width => 20
);
my $xaxis = new Graphics::Primitive::Component(
    minimum_height => 20, minimum_width => 10
);
my $plot = new Graphics::Primitive::Container(
    minimum_height => 10, minimum_width => 10,
    layout_manager => Layout::Manager::Single->new
);
my $renderer = new Graphics::Primitive::Component(
    minimum_height => 10, minimum_width => 10,
);
$plot->add_component($renderer);

my $cont = new Graphics::Primitive::Container(
    width => 500, height => 300
);

$cont->add_component($legend, 's');
$cont->add_component($xaxis, 's');
$cont->add_component($yaxis, 'w');
$cont->add_component($plot, 'c');

cmp_ok($cont->component_count, '==', 4, 'component_count');

my $lm = Layout::Manager::Compass->new;
$lm->do_layout($cont);

cmp_ok($legend->origin->x, '==', 0, 'legend origin x');
cmp_ok($legend->origin->y, '==', 290, 'legend origin y');
cmp_ok($legend->width, '==', 500, 'legend width');
cmp_ok($legend->height, '==', 10, 'north height');

cmp_ok($yaxis->origin->x, '==', 0, 'yaxis origin x');
cmp_ok($yaxis->origin->y, '==', 0, 'yaxis origin y');
cmp_ok($yaxis->width, '==', 20, 'yaxis width');
cmp_ok($yaxis->height, '==', 270, 'yaxis height');

cmp_ok($xaxis->origin->x, '==', 0, 'xaxis origin x');
cmp_ok($xaxis->origin->y, '==', 270, 'xaxis origin y');
cmp_ok($xaxis->width, '==', 500, 'xaxis width');
cmp_ok($xaxis->height, '==', 20, 'xaxis height');

cmp_ok($plot->origin->x, '==', 20, 'plot origin x');
cmp_ok($plot->origin->y, '==', 0, 'plot origin y');
cmp_ok($plot->width, '==', 480, 'plot width');
cmp_ok($plot->height, '==', 270, 'plot height');

cmp_ok($renderer->origin->x, '==', 0, 'renderer origin x');
cmp_ok($renderer->origin->y, '==', 0, 'renderer origin y');
cmp_ok($renderer->width, '==', $plot->width, 'renderer width');
cmp_ok($renderer->height, '==', $plot->height, 'renderer width');