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
|
use strict;
use Test::More tests => 17;
use Graphics::Primitive::Component;
use Graphics::Primitive::Container;
BEGIN {
use_ok('Layout::Manager::Grid');
}
my $foo = Graphics::Primitive::Component->new(
name => 'one', minimum_height => 20, minimum_width => 100
);
my $foo2 = Graphics::Primitive::Component->new(
name => 'two', minimum_height => 20, minimum_width => 100
);
my $foo3 = Graphics::Primitive::Component->new(
name => 'three', minimum_height => 20, minimum_width => 100
);
my $foo4 = Graphics::Primitive::Component->new(
name => 'four', minimum_height => 20, minimum_width => 100
);
my $cont = Graphics::Primitive::Container->new(
width => 200
);
$cont->add_component($foo, { row => 0, column => 0 });
$cont->add_component($foo2, { row => 0, column => 1 });
$cont->add_component($foo3, { row => 1, column => 0, height => 2 });
$cont->add_component($foo4, { row => 3, column => 0, width => 2 });
my $lm = Layout::Manager::Grid->new(rows => 4, columns => 2);
$lm->do_layout($cont);
cmp_ok($foo->height, '==', 20, 'left top component height');
cmp_ok($foo->width, '==', 100, 'left top component width');
cmp_ok($foo->origin->x, '==', 0, 'left top component origin x');
cmp_ok($foo->origin->y, '==', 0, 'left top component origin y');
cmp_ok($foo2->height, '==', 20, 'right top component height');
cmp_ok($foo2->width, '==', 100, 'right top component width');
cmp_ok($foo2->origin->x, '==', 100, 'right top component origin x');
cmp_ok($foo2->origin->y, '==', 0, 'right top component origin y');
cmp_ok($foo3->height, '==', 20, 'middle component height');
cmp_ok($foo3->width, '==', 100, 'middle component width');
cmp_ok($foo3->origin->x, '==', 0, 'middle component origin x');
cmp_ok($foo3->origin->y, '==', 20, 'middle component origin y');
cmp_ok($foo4->height, '==', 20, 'bottom component height');
cmp_ok($foo4->width, '==', 200, 'bottom component width');
cmp_ok($foo4->origin->x, '==', 0, 'bottom component origin x');
cmp_ok($foo4->origin->y, '==', 40, 'bottom component origin y');
|