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 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
|
#
# $Header: /cvsroot/gtk2-perl/gtk2-perl-xs/Gtk2/t/00.Gtk2.t,v 1.21 2006/05/14 10:57:07 kaffeetisch Exp $
#
use strict;
use warnings;
#########################
# Gtk2 Tests
# - rm
#########################
#########################
# NOTE: this is the bootstrap test -- no Gtk2::TestHelper here!
use Test::More tests => 35;
BEGIN { use_ok('Gtk2') };
#########################
my @version = Gtk2->get_version_info;
is( @version, 3, 'version info is three items long' );
is (Gtk2->check_version(0,0,0), 'Gtk+ version too new (major mismatch)',
'check_version pass');
is (Gtk2->check_version(50,0,0), 'Gtk+ version too old (major mismatch)',
'check_version fail');
ok (defined (Gtk2::major_version), 'major_version');
ok (defined (Gtk2::minor_version), 'minor_version');
ok (defined (Gtk2::micro_version), 'micro_version');
@version = Gtk2->GET_VERSION_INFO;
is (@version, 3, 'version info is three items long');
ok (Gtk2->CHECK_VERSION(0,0,0), 'CHECK_VERSION pass');
ok (!Gtk2->CHECK_VERSION(50,0,0), 'CHECK_VERSION fail');
is (Gtk2::MAJOR_VERSION, $version[0], 'MAJOR_VERSION');
is (Gtk2::MINOR_VERSION, $version[1], 'MINOR_VERSION');
is (Gtk2::MICRO_VERSION, $version[2], 'MICRO_VERSION');
# Pango has only a compile-time version
@version = Gtk2::Pango->GET_VERSION_INFO;
is (@version, 3, 'version info is three items long');
ok (Gtk2::Pango->CHECK_VERSION(0,0,0), 'CHECK_VERSION pass');
ok (!Gtk2::Pango->CHECK_VERSION(50,0,0), 'CHECK_VERSION fail');
SKIP:
{
Gtk2->disable_setlocale;
@ARGV = qw(--help --name gtk2perl --urgs tree);
skip 'Gtk2->init_check failed, probably unable to open DISPLAY',
19, unless( Gtk2->init_check );
ok( Gtk2->init );
ok( Gtk2->set_locale );
is_deeply(\@ARGV, [qw(--help --urgs tree)]);
SKIP:
{
skip "parse_args is new in 2.4.5", 1
unless Gtk2->CHECK_VERSION (2, 4, 5);
# we can't do much more than just calling it, since it always
# immediately returns if init() was called already.
ok( Gtk2->parse_args );
}
isa_ok( Gtk2->get_default_language, "Gtk2::Pango::Language" );
is( Gtk2->main_level, 0, 'main level is zero when there are no loops' );
my $window = Gtk2::Object->new ("Gtk2::Window");
my $object = Gtk2::Object->new ("Gtk2::Label");
my $event = Gtk2::Gdk::Event->new ("button-press");
$event->button (1);
$event->time (time);
$event->state ([qw/shift-mask control-mask/]);
Gtk2::Gdk::Event->put ($event);
$window->add ($object);
$object->realize;
$object->propagate_event ($event);
# warn Gtk2->get_current_event;
# warn Gtk2->get_current_event_time;
# warn Gtk2->get_current_event_state;
# warn Gtk2->get_event_widget ($event);
my $events = 0;
my $retval;
while (Gtk2->events_pending) {
$retval = Gtk2->main_iteration;
$events++;
}
ok( $events );
ok( $retval );
Gtk2::Gdk::Event->put ($event);
$events = 0;
while (Gtk2->events_pending) {
$retval = Gtk2->main_iteration_do (0);
$events++;
}
ok( $events );
ok( $retval );
my $snooper;
ok( $snooper = Gtk2->key_snooper_install (sub { warn @_; 0; }, "bla") );
Gtk2->key_snooper_remove ($snooper);
Gtk2->init_add( sub { ok(1); } );
Gtk2->init_add( sub { ok($_[0] eq 'foo'); }, 'foo' );
ok(1);
Gtk2->quit_add_destroy (1, $object);
my $q1;
ok( $q1 = Gtk2->quit_add( 0, sub { Gtk2->quit_remove($q1); ok(1); } ) );
ok( Gtk2->quit_add( 0, sub { ok($_[0] eq 'bar'); }, 'bar' ) );
Glib::Idle->add( sub { Gtk2->main_quit; 0 } );
Gtk2->main;
ok(1);
}
__END__
Copyright (C) 2003-2004 by the gtk2-perl team (see the file AUTHORS for the
full list). See LICENSE for more information.
|