# Tests for the HistogramMLApplication # # @Author: Christopher Hylands, Edward A. Lee # # @Version: $Id: Pxgraph.tcl,v 1.12 2000/01/19 00:18:07 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 } {} if {[info procs jdkCapture] == "" } then { source [file join $PTII util testsuite jdktools.tcl] } # Uncomment this to get a full report, or set in your Tcl shell window. # set VERBOSE 1 ######################################## #### histogramFiles # Create two test files histogramfile1 histogramfile2 # proc histogramFiles {} { global histogramfile1 histogramfile2 tcl_platform if { $tcl_platform(host_platform) == "windows"} { set histogramfile1 histogramfile1.plt set histogramfile2 histogramfile2.plt } else { set histogramfile1 /tmp/histogramfile1.plt set histogramfile2 /tmp/histogramfile2.plt } set fd [open $histogramfile1 w] puts $fd "TitleText: Sample histogram\n" puts $fd "XLabel: values\n" puts $fd "YLabel: count\n" puts $fd "YRange: 0.0,100.0\n" puts $fd "BarGraph: 0.5,0.15\n" puts $fd "BinWidth: 1.0\n" puts $fd "BinOffset: 0.5\n" puts $fd "DataSet: first\n" puts $fd "5.0\n" puts $fd "4.9999013042806855\n" puts $fd "4.99960522101908\n" close $fd #set fd [open $histogramfile2 w] #puts $fd "0 1\n 1 2\nmove:2 2.5\n 3 1" #close $fd } histogramFiles ######################################## #### histogramTest # Pass arguments to Histogram, run it, write the output to # a variable, sleep, dispose of the Histogram, then return the results # # proc histogramTest { args } { global defaultPlotMLHeader set jargs [java::new {String[]} [llength $args] $args ] set histogram [java::new ptolemy.plot.plotml.HistogramMLApplication $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 $histogram ] 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 $histogram 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 } test Histogram-1.1 {Get the sample output} { global histogramfile1 histogramfile2 histogramTest } { Sample histogram values count

} test Histogram-2.1 {Read in an old format file} { global histogramfile1 histogramTest $histogramfile1 } { Sample histogram values count

} test Histogram-3.1 {Read in an old format file} { global histogramfile1 jdkCapture {histogramTest -help} results set results } {}