3
# Create the task manager
11
######################################################################
12
# This test requires a DISPLAY to run
14
unless ( $ENV{DISPLAY} or $^O eq 'MSWin32' ) {
15
plan skip_all => 'Needs DISPLAY';
23
use Padre::TaskManager ();
24
use Padre::Task::Addition ();
25
use Padre::Wx::App ();
26
use t::lib::Padre::NullWindow ();
28
use_ok('Test::NoWarnings');
30
# Do we start with no threads as expected
31
is( scalar( threads->list ), 0, 'No threads' );
37
######################################################################
41
my $wxapp = Padre::Wx::App->new;
42
isa_ok( $wxapp, 'Padre::Wx::App' );
44
my $window = t::lib::Padre::NullWindow->new;
45
isa_ok( $window, 't::lib::Padre::NullWindow' );
47
my $manager = Padre::TaskManager->new( conduit => $window );
48
isa_ok( $manager, 'Padre::TaskManager' );
49
is( scalar( threads->list ), 0, 'No threads' );
51
# Run the startup process
52
ok( $manager->start, '->start ok' );
53
Time::HiRes::sleep(1);
54
is( scalar( threads->list ), 1, 'The master threads exists' );
56
# Create the sample task
57
my $addition = Padre::Task::Addition->new(
61
isa_ok( $addition, 'Padre::Task::Addition' );
63
# Schedule the task (which should trigger it's execution)
64
ok( $manager->schedule($addition), '->schedule ok' );
66
# Only the prepare phase should run (for now)
67
is( $addition->{prepare}, 1, '->{prepare} is false' );
68
is( $addition->{run}, 0, '->{run} is false' );
69
is( $addition->{finish}, 0, '->{finish} is false' );
71
# Run the shutdown process
72
ok( $manager->stop, '->stop ok' );
73
Time::HiRes::sleep(5);
74
is( scalar( threads->list ), 0, 'No threads' );