Class KielerJUnitTest

  • Direct Known Subclasses:
    KielerJUnitTestExtendedModels

    public class KielerJUnitTest
    extends java.lang.Object
    Test out Kieler by open models, using Kieler to layout the graph and then doing undo and redo.

    There are two types of tests.

    1. _layoutModelCompareAgainstFile(NamedObj, String) We read in a model and run the Kieler layout algorithm on on the model and compare the results against the original model. This test is run on regression tests to be sure that the Kieler algorithm has not changed. Typically, the models are in the ptolemy/vergil/basic/layout/kieler/test/junit/models subdirectory.

    2. We read in a model, use the Ptolemy layouter and then the Kieler layout algorithm. We then do an undo, a redo and an undo and compare. the model against the model after the Ptolemy layouter. This test is used run on models in the Ptolemy tree to make sure that the Kieler layouter and the undo/redo mechanism works.

    Since:
    Ptolemy II 10.0
    Version:
    $Id$
    Author:
    Christopher Brooks
    Pt.AcceptedRating:
    Red (cxh)
    Pt.ProposedRating:
    Red (cxh)
    • Constructor Summary

      Constructors 
      Constructor Description
      KielerJUnitTest()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void _layoutModelCompareAgainstFile​(NamedObj model, java.lang.String modelFileName)
      Lay out the model and compare the results against the original model file name.
      protected void _layoutTest​(java.lang.String modelFileName, boolean compareAgainstOriginal)
      Test the layout facility by reading in a model, laying out the model, comparing the new results with the known good results and then doing undo and redo.
      protected void _redo​(NamedObj model)
      Redo the last operation on the model.
      protected static void _sleep()
      Sleep the current thread, which is usually not the Swing Event Dispatch Thread.
      protected void _undo​(NamedObj model)
      Undo the last operation on the model.
      static void closeSentinelModel()
      Reset the ptolemy.ptII.doNotExit property to the previous value.
      static void main​(java.lang.String[] args)
      Test the Kieler layout facility.
      static void openSentinelModel()
      Save the previous value of the ptolemy.ptII.doNotExit property and set it to true while running this test.
      void runModulation()
      Test the layout of the modulation model.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • KielerJUnitTest

        public KielerJUnitTest()
    • Method Detail

      • main

        public static void main​(java.lang.String[] args)
        Test the Kieler layout facility.

        To run, use:

           java -classpath \
              $PTII:$PTII/lib/junit-4.8.2.jar:$PTII/lib/kieler.jar \
              ptolemy.vergil.basic.layout.kieler.test.junit.KielerJUnitTest
          
        Parameters:
        args - Not used.
      • openSentinelModel

        public static void openSentinelModel()
                                      throws java.lang.Exception
        Save the previous value of the ptolemy.ptII.doNotExit property and set it to true while running this test.
        Throws:
        java.lang.Exception - If there is a problem opening the model
      • runModulation

        public void runModulation()
                           throws java.lang.Exception
        Test the layout of the modulation model.
        Throws:
        java.lang.Exception - If there is a problem reading or laying out a model.
      • closeSentinelModel

        public static void closeSentinelModel()
                                       throws java.lang.Throwable
        Reset the ptolemy.ptII.doNotExit property to the previous value.
        Throws:
        java.lang.Throwable - If there is a problem setting the property.
      • _layoutTest

        protected void _layoutTest​(java.lang.String modelFileName,
                                   boolean compareAgainstOriginal)
                            throws java.lang.Exception
        Test the layout facility by reading in a model, laying out the model, comparing the new results with the known good results and then doing undo and redo.

        This is the main entry point for Kieler layout tests.

        The caller of this method need notbe in the Swing Event Thread.

        Parameters:
        modelFileName - The file name of the test model.
        compareAgainstOriginal - If true, then run the Kieler Layouter and compare against the original file. If false, run the Ptolemy layouter, the Kieler layouter, then undo, redo, undo and compare against the output after the Ptolemy layouter.
        Throws:
        java.lang.Exception - If the file name cannot be read or laid out.
      • _layoutModelCompareAgainstFile

        protected void _layoutModelCompareAgainstFile​(NamedObj model,
                                                      java.lang.String modelFileName)
                                               throws java.lang.Exception
        Lay out the model and compare the results against the original model file name.

        The caller of this method should be in the Swing Event Thread.

        Parameters:
        model - The model.
        modelFileName - The pathname of the model, used for comparing.
        Throws:
        java.lang.Exception - If thrown while opening or laying out the model.
      • _redo

        protected void _redo​(NamedObj model)
        Redo the last operation on the model.

        The caller of this method should be in the Swing Event Thread.

        Parameters:
        model - The model upon which the last operation should be redone.
      • _sleep

        protected static void _sleep()
        Sleep the current thread, which is usually not the Swing Event Dispatch Thread.
      • _undo

        protected void _undo​(NamedObj model)
        Undo the last operation on the model.

        The caller of this method should be in the Swing Event Thread.

        Parameters:
        model - The model upon which the last operation should be redone.