File: CairoGObject.t

package info (click to toggle)
libcairo-gobject-perl 1.005-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 176 kB
  • sloc: perl: 125; makefile: 5
file content (63 lines) | stat: -rw-r--r-- 1,781 bytes parent folder | download | duplicates (6)
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
#!/usr/bin/perl
#
# Copyright (c) 2011 by the cairo perl team (see the file README)
#
# Licensed under the LGPL, see LICENSE file for more information.
#

use strict;
use warnings;

use Test::More tests => 7;

use Cairo::GObject;

my $drawer = Drawer->new;

# Put some Cairo objects into the Drawer.
my $orig_surf = Cairo::ImageSurface->create ('argb32', 10, 10);
$drawer->set (surface => $orig_surf);

my $orig_cr = Cairo::Context->create ($orig_surf);
$orig_cr->set_antialias ('gray');
$drawer->set (context => $orig_cr);

my $orig_pattern = Cairo::LinearGradient->create (1, 2, 3, 4);
$orig_pattern->set_extend ('repeat');
$drawer->set (pattern => $orig_pattern);

# Now get them back and see if they're unscathed.
my $cr = $drawer->get ('context');
isa_ok ($cr, 'Cairo::Context');
is ($cr->get_antialias, 'gray');

my $surf = $drawer->get ('surface');
isa_ok ($surf, 'Cairo::ImageSurface');
is ($surf->get_content, 'color-alpha');
is ($surf->get_width, 10);

my $pattern = $drawer->get ('pattern');
isa_ok ($pattern, 'Cairo::LinearGradient');
is ($pattern->get_extend, 'repeat');

# --------------------------------------------------------------------------- #

package Drawer;

use strict;
use warnings;
use Cairo::GObject;

use Glib::Object::Subclass
  Glib::Object::,
  properties => [
    Glib::ParamSpec->boxed ('context', 'context', 'context',
                            Cairo::Context::,
                            [qw/readable writable/]),
    Glib::ParamSpec->boxed ('surface', 'surface', 'surface',
                            Cairo::Surface::,
                            [qw/readable writable/]),
    Glib::ParamSpec->boxed ('pattern', 'pattern', 'pattern',
                            Cairo::Pattern::,
                            [qw/readable writable/]),
  ];