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
|
#!/usr/bin/perl -w
# vim: set filetype=perl :
use strict;
use Gtk2::TestHelper tests => 3;
use Scalar::Util;
# $Header: /cvsroot/gtk2-perl/gtk2-perl-xs/Gtk2/t/GtkGC.t,v 1.2 2008/06/01 13:17:18 kaffeetisch Exp $
my $black = Gtk2::Gdk::Color -> new(0, 0, 0);
my $colormap = Gtk2::Gdk::Colormap -> get_system();
my $values = {
foreground => $black,
background => $black,
function => "copy",
fill => "tiled",
subwindow_mode => "clip-by-children",
ts_x_origin => 0,
ts_y_origin => 0,
clip_x_origin => 0,
clip_y_origin => 0,
graphics_exposures => 1,
line_width => 5,
line_style => "solid",
cap_style => "butt",
join_style => "round"
};
my $gc = Gtk2::GC -> get(16, $colormap, $values);
isa_ok($gc, "Gtk2::Gdk::GC");
isa_ok($gc, "Gtk2::GC");
Gtk2::GC -> release($gc);
# regression tests for the automatic releasing of GCs
my ($save, $weak_ref);
{
my $one = Gtk2::GC -> get(16, $colormap, $values);
Gtk2::GC -> get(16, $colormap, $values);
Gtk2::GC -> get(16, $colormap, $values);
Gtk2::GC -> release($one);
Gtk2::GC -> release($one);
Gtk2::GC -> release($one);
$one = undef;
my $two = Gtk2::GC -> get(32, $colormap, $values);
Gtk2::GC -> get(32, $colormap, $values);
{ my $three = Gtk2::GC -> get(32, $colormap, $values); }
$save = Gtk2::GC -> get(32, $colormap, $values);
Gtk2::GC -> get(32, $colormap, $values);
Scalar::Util::weaken ($weak_ref = $two);
}
$save = undef;
is ($weak_ref, undef);
__END__
Copyright (C) 2003 by the gtk2-perl team (see the file AUTHORS for the
full list). See LICENSE for more information.
|