# Tests for the Pxgraph class
#
# @Author: Christopher Hylands, Edward A. Lee
#
# @Version: $Id: Pxgraph.tcl,v 1.16 2003/01/08 02:40:29 ptII Exp $
#
# @Copyright (c) 1998-2003 The Regents of the University of California.
# All rights reserved.
#
# Permission is hereby granted, without written agreement and without
# license or royalty fees, to use, copy, modify, and distribute this
# software and its documentation for any purpose, provided that the
# above copyright notice and the following two paragraphs appear in all
# copies of this software.
#
# IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
# FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
# ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
# THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
# PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
# CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES,
# ENHANCEMENTS, OR MODIFICATIONS.
#
# PT_COPYRIGHT_VERSION_2
# COPYRIGHTENDKEY
#######################################################################
# Load up the test definitions.
if {[string compare test [info procs test]] == 1} then {
source testDefs.tcl
} {}
# Uncomment this to get a full report, or set in your Tcl shell window.
# set VERBOSE 1
########################################
#### pxgraphFiles
# Create two test files pxgraphfile1 pxgraphfile2
#
proc pxgraphFiles {} {
global pxgraphfile1 pxgraphfile2 tcl_platform
if { $tcl_platform(host_platform) == "windows"} {
set pxgraphfile1 pxgraphfile1.plt
set pxgraphfile2 pxgraphfile2.plt
} else {
set pxgraphfile1 /tmp/pxgraphfile1.plt
set pxgraphfile2 /tmp/pxgraphfile2.plt
}
set fd [open $pxgraphfile1 w]
puts $fd "0 0\n1 1 \n2,2\n3 -0.2"
close $fd
set fd [open $pxgraphfile2 w]
puts $fd "0 1\n 1 2\nmove:2 2.5\n 3 1"
close $fd
}
pxgraphFiles
########################################
#### pxgraphTest
# Pass arguments to Pxgraph, run it, write the output to
# a variable, sleep, dispose of the Pxgraph, then return the results
#
#
proc pxgraphTest { args } {
global defaultPlotMLHeader
set jargs [java::new {String[]} [llength $args] $args ]
set pxgraph [java::new ptolemy.plot.compat.PxgraphApplication $jargs]
set stream [java::new java.io.ByteArrayOutputStream]
set printStream [java::new \
{java.io.PrintStream java.io.OutputStream} $stream]
set plotFrame [java::cast ptolemy.plot.PlotFrame $pxgraph ]
set plot [java::field $plotFrame plot]
$plot write $printStream "Usually, the DTD would go here"
$printStream flush
set results [$stream toString]
set thread [java::call Thread currentThread ]
# sleep 10 seconds
$thread sleep 10000
$pxgraph dispose
# This hack is necessary because of problems with crnl under windows
regsub -all [java::call System getProperty "line.separator"] \
$results "\n" results2
return $results2
}
########################################
#### pxgraphTest
# Test out set labeling
#
test Pxgraph-1.1 {Test set labeling} {
global pxgraphfile1 pxgraphfile2
pxgraphTest -0 {''} -binary ../demo/data/bin.plt
} {
}
test Pxgraph-1.2 {Test set labeling} {
global pxgraphfile1 pxgraphfile2
pxgraphTest $pxgraphfile1 $pxgraphfile2
} {
}
test Pxgraph-1.3 {Test set labeling} {
global pxgraphfile1 pxgraphfile2
pxgraphTest -0 "first data set" -1 "second data set" \
$pxgraphfile1 $pxgraphfile2
} {
}
test Pxgraph-1.4 {Test set labeling} {
global pxgraphfile1 pxgraphfile2
pxgraphTest -0 "first data set" $pxgraphfile1 $pxgraphfile2
} {
}
test Pxgraph-1.5 {Test set labeling} {
global pxgraphfile1 pxgraphfile2
pxgraphTest -1 "second data set" $pxgraphfile1 $pxgraphfile2
} {
}
test Pxgraph-1.6 {Test set labeling} {
global pxgraphfile1 pxgraphfile2
pxgraphTest -2 "second data set" $pxgraphfile1 $pxgraphfile2
} {
}
test Pxgraph-1.7 {Test set labeling} {
global pxgraphfile1 pxgraphfile2
pxgraphTest -0 "zero" -binary ../demo/data/bin.plt
} {
}
test Pxgraph-1.8 {Test set labeling} {
global pxgraphfile1 pxgraphfile2
pxgraphTest -bar -0 "first data set" -1 "second data set" \
$pxgraphfile1 $pxgraphfile2
} {
}
######################################################################
####
#
test Pxgraph-2.1 {Test out Flags in order} {
global pxgraphfile1
pxgraphTest $pxgraphfile1
} {
}
test Pxgraph-2.2 {Flags: -bar} {
global pxgraphfile1
pxgraphTest -bar $pxgraphfile1
} {
}
test Pxgraph-2.3 {Flags: -bb (Ignored)} {
global pxgraphfile1
pxgraphTest -bb $pxgraphfile1
} {
}
test Pxgraph-2.4 {Flags: -bigendian} {
global pxgraphfile1
pxgraphTest -bigendian ../demo/data/bin.plt
} {
}
test Pxgraph-2.5 {Flags: -binary} {
global pxgraphfile1
pxgraphTest -binary ../demo/data/bin.plt
} {
}
test Pxgraph-2.6 {Flags: -bar -binary} {
global pxgraphfile1
pxgraphTest -bar -binary ../demo/data/bin.plt
} {
}
test Pxgraph-2.7 {Flags: -db (turn on debugging)} {
global pxgraphfile1
pxgraphTest -db $pxgraphfile1
} {
}
test Pxgraph-2.7.5 {Flags: -debug 20 (turn on debugging)} {
global pxgraphfile1
pxgraphTest -debug 20 $pxgraphfile1
} {
}
test Pxgraph-2.8 {Flags: -help} {
global pxgraphfile1
# FIXME: need to capture the output here
#pxgraphTest -help $pxgraphfile1
} {}
test Pxgraph-2.9 {Flags: -littleendian} {
global pxgraphfile1
pxgraphTest -littleendian ../demo/data/bin.plt
} {
}
test Pxgraph-2.10 {Flags: -lnx (Log X axis)} {
global pxgraphfile1
pxgraphTest -lnx $pxgraphfile1
} {
}
test Pxgraph-2.11 {Flags: -lny (Log Y axis)} {
global pxgraphfile1
pxgraphTest -lny $pxgraphfile1
} {
}
test Pxgraph-2.12 {Flags: -m} {
global pxgraphfile1
pxgraphTest -m $pxgraphfile1
} {
}
test Pxgraph-2.13 {Flags -M (StyleMarkers)} {
global pxgraphfile1
pxgraphTest -M $pxgraphfile1
} {
}
test Pxgraph-2.14 {Flags: -nl (No Lines)} {
global pxgraphfile1
pxgraphTest -nl $pxgraphfile1
} {
}
test Pxgraph-2.15 {Flags: -p (PixelMarkers) } {
global pxgraphfile1
pxgraphTest -p $pxgraphfile1
} {
}
test Pxgraph-2.16 {Flags: -p (PixelsMarkers) -nl } {
global pxgraphfile1
pxgraphTest -p -nl $pxgraphfile1
} {
}
test Pxgraph-2.17 {Flags: -P (LargePixels) } {
global pxgraphfile1
pxgraphTest -P $pxgraphfile1
} {
}
test Pxgraph-2.18 {Flags: -p -nl -binary} {
pxgraphTest -P -nl -binary ../demo/data/bin.plt
} {
}
test Pxgraph-2.19 {Flags -p -nl} {
global pxgraphfile1
pxgraphTest -P -nl $pxgraphfile1
} {
}
test Pxgraph-2.20 {Flags: -rv (Reverse Video)} {
global pxgraphfile1
# FIXME: The write output does not capture -rv
pxgraphTest -rv $pxgraphfile1
} {
}
test Pxgraph-2.21 {Flags: -tk (Ticks)} {
global pxgraphfile1
pxgraphTest -tk $pxgraphfile1
} {
}
test Pxgraph-2.22 {Flags: -v (Version)} {
global pxgraphfile1
pxgraphTest -v $pxgraphfile1
} {}
######################################################################
####
#
test Pxgraph-3.1 {Options: -bd (Unsupported)} {
global $pxgraphfile1
pxgraphTest -bd blue $pxgraphfile1
} {
}
test Pxgraph-3.2 {Options: -bg } {
global $pxgraphfile1
#FIXME: the background is not written out
pxgraphTest -bg red $pxgraphfile1
} {
}
test Pxgraph-3.3 {Options: -brb (Unsupported)} {
global $pxgraphfile1
pxgraphTest -brb 1.0 -bar $pxgraphfile1
} {
}
test Pxgraph-3.4 { Options -brw } {
global $pxgraphfile1
pxgraphTest -brw 0.8 -bar $pxgraphfile1
} {
}
test Pxgraph-3.5 {Options: -fg } {
global $pxgraphfile1
#FIXME: the foreground is not written out
pxgraphTest -fg green $pxgraphfile1
} {
}
test Pxgraph-3.6 {Options: -gw (Unsupported)} {
global $pxgraphfile1
pxgraphTest -gw 10 $pxgraphfile1
} {
}
test Pxgraph-3.7 {Options: -lf