From 880c4876e8102cc36045ea5b9228dcbefd390e48 Mon Sep 17 00:00:00 2001 From: "kestes%walrus.com" Date: Tue, 10 Dec 2002 19:20:05 +0000 Subject: [PATCH] add new unit tests. These test the VCDisplay and HTMLpopup subsystems. --- webtools/tinderbox2/src/test/gennotices.tst | 14 ++++++-- webtools/tinderbox2/src/test/popup.tst | 36 +++++++++++++++++++-- 2 files changed, 45 insertions(+), 5 deletions(-) diff --git a/webtools/tinderbox2/src/test/gennotices.tst b/webtools/tinderbox2/src/test/gennotices.tst index 681a5923388..817db4deb06 100755 --- a/webtools/tinderbox2/src/test/gennotices.tst +++ b/webtools/tinderbox2/src/test/gennotices.tst @@ -5,8 +5,8 @@ # current time. -# $Revision: 1.11 $ -# $Date: 2002-05-10 21:17:56 $ +# $Revision: 1.12 $ +# $Date: 2002-12-10 19:20:05 $ # $Author: kestes%walrus.com $ # $Source: /home/jrmuizel/cvs-mirror/mozilla/webtools/tinderbox2/src/test/gennotices.tst,v $ # $Name: $ @@ -173,12 +173,22 @@ foreach $tree (@TREES) { my ($pretty_time) = HTMLPopUp::timeHTML($timenow); $associations = generate_associations(); + # We simulate people posting notices for events older then the + # when they post the note. + + my ($random_posttime) = rand 10; + $posttime = $timenow - ($random_posttime * 60), + $localposttime = localtime($posttime); + + my (%data) = ( 'tree' => $tree, 'mailaddr' => $mailaddr, 'note' => $note, 'time' => $timenow, 'localtime' => $localtimenow, + 'posttime' => $posttime =$timenow, + 'localposttime' => $localposttime, 'remote_host' => '127.0.0.1', 'associations' => $associations, ); diff --git a/webtools/tinderbox2/src/test/popup.tst b/webtools/tinderbox2/src/test/popup.tst index abc5347a609..42fff42c09e 100644 --- a/webtools/tinderbox2/src/test/popup.tst +++ b/webtools/tinderbox2/src/test/popup.tst @@ -1,10 +1,10 @@ -#!#perl# -- +#!#perl# -w -- # generate static html pages for use in testing the popup libraries. -# $Revision: 1.1 $ -# $Date: 2002-05-01 01:51:51 $ +# $Revision: 1.2 $ +# $Date: 2002-12-10 19:20:04 $ # $Author: kestes%walrus.com $ # $Source: /home/jrmuizel/cvs-mirror/mozilla/webtools/tinderbox2/src/test/popup.tst,v $ # $Name: $ @@ -204,3 +204,33 @@ foreach $popup_lib (@popup_libs) { overwrite_file($outfile, $out); } + +{ + +# simple tests to validate the escape routines. + +my $string = ' 12/09 17:07 '; +my $urlescaped_string = HTMLPopUp::escapeURL($string); +my $htmlescaped_string = HTMLPopUp::escapeHTML($string); +my $url = HTMLPopUp::unescapeURL($urlescaped_string); +my $html = HTMLPopUp::unescapeHTML($htmlescaped_string); + +($string eq $url) || + die("escapeURL followed by unescapeURL did not give us original string\n"); + +($string eq $html) || + die("escapeHTML followed by unescapeHTML did not give us original string\n"); + + +($htmlescaped_string eq ' <A HREF="#1039471635" >12/09&nbsp;17:07</a> ') || + die("escapeHTML did not return expected string\n"); + + +($urlescaped_string eq +'%20%3CA%20%20HREF%3D%22%231039471635%22%20%3E12%2F09%26nbsp%3B17%3A07%3C%2Fa%3E%20') +|| + die("escapeURL did not return expected string\n"); + +} + +1;