ij2x.plugin.frame
Class InteractiveTestCase

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by ij2x.plugin.frame.InteractiveTestCase
All Implemented Interfaces:
junit.framework.Test

public abstract class InteractiveTestCase
extends junit.framework.TestCase

Base class for supporting inclusion of interactive tests into a JUnit test case. Note that the interactive tests are NOT executed by the JUnit framework and are not automated. They are typically used for visual inspection of features during development. It is convenient to include the interactive tests along with the automated JUnit tests since they may share resources and it keeps tests focused in a single place.

All interactive test methods should be prefixed with "interactive", e.g. interactiveTestTableSorting().

The test class's main method should be used to control which interactive tests should run. Use runInteractiveTests() method to run all interactive tests in the class.

Ultimately we need to investigate moving to a mechanism which can help automate interactive tests. JFCUnit is being investigated. In the meantime, this is quick and dirty and cheap.


Field Summary
protected  java.awt.Point frameLocation
           
protected  boolean systemLF
           
 
Constructor Summary
InteractiveTestCase()
           
InteractiveTestCase(java.lang.String testTitle)
           
 
Method Summary
 void addAction(org.jdesktop.swingx.JXFrame frame, javax.swing.Action action)
           
 void addComponentOrientationToggle(org.jdesktop.swingx.JXFrame frame)
          Creates and adds a button toggling the frame's componentOrientation.
 void addMessage(org.jdesktop.swingx.JXFrame frame, java.lang.String message)
           
 void addSearchModeToggle(org.jdesktop.swingx.JXFrame frame)
          Creates and adds a button toggling the frame's componentOrientation.
 void addStatusComponent(org.jdesktop.swingx.JXFrame frame, javax.swing.JComponent component)
          Adds the component to the statusbar of the frame.
 void addStatusMessage(org.jdesktop.swingx.JXFrame frame, java.lang.String message)
           
protected  void createAndAddMenus(javax.swing.JMenuBar bar, javax.swing.JComponent component)
          Creates menus and adds them to the given menu bar.
protected  javax.swing.JMenuBar createAndFillMenuBar(javax.swing.JComponent component)
          Creates, fills and returns a JMenuBar.
protected  javax.swing.JMenu createPlafMenu()
          Creates a menu filled with one SetPlafAction for each of the currently installed LFs.
 org.jdesktop.swingx.JXStatusBar getStatusBar(org.jdesktop.swingx.JXFrame frame)
          Returns the JXFrame's status bar.
static boolean isCrossPlatformLF()
          Returns whether the current lf is the cross-platform lf.
static boolean isSystemLF()
          Returns whether the current lf is the system lf.
 void runInteractiveTests()
          Runs all test methods which are prefixed with "interactive".
 void runInteractiveTests(java.lang.String regexPattern)
          Runs all tests whose method names match the specified regex pattern.
static void setSystemLF(boolean system)
          PENDING: JW - this is about toggling the LF, does nothing to update the UI.
 void show(org.jdesktop.swingx.JXFrame frame)
          Packs and shows the frame.
 void show(org.jdesktop.swingx.JXFrame frame, int width, int height)
          Packs, sizes and shows the frame.
 org.jdesktop.swingx.JXFrame showInFrame(javax.swing.JComponent component, java.lang.String title)
          Creates, shows and returns a JXFrame with the specified title, containing the component.
 org.jdesktop.swingx.JXFrame showInFrame(javax.swing.JComponent component, java.lang.String title, boolean showMenu)
          Creates, shows and returns a JXFrame with the specified title, containing the component.
 org.jdesktop.swingx.JXFrame showWithScrollingInFrame(javax.swing.JComponent leftComp, javax.swing.JComponent rightComp, java.lang.String title)
          Creates and returns a JXFrame with the specified title, containing two components individually wrapped into a JScrollPane.
 org.jdesktop.swingx.JXFrame showWithScrollingInFrame(javax.swing.JComponent component, java.lang.String title)
          Creates, shows and returns a JXFrame with the specified title, containing the component wrapped into a JScrollPane.
 org.jdesktop.swingx.JXFrame wrapInFrame(javax.swing.JComponent component, java.lang.String title)
          Creates and returns a JXFrame with the specified title, containing the component.
 org.jdesktop.swingx.JXFrame wrapInFrame(javax.swing.JComponent component, java.lang.String title, boolean showMenu)
           
 org.jdesktop.swingx.JXFrame wrapWithScrollingInFrame(javax.swing.JComponent leftComp, javax.swing.JComponent rightComp, java.lang.String title)
          Creates and returns a JXFrame with the specified title, containing two components individually wrapped into a JScrollPane.
 org.jdesktop.swingx.JXFrame wrapWithScrollingInFrame(javax.swing.JComponent component, java.lang.String title)
          Creates and returns a JXFrame with the specified title, containing the component wrapped into a JScrollPane.
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, setUp, tearDown, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame, failSame, format
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

