|
From: <jgr...@us...> - 2003-08-22 09:08:28
|
Update of /cvsroot/popfile/engine/tests
In directory sc8-pr-cvs1:/tmp/cvs-serv1767/tests
Modified Files:
TestHTML.script TestHTML.tst
Log Message:
Created initial infrastructure for manipulating the HTML forms that drive most of POPFile's UI. The HTML scripting for testing has very simplified functionality for HTML form manipulation
Index: TestHTML.script
===================================================================
RCS file: /cvsroot/popfile/engine/tests/TestHTML.script,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** TestHTML.script 21 Aug 2003 00:40:31 -0000 1.2
--- TestHTML.script 21 Aug 2003 01:22:12 -0000 1.3
***************
*** 37,40 ****
--- 37,41 ----
# MATCH/ENDMATCH Encloses a block of test to find in the return from the last URL fetch
# CODE/ENDCODE Arbitrary code that should be executed
+ # INPUTIS a b Assert that form item a has value b
#
# Expect that the following are available to you within the MATCH/ENDMATCH block
***************
*** 45,48 ****
--- 46,50 ----
# $sk The current HTML UI session key
# $version Same as $h->version()
+ # @forms All HTML forms in the last content downloaded
# Test the simplest functionality of the HTML interface
***************
*** 177,180 ****
--- 179,185 ----
# TODO Configuration Page
+ URL http://127.0.0.1:$port/configuration
+ GET
+
# TODO Check skin change
# TODO Check language change
***************
*** 184,187 ****
--- 189,195 ----
# TODO Check change timeout
# TODO Check change POP3 port
+
+ INPUTIS pop3_port 110
+
# TODO Check change separator
# TODO Check Subject Line Modification
***************
*** 190,193 ****
--- 198,204 ----
# TODO Check XMLRPC port
# TODO Check UI port
+
+ INPUTIS ui_port $port
+
# TODO Check SMTP port
# TODO Check NNTP port
Index: TestHTML.tst
===================================================================
RCS file: /cvsroot/popfile/engine/tests/TestHTML.tst,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** TestHTML.tst 20 Aug 2003 20:14:20 -0000 1.6
--- TestHTML.tst 21 Aug 2003 01:22:12 -0000 1.7
***************
*** 23,28 ****
--- 23,71 ----
# ---------------------------------------------------------------------------------------------
+ # Set up the test corpus and use the Test msg and cls files
+ # to create a current history set
+
+ test_assert( `rm -rf corpus` == 0 );
+ test_assert( `cp -R corpus.base corpus` == 0 );
+ test_assert( `rm -rf corpus/CVS` == 0 );
+ test_assert( `rm -rf messages` == 0 );
+
+ mkdir 'messages';
+ my @messages = glob '*.msg';
+
+ my $count = 0;
+ foreach my $msg (@messages) {
+ test_assert( `cp $msg messages/popfile0=$count.msg` == 0 );
+ $msg =~ s/\.msg$/\.cls/;
+ test_assert( `cp $msg messages/popfile0=$count.cls` == 0 );
+ $count += 1;
+ }
+
use POSIX ":sys_wait_h";
+ use HTML::Form;
+ my @forms;
+
+ # Helper function that finds an input with a specific name
+ # in the @forms collection and returns or sets its value
+
+ sub form_input
+ {
+ my ( $name, $value ) = @_;
+
+ foreach my $form (@forms) {
+ my $input = $form->find_input( $name );
+
+ if ( defined( $input ) ) {
+ $input->value( $value ) if defined( $value );
+ return $input->value();
+ }
+ }
+
+ test_assert( 0, "Unable to find form element '$name'" );
+
+ return undef;
+ }
+
sub pipeready
{
***************
*** 43,48 ****
}
- test_assert( `rm -rf messages` == 0 );
-
use Classifier::Bayes;
use UI::HTML;
--- 86,89 ----
***************
*** 50,53 ****
--- 91,95 ----
use POPFile::MQ;
use POPFile::Logger;
+ use Proxy::POP3;
my $c = new POPFile::Configuration;
***************
*** 77,80 ****
--- 119,131 ----
$b->initialize();
+ my $p = new Proxy::POP3;
+
+ $p->configuration( $c );
+ $p->mq( $mq );
+ $p->logger( $l );
+ $p->classifier( $b );
+ $p->version( 'testsuite' );
+ $p->initialize();
+
our $h = new UI::HTML;
***************
*** 89,92 ****
--- 140,145 ----
our $sk = $h->{session_key__};
+ $mq->service();
+
test_assert_equal( $h->url_encode_( ']' ), '%5d' );
test_assert_equal( $h->url_encode_( '[' ), '%5b' );
***************
*** 146,162 ****
$line =~ s/[\r\n\t ]+$//g;
- $line = interpolate( $line );
-
if ( $line =~ /^#/ ) {
next;
}
! if ( $line =~ /^URL (.+)/ ) {
$url = url( $1 );
next;
}
if ( $line =~ /^GET$/ ) {
$content = get($url);
next;
}
--- 199,221 ----
$line =~ s/[\r\n\t ]+$//g;
if ( $line =~ /^#/ ) {
next;
}
! $line = interpolate( $line );
!
! if ( $line =~ /^URL (.+)$/ ) {
$url = url( $1 );
next;
}
+ if ( $line =~ /^INPUTIS (.+) (.+)$/ ) {
+ test_assert_equal( form_input( $1 ), $2 );
+ next;
+ }
+
if ( $line =~ /^GET$/ ) {
$content = get($url);
+ @forms = HTML::Form->parse( $content, "http://127.0.0.1:$port" );
next;
}
***************
*** 185,188 ****
--- 244,266 ----
test_assert_regexp( $content, "\Q$block\E" );
+ next;
+ }
+
+ if ( $line =~ /^CODE$/ ) {
+ my $block;
+
+ while ( $line = <SCRIPT> ) {
+ $line =~ s/^[\t ]+//g;
+ $line =~ s/[\r\n\t ]+$//g;
+
+ if ( $line =~ /^ENDCODE$/ ) {
+ last;
+ }
+
+ $block .= "\n" unless ( $block eq '' );
+ $block .= $line;
+ }
+
+ eval( $block );
next;
}
|