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 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
|
#!perl
use strict;
use warnings;
use Gtk2::TestHelper tests => 31;
use Test::Exception;
use Gtk2::Notify -init, $0;
ginterfaces_ok('Gtk2::Notify');
my $w = Gtk2::Window->new;
my $n = Gtk2::Notify->new('foo', 'bar', '');
isa_ok($n, 'Gtk2::Notify');
my @methods = qw(
add_action
clear_actions
clear_hints
close
set_category
set_hint_byte
set_hint_byte_array
set_hint_double
set_hint_int32
set_hint_string
set_icon_from_pixbuf
set_timeout
set_urgency
show
update
);
for my $method (@methods) {
ok( $n->can($method), "can $method" );
}
lives_ok(sub {
$n->clear_actions;
}, 'clear_actions without existing actions');
lives_ok(sub {
$n->add_action('foo', 'Foo', sub {
1;
}, 42);
}, 'add_action');
lives_ok(sub {
$n->clear_actions;
}, 'clear_actions with existing actions');
lives_ok(sub {
$n->set_category('foo');
}, 'set_category');
lives_ok(sub {
$n->clear_hints;
}, 'clear_hins without existing hints');
lives_ok(sub {
$n->set_hint_double(foo => 4.2);
}, 'set_hint_double');
lives_ok(sub {
$n->set_hint_int32(foo => 42);
}, 'set_hint_int32');
lives_ok(sub {
$n->set_hint_string(foo => 'bar');
}, 'set_hint_string');
{
my $pixbuf = Gtk2::Gdk::Pixbuf->new('rgb', 0, 8, 5, 5);
lives_ok(sub {
$n->set_icon_from_pixbuf($pixbuf);
}, 'set_icon_from_pixbuf');
}
lives_ok(sub {
$n->set_timeout(20);
}, 'set_timeout');
lives_ok(sub {
$n->set_urgency('critical');
}, 'set_urgency');
#lives_ok(sub {
# $n->close;
#}, 'close before show');
$w->show_all;
lives_ok(sub {
$n->show;
}, 'show');
lives_ok(sub {
$n->close;
}, 'close after show');
ok( $n->update('bar', 'foo', ''), 'update' );
|