File: ClutterActor.t

package info (click to toggle)
libclutter-perl 1.002-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 728 kB
  • ctags: 98
  • sloc: perl: 1,503; ansic: 48; makefile: 9
file content (84 lines) | stat: -rw-r--r-- 1,607 bytes parent folder | download
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package My::FooActor;

use Clutter;

use Glib::Object::Subclass
    'Clutter::Actor';

sub GET_PREFERRED_WIDTH
{
    my ($self, $for_height) = @_;

    return (0.0, 100.0);
}

sub GET_PREFERRED_HEIGHT
{
    my ($self, $for_width) = @_;

    return (0.0, 100.0);
}

sub ALLOCATE
{
    my ($self, $box, $flags) = @_;

    $self->SUPER::ALLOCATE($box, $flags);

    $self->{coords} = $box;
}

sub APPLY_TRANSFORM
{
    my ($self, $matrix) = @_;

    $self->SUPER::APPLY_TRANSFORM($matrix);

    $matrix->translate(-100, 0, 0);
}

package My::BarActor;

use Clutter;

use Glib::Object::Subclass
    'My::FooActor';

sub GET_PREFERRED_WIDTH
{
    my ($self, $for_height) = @_;

    return (0, 50);
}

sub ALLOCATE {
    my ($self, $box, $origin_changed) = @_;

    $self->SUPER::ALLOCATE($box, $origin_changed);
}

package main;

use Clutter::TestHelper tests => 8;

my $foo_actor = My::FooActor->new();
isa_ok($foo_actor, 'Clutter::Actor', 'foo');

my @foo_width = $foo_actor->get_preferred_width(-1);
is_deeply(\@foo_width, [ 0, 100 ], 'foo::width');

my @foo_height = $foo_actor->get_preferred_height(-1);
is_deeply(\@foo_height, [ 0, 100 ], 'foo::height');

my $bar_actor = My::BarActor->new();
isa_ok($bar_actor, 'Clutter::Actor', 'bar');
isa_ok($bar_actor, 'Clutter::Actor', 'foo');

my @bar_width = $bar_actor->get_preferred_width(-1);
is_deeply(\@bar_width, [ 0, 50 ], 'bar::width');

my @bar_height = $bar_actor->get_preferred_height(-1);
is_deeply(\@bar_height, [ 0, 100 ], 'bar::height');

my $matrix = $foo_actor->get_transformation_matrix();
isa_ok($matrix, 'Clutter::Cogl::Matrix', 'foo::matrix');