Update of /cvsroot/http-webtest/HTTP-WebTest/t
In directory usw-pr-cvs1:/tmp/cvs-serv25857/t
Added Files:
test3.txt test2.html.in test1.html 10-click.t
Log Message:
Added
--- NEW FILE: test3.txt ---
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Test File 1</title>
</head>
<body>
<a href="test2.html">Test 2</a>
</body>
</html>
--- NEW FILE: test2.html.in ---
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Test File 2</title>
<base href="<<SERVER_URL>>dir/" />
</head>
<a href="alttest1.txt">Text File</a>
<body>
</body>
</html>
--- NEW FILE: test1.html ---
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Test File 1</title>
</head>
<body>
<a href="">Self Reference</a>
<a href="test2.html">Test 2</a>
</body>
</html>
--- NEW FILE: 10-click.t ---
#!/usr/bin/perl -w
# $Id: 10-click.t,v 1.1 2002/02/21 01:43:35 m_ilya Exp $
# This script tests HTTP::WebTest::Plugin::Click plugin
use strict;
use HTTP::Status;
use Test;
use HTTP::WebTest;
require 't/config.pl';
require 't/utils.pl';
use vars qw($HOSTNAME $PORT $URL $TEST);
BEGIN { plan tests => 1 }
# init tests
my $PID = start_webserver(port => $PORT, server_sub => \&server_sub);
my $WEBTEST = HTTP::WebTest->new;
my $OPTS = { plugins => [ '::Click' ] };
# 1: test following links in HTML files
{
generate_testfile(file => 't/test2.html', server_url => $URL);
my $tests = [ { url => abs_url($URL, '/test1.html'),
text_require => [ '<title>Test File 1</title>' ] },
# link which points back to test1.html
{ click_link => 'Self Reference',
text_require => [ '<title>Test File 1</title>' ] },
# link to test2.html
{ click_link => 'Test 2',
text_require => [ '<title>Test File 2</title>' ] },
# link on text file from test2.html (note that it
# has <base> tag)
{ click_link => 'Text File',
text_require => [ 'TEST TEST' ] }
];
check_webtest(webtest => $WEBTEST,
server_url => $URL,
tests => $tests,
opts => $OPTS,
check_file => 't/test.out/click_link1');
}
# try to stop server even we have been crashed
END { stop_webserver($PID) if defined $PID }
# here we handle connects to our mini web server
sub server_sub {
my %param = @_;
my $request = $param{request};
my $connect = $param{connect};
my $path = $request->url->path;
if($path =~ m(/test1.txt|/dir/alttest1.txt)) {
$connect->send_file_response('t/test1.txt');
} elsif($path eq '/test3.txt') {
$connect->send_file_response('t/test3.txt');
} elsif($path eq '/test1.html' ) {
$connect->send_file_response('t/test1.html');
} elsif($path eq '/test2.html' ) {
$connect->send_file_response('t/test2.html');
} else {
$connect->send_error(RC_NOT_FOUND);
}
}
|