File: 05_timer.t

package info (click to toggle)
libwx-perl 1%3A0.9932-9
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 5,300 kB
  • sloc: cpp: 11,064; perl: 8,603; ansic: 711; makefile: 53
file content (78 lines) | stat: -rwxr-xr-x 1,286 bytes parent folder | download | duplicates (7)
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
#!/usr/bin/perl -w

use strict;
use Wx;
use lib './t';
use Test::More Wx::wxMAC() ? ( 'skip_all' => 'Hangs on wxMac' ) :
                             ( 'tests'    => 2 );
use Tests_Helper qw(test_app);

# test with Notify

package MyTimer;

use vars qw(@ISA); @ISA = qw(Wx::Timer);

sub Notify {
  main::ok( 1, "Overriding Notify works" );
}

package main;

# test with owner

package MyHandler;

use base qw(Wx::EvtHandler);
use Wx::Event qw(EVT_TIMER);

sub new {
  my $class = shift;
  my $this = $class->SUPER::new( @_ );

  EVT_TIMER( $this, -1, \&OnTimer );

  return $this;
}

sub OnTimer {
  main::ok( 1, "EVT_TIMER works" );
  my $frame = Wx::wxTheApp()->GetTopWindow;
  $frame->{T1}->Destroy;
  $frame->{T2}->Destroy;
  $frame->Destroy;
  Wx::WakeUpIdle;
}

package MyFrame;

use base qw(Wx::Frame);

sub new {
  my $class = shift;
  my $this = $class->SUPER::new( @_ );

  my $timer2 = Wx::Timer->new( MyHandler->new );
  $timer2->Start( 800, 1 );

  my $timer1 = MyTimer->new;
  $timer1->Start( 100, 1 );

  $this->{T1} = $timer1;
  $this->{T2} = $timer2;

  return $this;
}

package main;

my $app = test_app( sub {
                      MyFrame->new( undef, -1, 'boo' )->Show( 1 );
                    } );

$app->MainLoop;

# Local variables: #
# mode: cperl #
# End: #