cvsimport
[fvwm.git] / tests / perl / module-trackertest
blob398c2e84662bc51137f78021715688fde32d1ec6
1 #!/usr/bin/perl -w
3 use strict;
4 use lib `fvwm-perllib dir`;
5 use FVWM::Module;
7 my $module = new FVWM::Module(Debug => 2);
9 my @tracker_names = qw(
10 Colorsets GlobalConfig ModuleConfig PageInfo Scheduler WindowList
13 foreach my $name (@tracker_names) {
14 my %params = ();
15 %params = ( ModuleName => $0 ) if $name eq "Scheduler";
16 %params = (
17 ModuleName => "FvwmIdent",
18 DefaultConfig => { Font => 'missing' }
19 ) if $name eq "ModuleConfig";
21 my $tracker = $module->track($name, %params);
22 if ($name eq "Scheduler") {
23 $tracker->schedule(30, sub {
24 my $old_timeout = $_[0]->{seconds};
25 my $new_timeout = $old_timeout - 10;
26 $module->terminate if $new_timeout <= 0;
27 $tracker->reschedule($new_timeout);
28 });
30 $module->debug(
31 "$name: initialized\n" . $tracker->dump . ("-" x 74)
33 $tracker->observe("main", sub {
34 my ($module, $tracker, $info, @params) = @_;
35 my $headline = "$name: " . $tracker->observables->[0];
36 $module->debug(
37 "$headline\n" . $tracker->dump(@params) . ("-" x 74)
39 });
42 $module->event_loop();