frameLocation

protected java.awt.Point frameLocation

systemLF

protected boolean systemLF
Constructor Detail

InteractiveTestCase

public InteractiveTestCase()

InteractiveTestCase

public InteractiveTestCase(java.lang.String testTitle)
Method Detail

runInteractiveTests

public void runInteractiveTests(java.lang.String regexPattern)
                         throws java.lang.Exception
Runs all tests whose method names match the specified regex pattern.

Parameters:
regexPattern - regular expression pattern used to match test method names
Throws:
java.lang.Exception

runInteractiveTests

public void runInteractiveTests()
                         throws java.lang.Exception
Runs all test methods which are prefixed with "interactive".

Throws:
java.lang.Exception

wrapWithScrollingInFrame

public org.jdesktop.swingx.JXFrame wrapWithScrollingInFrame(javax.swing.JComponent component,
                                                            java.lang.String title)
Creates and returns a JXFrame with the specified title, containing the component wrapped into a JScrollPane.

Parameters:
component - the JComponent to wrap
title - the title to show in the frame
Returns:
a configured, packed and located JXFrame.

wrapWithScrollingInFrame

public org.jdesktop.swingx.JXFrame wrapWithScrollingInFrame(javax.swing.JComponent leftComp,
                                                            javax.swing.JComponent rightComp,
                                                            java.lang.String title)
Creates and returns a JXFrame with the specified title, containing two components individually wrapped into a JScrollPane.

Parameters:
leftComp - the left JComponent to wrap
rightComp - the right JComponent to wrap
title - the title to show in the frame
Returns:
a configured, packed and located JXFrame

wrapInFrame

public org.jdesktop.swingx.JXFrame wrapInFrame(javax.swing.JComponent component,
                                               java.lang.String title)
Creates and returns a JXFrame with the specified title, containing the component. First frame get's the menubar as defined by createAndFillMenuBar. Closing the first frame will exit.

Parameters:
component - the JComponent to wrap
title - the title to show in the frame
Returns:
a configured, packed and located JXFrame.

showWithScrollingInFrame

public org.jdesktop.swingx.JXFrame showWithScrollingInFrame(javax.swing.JComponent component,
                                                            java.lang.String title)
Creates, shows and returns a JXFrame with the specified title, containing the component wrapped into a JScrollPane.

Parameters:
component - the JComponent to wrap
title - the title to show in the frame
Returns:
a configured, packed and located JXFrame.
See Also:
wrapWithScrollingInFrame(JComponent, String)

showWithScrollingInFrame

public org.jdesktop.swingx.JXFrame showWithScrollingInFrame(javax.swing.JComponent leftComp,
                                                            javax.swing.JComponent rightComp,
                                                            java.lang.String title)
Creates and returns a JXFrame with the specified title, containing two components individually wrapped into a JScrollPane.

Parameters:
leftComp - the left JComponent to wrap
rightComp - the right JComponent to wrap
title - the title to show in the frame
Returns:
a configured, packed and located JXFrame

