[perl-Gtk2/stable-1-22] Skip a few tests if no keymap is available



commit 32d7a21a83ca92c937982f584cf2bdda0d2e2f92
Author: Torsten Schönfeld <kaffeetisch gmx de>
Date:   Sun Jun 7 20:33:11 2009 +0200

    Skip a few tests if no keymap is available
    
    Based on a patch provided by Ryan Niebur.
---
 t/GtkBindings.t |   16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/t/GtkBindings.t b/t/GtkBindings.t
index 5bf612c..1a53ec5 100644
--- a/t/GtkBindings.t
+++ b/t/GtkBindings.t
@@ -77,6 +77,12 @@ use warnings;
 # Note: need '-init' to make Gtk2::Rc do its thing ...
 use Gtk2::TestHelper tests => 43;
 
+# A few tests below require a valid keymap, which some display servers lack.
+# So try to determine if we're affected and skip the relevant tests if so.
+my $keymap = Gtk2::Gdk::Keymap->get_default();
+my @entries = $keymap->get_entries_for_keyval(
+  Gtk2::Gdk->keyval_from_name('Return'));
+my $have_valid_keymap = scalar @entries != 0;
 
 #-----------------------------------------------------------------------------
 # new()
@@ -154,7 +160,10 @@ HERE
 # As of Gtk 2.12 $gtkobj->bindings_activate() only actually works on a
 # Gtk2::Widget, not a Gtk2::Object, hence using My::Widget to exercise
 # add_path() instead of My::Object.
-{
+SKIP: {
+  skip 'Need a keymap', 5
+    unless $have_valid_keymap;
+
   my $my_widget_bindings = Gtk2::BindingSet->find('my_widget_bindings');
   ok ($my_widget_bindings, 'find() of RC parsed bindings');
 
@@ -342,7 +351,10 @@ HERE
 # entry_skip()
 
 # basic invocation on object doesn't dispatch
-{
+SKIP: {
+  skip 'Need a keymap', 8
+    unless $have_valid_keymap;
+
   my $skip_bindings = Gtk2::BindingSet->new ('entry_skip_test');
   my $keyval = Gtk2::Gdk->keyval_from_name('Return');
   my $modifiers = [];



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