"Fossies" - the Fresh Open Source Software Archive

Member "Gtk3-0.035/t/zz-GtkRadioAction.t" (1 May 2019, 1498 Bytes) of package /linux/privat/Gtk3-0.035.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/usr/bin/perl
    2 
    3 # Based on Gtk2/t/GtkRadioAction.t
    4 
    5 BEGIN { require './t/inc/setup.pl' }
    6 
    7 use strict;
    8 use warnings;
    9 
   10 plan tests => 14;
   11 
   12 my @actions = (Gtk3::RadioAction->new ('one', undef, undef, undef, 0));
   13 isa_ok ($actions[$#actions], 'Gtk3::RadioAction');
   14 my $i = 1;
   15 foreach (qw(two three four five)) {
   16     push @actions, Gtk3::RadioAction->new ($_, undef, undef, undef, $i++);
   17         $actions[$#actions]->set (group => $actions[$#actions-1]);
   18     isa_ok ($actions[$#actions], 'Gtk3::RadioAction');
   19 }
   20 my $group = $actions[0]->get_group;
   21 push @actions, Gtk3::RadioAction->new ('six', undef, undef, undef, 5);
   22 isa_ok ($actions[$#actions], 'Gtk3::RadioAction');
   23 $actions[$#actions]->set_group ($group);
   24 {
   25   # get_group() no memory leaks in arrayref return and array items
   26   my $x = Gtk3::RadioAction->new ('x', undef, undef, undef, 0);
   27   my $y = Gtk3::RadioAction->new ('y', undef, undef, undef, 0);
   28   $y->set_group($x);
   29   my $aref = $x->get_group;
   30   is_deeply($aref, [$x,$y]);
   31   require Scalar::Util;
   32   Scalar::Util::weaken ($aref);
   33   is ($aref, undef, 'get_group() array destroyed by weakening');
   34   Scalar::Util::weaken ($x);
   35   is ($x, undef, 'get_group() item x destroyed by weakening');
   36   Scalar::Util::weaken ($y);
   37   is ($y, undef, 'get_group() item y destroyed by weakening');
   38 }
   39 
   40 is ($actions[0]->get_current_value, 0);
   41 $actions[0]->set_current_value (3);
   42 is ($actions[0]->get_current_value, 3);
   43 
   44 $actions[3]->set_active (Glib::TRUE);
   45 ok (!$actions[0]->get_active);
   46 ok ($actions[3]->get_active);