[perl-Gtk2] Test that custom signal marshallers are always used



commit 0d58cf33660f954ecb883a77611424bd18372626
Author: Torsten SchÃnfeld <kaffeetisch gmx de>
Date:   Sat Aug 25 19:55:00 2012 +0200

    Test that custom signal marshallers are always used
    
    In particular, test that they are used for all equivalent spellings of a signal
    name.
    
    We need to require Glib 1.280 for this to work.

 Makefile.PL      |    2 +-
 NEWS             |    1 +
 README           |    2 +-
 t/GtkEditable.t  |   30 ++++++++++++++++++++++++++----
 t/GtkMenuItem.t  |   19 +++++++++++--------
 t/GtkTreeModel.t |   15 +++++++++------
 6 files changed, 49 insertions(+), 20 deletions(-)
---
diff --git a/Makefile.PL b/Makefile.PL
index ff96224..23f6e84 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -33,7 +33,7 @@ use Cwd;
 our %build_reqs = (
 	'perl-ExtUtils-Depends'   => '0.300',
 	'perl-ExtUtils-PkgConfig' => '1.030',
-	'perl-Glib'               => '1.240',
+	'perl-Glib'               => '1.280',
 	'perl-Pango'              => '1.220',
 	'perl-Cairo'              => '1.000',
 	'Gtk+'                    => '2.0.0',
diff --git a/NEWS b/NEWS
index d6cc8d9..00d3b06 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,7 @@
 Overview of changes in Gtk2 <next>
 =================================
 
+* Require Glib 1.280 for the fixes to custom signal marshalling.
 * Fix a test failure in t/GtkRecentChooser.t.
 
 Overview of changes in Gtk2 1.246
diff --git a/README b/README
index f0d6073..3c652b6 100644
--- a/README
+++ b/README
@@ -61,7 +61,7 @@ DEPENDENCIES
 This module requires these other modules and libraries:
 
   perl >= 5.8.0
-  Glib >= 1.240 (Perl module)
+  Glib >= 1.280 (Perl module)
   Pango >= 1.220 (Perl module)
   GTK+ > 2.x (C library)
 
diff --git a/t/GtkEditable.t b/t/GtkEditable.t
index 2790f06..43cc387 100644
--- a/t/GtkEditable.t
+++ b/t/GtkEditable.t
@@ -1,6 +1,6 @@
 #!/usr/bin/perl -w
 use strict;
-use Gtk2::TestHelper tests => 10;
+use Gtk2::TestHelper tests => 11;
 
 use utf8; # for the umlaut test
 
@@ -40,9 +40,31 @@ $entry -> copy_clipboard();
 $entry -> paste_clipboard();
 $entry -> delete_selection();
 
-$entry -> signal_connect(insert_text => sub { return (); });
-$entry -> set_text("ÃÃÃ");
-is($entry -> get_text(), "ÃÃÃ");
+# Test the custom insert-text marshaller.
+{
+  my $entry = Gtk2::Entry -> new();
+  $entry -> set_text("ÃÃÃ");
+  $entry -> signal_connect(insert_text => sub {
+    my ($entry, $new_text, $new_text_length, $position, $data) = @_;
+    $_[1] = reverse $new_text;
+    $_[3] = 0;
+    return ();
+  });
+  $entry -> insert_text("123", 3);
+  is($entry -> get_text(), "321ÃÃÃ");
+}
+{
+  my $entry = Gtk2::Entry -> new();
+  $entry -> set_text("ÃÃÃ");
+  $entry -> signal_connect('insert-text' => sub {
+    my ($entry, $new_text, $new_text_length, $position, $data) = @_;
+    my $mangled_new_text = reverse $new_text;
+    my $mangled_position = 0;
+    return ($mangled_new_text, $mangled_position);
+  });
+  $entry -> insert_text("123", 3);
+  is($entry -> get_text(), "321ÃÃÃ");
+}
 
 __END__
 
diff --git a/t/GtkMenuItem.t b/t/GtkMenuItem.t
index 5a75dc6..bb4879a 100644
--- a/t/GtkMenuItem.t
+++ b/t/GtkMenuItem.t
@@ -1,6 +1,6 @@
 #!/usr/bin/perl -w
 use strict;
-use Gtk2::TestHelper tests => 20;
+use Gtk2::TestHelper tests => 23;
 
 # $Id$
 
@@ -41,13 +41,16 @@ SKIP: {
 $item -> remove_submenu();
 $item -> set_accel_path("<bla/bla/bla>");
 
-$item -> signal_connect(toggle_size_request => sub {
-  is (shift, $item);
-  is (shift, "bla");
-  return 23;
-}, "bla");
-
-is ($item -> toggle_size_request(), 23);
+# Ensure that both spellings of the signal name get the custom marshaller.
+foreach my $signal_name (qw/toggle_size_request toggle-size-request/) {
+  my $id = $item -> signal_connect($signal_name => sub {
+    is (shift, $item, $signal_name);
+    is (shift, "bla", $signal_name);
+    return 23;
+  }, "bla");
+  is ($item -> toggle_size_request(), 23);
+  $item -> signal_handler_disconnect ($id);
+}
 
 $item -> signal_connect(toggle_size_allocate => sub {
   is (shift, $item);
diff --git a/t/GtkTreeModel.t b/t/GtkTreeModel.t
index 81563da..05044f5 100644
--- a/t/GtkTreeModel.t
+++ b/t/GtkTreeModel.t
@@ -1,6 +1,6 @@
 #!/usr/bin/perl -w
 use strict;
-use Gtk2::TestHelper tests => 73, noinit => 1;
+use Gtk2::TestHelper tests => 74, noinit => 1;
 
 # $Id$
 
@@ -199,11 +199,14 @@ $model -> row_inserted($path_one, $iter_one);
 $model -> row_has_child_toggled($path_one, $iter_one);
 $model -> row_deleted($path_one);
 
-$model -> signal_connect(rows_reordered => sub {
-	is_deeply($_[3], [3, 2, 1, 0]);
-});
-
-$model -> rows_reordered($path_one, undef, 3, 2, 1, 0);
+# Ensure that both spellings of the signal name get the custom marshaller.
+foreach my $signal_name (qw/rows_reordered rows-reordered/) {
+	my $id = $model -> signal_connect($signal_name => sub {
+		is_deeply($_[3], [3, 2, 1, 0], $signal_name);
+	});
+	$model -> rows_reordered($path_one, undef, 3, 2, 1, 0);
+	$model -> signal_handler_disconnect($id);
+}
 
 ###############################################################################
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]