From bf563d29e40e6bb6cb9732b4457e633468a8c6c2 Mon Sep 17 00:00:00 2001 From: Tom Feist Date: Sat, 26 Feb 2011 00:37:11 +0000 Subject: lots of work moving things around so it mostly works. Hooray --- testing/lib/Test/Irssi.pm | 40 +++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) (limited to 'testing/lib/Test/Irssi.pm') diff --git a/testing/lib/Test/Irssi.pm b/testing/lib/Test/Irssi.pm index dbb2505..a8ee49e 100644 --- a/testing/lib/Test/Irssi.pm +++ b/testing/lib/Test/Irssi.pm @@ -19,9 +19,7 @@ class Test::Irssi { use Test::Irssi::Driver; use Test::Irssi::Callbacks; - use Test::Irssi::API; - - + use Test::Irssi::Test; has 'irssi_binary' @@ -98,17 +96,28 @@ class Test::Irssi { builder => '_build_callback_obj', ); - has 'api' + has 'tests' => ( is => 'ro', - isa => "Test::Irssi::API", + isa => "HashRef", required => 1, - lazy => 1, - builder => "_build_api" + default => sub { {} }, + traits => [qw/Hash/], + handles => { + all_tests => 'values' + }, + ); + + has 'active_test' + => ( + is => 'rw', + isa => 'Test::Irssi::Test', ); - method _build_api { - Test::Irssi::API->new(parent => $self); + sub new_test { + my ($self, $name, @params) = @_; + my $new = Test::Irssi::Test->new(name => $name, parent => $self); + $self->tests->{$name} = $new; } method _build_callback_obj { @@ -153,6 +162,12 @@ class Test::Irssi { $self->_logfile_fh->say($msg); } + method run_tests { + foreach my $test ($self->all_tests) { + $test->execute(); + } + } + method run { $self->_driver->setup; $self->_vt_setup; @@ -161,6 +176,13 @@ class Test::Irssi { $poe_kernel->run(); } + sub apply_delay { + my ($self, $delay, $next_index) = @_; + $poe_kernel->post(IrssiTestDriver + => create_delay + => $delay, $next_index); + } + sub inject_text { my ($self, $text) = @_; $poe_kernel->post(IrssiTestDriver => got_terminal_stdin -- cgit v1.2.3