showInFrame

public org.jdesktop.swingx.JXFrame showInFrame(javax.swing.JComponent component,
                                               java.lang.String title)
Creates, shows and returns a JXFrame with the specified title, containing the component.

Parameters:
component - the JComponent to wrap
title - the title to show in the frame
Returns:
a configured, packed and located JXFrame.

showInFrame

public org.jdesktop.swingx.JXFrame showInFrame(javax.swing.JComponent component,
                                               java.lang.String title,
                                               boolean showMenu)
Creates, shows and returns a JXFrame with the specified title, containing the component. Creates and adds a Menubar if showMenu is true.

Parameters:
component - the JComponent to wrap
title - the title to show in the frame
showMenu - flag to indicate whether a JMenuBar should be added
Returns:
a configured, packed and located JXFrame.

wrapInFrame

public org.jdesktop.swingx.JXFrame wrapInFrame(javax.swing.JComponent component,
                                               java.lang.String title,
                                               boolean showMenu)

show

public void show(org.jdesktop.swingx.JXFrame frame)
Packs and shows the frame.

Parameters:
frame -

show

public void show(org.jdesktop.swingx.JXFrame frame,
                 int width,
                 int height)
Packs, sizes and shows the frame.

Parameters:
frame -

addAction

public void addAction(org.jdesktop.swingx.JXFrame frame,
                      javax.swing.Action action)

addComponentOrientationToggle

public void addComponentOrientationToggle(org.jdesktop.swingx.JXFrame frame)
Creates and adds a button toggling the frame's componentOrientation.

Parameters:
frame -

addSearchModeToggle

public void addSearchModeToggle(org.jdesktop.swingx.JXFrame frame)
Creates and adds a button toggling the frame's componentOrientation.

Parameters:
frame -

addMessage

public void addMessage(org.jdesktop.swingx.JXFrame frame,
                       java.lang.String message)

getStatusBar

public org.jdesktop.swingx.JXStatusBar getStatusBar(org.jdesktop.swingx.JXFrame frame)
Returns the JXFrame's status bar. Lazily creates and sets an instance if necessary.

Parameters:
frame - the target frame
Returns:
the frame's statusbar

addStatusComponent

public void addStatusComponent(org.jdesktop.swingx.JXFrame frame,
                               javax.swing.JComponent component)
Adds the component to the statusbar of the frame.

Parameters:
frame -
component -

addStatusMessage

public void addStatusMessage(org.jdesktop.swingx.JXFrame frame,
                             java.lang.String message)
Parameters:
frame -
string -

createAndFillMenuBar

protected javax.swing.JMenuBar createAndFillMenuBar(javax.swing.JComponent component)
Creates, fills and returns a JMenuBar.

Parameters:
component - the component that was added to the frame.
Returns:
a menu bar filled with actions as defined in createAndAddMenus
See Also:
createAndAddMenus(javax.swing.JMenuBar, javax.swing.JComponent)

createAndAddMenus

protected void createAndAddMenus(javax.swing.JMenuBar bar,
                                 javax.swing.JComponent component)
Creates menus and adds them to the given menu bar.

This implementation adds a menu to choose the LF.

Parameters:
bar - the menubar to fill
component - the component that was added to the frame.

createPlafMenu

protected javax.swing.JMenu createPlafMenu()
Creates a menu filled with one SetPlafAction for each of the currently installed LFs.

Returns:
the menu to use for plaf switching.

setSystemLF

public static void setSystemLF(boolean system)
PENDING: JW - this is about toggling the LF, does nothing to update the UI. Check all tests using this method to see if they make sense!

Parameters:
system -

isSystemLF

public static boolean isSystemLF()
Returns whether the current lf is the system lf. It assumes that the lf is either cross-platform or system. Not really safe


isCrossPlatformLF

public static boolean isCrossPlatformLF()
Returns whether the current lf is the cross-platform lf. It assumes that the lf is either cross-platform or system. Not really safe