1#!perl 2 3use strict; 4use warnings; 5use Gtk2::TestHelper tests => 32; 6use Test::Exception; 7use Gtk2::Notify -init, $0; 8 9ginterfaces_ok('Gtk2::Notify'); 10 11my $n = Gtk2::Notify->new('foo', 'bar', ''); 12 13isa_ok($n, 'Gtk2::Notify'); 14 15my @methods = qw( 16 add_action 17 clear_actions 18 clear_hints 19 close 20 set_category 21 set_hint_byte 22 set_hint_byte_array 23 set_hint_double 24 set_hint_int32 25 set_hint_string 26 set_icon_from_pixbuf 27 set_timeout 28 set_urgency 29 show 30 update 31); 32 33for my $method (@methods) { 34 ok( $n->can($method), "can $method" ); 35} 36 37lives_ok(sub { 38 $n->clear_actions; 39}, 'clear_actions without existing actions'); 40 41lives_ok(sub { 42 $n->add_action('foo', 'Foo', sub { 43 1; 44 }, 42); 45}, 'add_action'); 46 47lives_ok(sub { 48 $n->clear_actions; 49}, 'clear_actions with existing actions'); 50 51lives_ok(sub { 52 $n->set_category('foo'); 53}, 'set_category'); 54 55lives_ok(sub { 56 $n->clear_hints; 57}, 'clear_hins without existing hints'); 58 59lives_ok(sub { 60 $n->set_hint_double(foo => 4.2); 61}, 'set_hint_double'); 62 63lives_ok(sub { 64 $n->set_hint_int32(foo => 42); 65}, 'set_hint_int32'); 66 67lives_ok(sub { 68 $n->set_hint_string(foo => 'bar'); 69}, 'set_hint_string'); 70 71{ 72 my $pixbuf = Gtk2::Gdk::Pixbuf->new('rgb', 0, 8, 5, 5); 73 lives_ok(sub { 74 $n->set_icon_from_pixbuf($pixbuf); 75 }, 'set_icon_from_pixbuf'); 76} 77 78lives_ok(sub { 79 $n->set_timeout(20); 80}, 'set_timeout'); 81 82lives_ok(sub { 83 $n->set_urgency('critical'); 84}, 'set_urgency'); 85 86lives_ok(sub { 87 $n->close; 88}, 'close before show'); 89 90lives_ok(sub { 91 $n->show; 92}, 'show'); 93 94lives_ok(sub { 95 $n->close; 96}, 'close after show'); 97 98ok( $n->update('bar', 'foo', ''), 'update' ); 99