File: drawcache.t

package info (click to toggle)
libgtk2-imageview-perl 0.04-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 224 kB
  • ctags: 42
  • sloc: perl: 457; makefile: 52; ansic: 27
file content (53 lines) | stat: -rw-r--r-- 2,298 bytes parent folder | download | duplicates (3)
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
# Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl 01.t'

#########################

# change 'tests => 1' to 'tests => last_test_to_print';

use Test::More tests => 19;

BEGIN {
 use Glib qw/TRUE FALSE/;
 use Gtk2 -init;
 use_ok('Gtk2::ImageView');
};

#########################

# Insert your test code below, the Test::More module is use()ed here so read
# its man page ( perldoc Test::More ) for help writing this test script.

my $cache = Gtk2::Gdk::Pixbuf::Draw::Cache->new;
ok(defined $cache, 'new() works');

ok(defined $cache->{last_pixbuf}, '$cache{last_pixbuf} defined');
ok(defined $cache->{old}, '$cache{old} defined');
ok(defined $cache->{check_size}, '$cache{check_size} defined');

can_ok('Gtk2::Gdk::Pixbuf::Draw::Cache', 'new', 'free', 'invalidate', 'draw');

my $opts = $cache->{old};
ok(defined $opts->{zoom}, '$opts{zoom} defined');
ok(defined $opts->{zoom_rect}, '$opts{zoom_rect} defined');
ok(defined $opts->{widget_x}, '$opts{widget_x} defined');
ok(defined $opts->{widget_y}, '$opts{widget_y} defined');
ok(defined $opts->{interp}, '$opts{interp} defined');
ok(defined $opts->{pixbuf}, '$opts{pixbuf} defined');
ok(defined $opts->{check_color1}, '$opts{check_color1} defined');
ok(defined $opts->{check_color2}, '$opts{check_color2} defined');

my $method = Gtk2::Gdk::Pixbuf::Draw::Cache->get_method($opts, $opts);
ok(($method eq 'contains' or $method eq 'scale' or $method eq 'scroll'), 'get_method');

eval{Gtk2::Gdk::Pixbuf::Draw::Cache->get_method(undef, undef)};
like($@, qr/Expected/, 'A TypeError is raised when get_method() is called with an argument that is not a PixbufDrawOpts object.');

eval{Gtk2::Gdk::Pixbuf::Draw::Cache->get_method($opts, undef)};
like($@, qr/Expected/, 'A TypeError is raised when get_method() is called with an argument that is not a PixbufDrawOpts object.');

eval{Gtk2::Gdk::Pixbuf::Draw::Cache->get_method(undef, $opts)};
like($@, qr/Expected/, 'A TypeError is raised when get_method() is called with an argument that is not a PixbufDrawOpts object.');

eval{Gtk2::Gdk::Pixbuf::Draw::Cache->get_method('Hello', 'Foo')};
like($@, qr/Expected/, 'A TypeError is raised when get_method() is called with an argument that is not a PixbufDrawOpts object.');