CS 1705 Library

objectdraw
Class TestableWindowController

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Panel
              extended by java.applet.Applet
                  extended by javax.swing.JApplet
                      extended by objectdraw.Controller
                          extended by objectdraw.WindowController
                              extended by objectdraw.FrameWindowController
                                  extended by objectdraw.TestableWindowController
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, RootPaneContainer
Direct Known Subclasses:
StudentTestableWindowController

public class TestableWindowController
extends objectdraw.FrameWindowController

TestableWindowController is an FrameWindowController with various methods to assert things about the state of the Window.

Version:
June 5, 2006
Author:
Roy Patrick Tan
See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
TestableWindowController()
          This constructor forces TestableWindowController to wait for the initial window to draw itself before exiting the constructor.
 
Method Summary
 void assertHas2DObject(Class shape, objectdraw.Location loc, Double width, Double height, Color color, Boolean visible)
          assert version of has2DObject
 void assertHas2DObject(String hint, Class shape, objectdraw.Location loc, Double width, Double height, Color color, Boolean visible)
          assert version of has2DObject that has a specific hint to the user.
 void assertHasLine(objectdraw.Location start, objectdraw.Location end, Color color, Boolean visible)
          assertHasLine asserts the existence of a line with the specified parameters.
 void assertHasLine(String hint, objectdraw.Location start, objectdraw.Location end, Color color, Boolean visible)
          assertHasLine asserts the existence of a line with the specified parameters.
 void assertNo2DObject(Class shape, objectdraw.Location loc, Double width, Double height, Color color, Boolean visible)
          inverse of assertHas2DObject, this method will fail if an object specified by the parameters is found, suceed otherwise.
 void assertNo2DObject(String hint, Class shape, objectdraw.Location loc, Double width, Double height, Color color, Boolean visible)
          inverse of assertHas2DObject, this method will fail if an object specified by the parameters is found, suceed otherwise.
 void assertNoLine(objectdraw.Location start, objectdraw.Location end, Color color, Boolean visible)
          assertNoLine asserts the non-existence of a line with the specified parameters.
 void assertNoLine(String hint, objectdraw.Location start, objectdraw.Location end, Color color, Boolean visible)
          assertNoLine iasserts the non-existence of a line with the specified parameters.
 objectdraw.Drawable2DInterface get2DObject(Class shape, objectdraw.Location loc, Double width, Double height, Color color, Boolean visible)
          get2dObject returns an arbitrary shape that meets the specified parameters.
 List<objectdraw.Drawable2DInterface> get2DObjects(Class shape, objectdraw.Location loc, Double width, Double height, Color color, Boolean visible)
          get2dObject gets a list of 2D object with the specified parameters.
 objectdraw.DrawingCanvas getCanvas()
          Accessor function to get the DrawingCanvas from the frame.
 JFrame getFrame()
          Get the top-level JFrame component.
 objectdraw.Line getLine(objectdraw.Location start, objectdraw.Location end, Color color, Boolean visible)
          getLine returns an arbitrary Line object that fits the parameters that are passed to the function.
 List<objectdraw.Line> getLines(objectdraw.Location start, objectdraw.Location end, Color color, Boolean visible)
          getLines gets a list of lines with the specified parameters.
 boolean has2DObject(Class shape, objectdraw.Location loc, Double width, Double height, Color color, Boolean visible)
          has2dObject determines existence of a 2D object with the specified parameters.
 boolean hasLine(objectdraw.Location start, objectdraw.Location end, Color color, Boolean visible)
          hasLine returns determines the existence of a line with the specified parameters.
 void paint(Graphics g)
          Paint gets called by the system whenever the application needs to be repainted.
 void waitForInit()
          This method forces the program to wait on a thread to release the init lock.
 
Methods inherited from class objectdraw.WindowController
begin, onMouseClick, onMouseDrag, onMouseEnter, onMouseExit, onMouseMove, onMousePress, onMouseRelease
 
Methods inherited from class objectdraw.Controller
destroy, getAudio, getImage, getTime, getVersion, init, placeInFrame, resize, start, startController, startController, stop
 
Methods inherited from class javax.swing.JApplet
getAccessibleContext, getContentPane, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, remove, setContentPane, setGlassPane, setJMenuBar, setLayeredPane, setLayout, update
 
Methods inherited from class java.applet.Applet
getAppletContext, getAppletInfo, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, getParameterInfo, isActive, newAudioClip, play, play, resize, setStub, showStatus
 
Methods inherited from class java.awt.Panel
addNotify
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusBackward, transferFocusDownCycle, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, dispatchEvent, enable, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocusInWindow, reshape, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TestableWindowController

public TestableWindowController()
This constructor forces TestableWindowController to wait for the initial window to draw itself before exiting the constructor.

Method Detail

getFrame

public JFrame getFrame()
Get the top-level JFrame component. You will not use this function for developing your test cases.


waitForInit

public void waitForInit()
This method forces the program to wait on a thread to release the init lock. you will not use this function for developing your test cases.


paint

public void paint(Graphics g)
Paint gets called by the system whenever the application needs to be repainted.

Overrides:
paint in class objectdraw.FrameWindowController

has2DObject

public boolean has2DObject(Class shape,
                           objectdraw.Location loc,
                           Double width,
                           Double height,
                           Color color,
                           Boolean visible)
has2dObject determines existence of a 2D object with the specified parameters. Every parameter can be passed null to mean "any".

Parameters:
shape - the shape of the object. null for any shape.
loc - the location of the object on the canvas, null for any location.
width - the width of the object, null for any width.
height - the height of the object, null for any height.
color - the color of the object, null for any color.
visible - whether the object is visible on the canvas or not. pass null, if either.
Returns:
true if it has the 2D object specified, false if not.

get2DObject

public objectdraw.Drawable2DInterface get2DObject(Class shape,
                                                  objectdraw.Location loc,
                                                  Double width,
                                                  Double height,
                                                  Color color,
                                                  Boolean visible)
get2dObject returns an arbitrary shape that meets the specified parameters. That arbitrary shape is the first one that appears in the DrawableIterator for the canvas. A null parameter can mean "any"

Parameters:
shape - the shape of the object. null for any shape.
loc - the location of the object on the canvas, null for any location.
width - the width of the object, null for any width.
height - the height of the object, null for any height.
color - the color of the object, null for any color.
visible - whether the object is visible on the canvas or not. pass null, if either.
Returns:
an arbitrary shape that fits the parameters passed, or null if no such element exists.

getLine

public objectdraw.Line getLine(objectdraw.Location start,
                               objectdraw.Location end,
                               Color color,
                               Boolean visible)
getLine returns an arbitrary Line object that fits the parameters that are passed to the function. A null parameter means "any."

Parameters:
start - the starting point of the line, null for any starting location
end - the end location of the line, null for any end location
color - the color of the line, null for any color.
visible - whether the line is visible on the canvas or not. pass null, if either.
Returns:
an arbitrary Line that fits the parameters passed, or null, if no such line exists.

get2DObjects

public List<objectdraw.Drawable2DInterface> get2DObjects(Class shape,
                                                         objectdraw.Location loc,
                                                         Double width,
                                                         Double height,
                                                         Color color,
                                                         Boolean visible)
get2dObject gets a list of 2D object with the specified parameters. Every parameter can be passed null to mean "any".

Parameters:
shape - the shape of the object. null for any shape.
loc - the location of the object on the canvas, null for any location.
width - the width of the object, null for any width.
height - the height of the object, null for any height.
color - the color of the object, null for any color.
visible - whether the object is visible on the canvas or not. pass null, if either.
Returns:
a List of the 2D objects specified, the list may be empty

getCanvas

public objectdraw.DrawingCanvas getCanvas()
Accessor function to get the DrawingCanvas from the frame. This is for testing purposes.


assertHas2DObject

public void assertHas2DObject(Class shape,
                              objectdraw.Location loc,
                              Double width,
                              Double height,
                              Color color,
                              Boolean visible)
assert version of has2DObject

Parameters:
shape - the shape of the object. null for any shape.
loc - the location of the object on the canvas, null for any location.
width - the width of the object, null for any width.
height - the height of the object, null for any height.
color - the color of the object, null for any color.
visible - whether the object is visible on the canvas or not. pass null, if either.

assertNo2DObject

public void assertNo2DObject(Class shape,
                             objectdraw.Location loc,
                             Double width,
                             Double height,
                             Color color,
                             Boolean visible)
inverse of assertHas2DObject, this method will fail if an object specified by the parameters is found, suceed otherwise.

Parameters:
shape - the shape of the object. null for any shape.
loc - the location of the object on the canvas, null for any location.
width - the width of the object, null for any width.
height - the height of the object, null for any height.
color - the color of the object, null for any color.
visible - whether the object is visible on the canvas or not. pass null, if either.

hasLine

public boolean hasLine(objectdraw.Location start,
                       objectdraw.Location end,
                       Color color,
                       Boolean visible)
hasLine returns determines the existence of a line with the specified parameters. Any of the parameters can be null to mean "dont care".

Parameters:
start - the starting point of the line, null for any starting location
end - the end location of the line, null for any end location
color - the color of the line, null for any color.
visible - whether the line is visible on the canvas or not. pass null, if either.
Returns:
true if the line exists.

getLines

public List<objectdraw.Line> getLines(objectdraw.Location start,
                                      objectdraw.Location end,
                                      Color color,
                                      Boolean visible)
getLines gets a list of lines with the specified parameters. Any of the parameters can be null to mean "dont care".

Parameters:
start - the starting point of the line, null for any starting location
end - the end location of the line, null for any end location
color - the color of the line, null for any color.
visible - whether the line is visible on the canvas or not. pass null, if either.
Returns:
a possibly empty list of lines that satisfy the scriteria specified by the parameters.

assertHasLine

public void assertHasLine(objectdraw.Location start,
                          objectdraw.Location end,
                          Color color,
                          Boolean visible)
assertHasLine asserts the existence of a line with the specified parameters. This method fails if no such line exists.

Parameters:
start - the starting point of the line, null for any starting location
end - the end location of the line, null for any end location
color - the color of the line, null for any color.
visible - whether the line is visible on the canvas or not. pass null, if either.

assertNoLine

public void assertNoLine(objectdraw.Location start,
                         objectdraw.Location end,
                         Color color,
                         Boolean visible)
assertNoLine asserts the non-existence of a line with the specified parameters. This method fails if such line exists.

Parameters:
start - the starting point of the line, null for any starting location
end - the end location of the line, null for any end location
color - the color of the line, null for any color.
visible - whether the line is visible on the canvas or not. pass null, if either.

assertHas2DObject

public void assertHas2DObject(String hint,
                              Class shape,
                              objectdraw.Location loc,
                              Double width,
                              Double height,
                              Color color,
                              Boolean visible)
assert version of has2DObject that has a specific hint to the user.

Parameters:
hint - error message that should be displayed for a failed assertion
shape - the shape of the object. null for any shape.
loc - the location of the object on the canvas, null for any location.
width - the width of the object, null for any width.
height - the height of the object, null for any height.
color - the color of the object, null for any color.
visible - whether the object is visible on the canvas or not. pass null, if either.

assertNo2DObject

public void assertNo2DObject(String hint,
                             Class shape,
                             objectdraw.Location loc,
                             Double width,
                             Double height,
                             Color color,
                             Boolean visible)
inverse of assertHas2DObject, this method will fail if an object specified by the parameters is found, suceed otherwise. Prints a custom message in the event of failure.

Parameters:
hint - error message that should be displayed for a failed assertion
shape - the shape of the object. null for any shape.
loc - the location of the object on the canvas, null for any location.
width - the width of the object, null for any width.
height - the height of the object, null for any height.
color - the color of the object, null for any color.
visible - whether the object is visible on the canvas or not. pass null, if either.

assertHasLine

public void assertHasLine(String hint,
                          objectdraw.Location start,
                          objectdraw.Location end,
                          Color color,
                          Boolean visible)
assertHasLine asserts the existence of a line with the specified parameters. This method fails if no such line exists. Prints a custom error message in the event of failure.

Parameters:
hint - error message that should be displayed for a failed assertion
start - the starting point of the line, null for any starting location
end - the end location of the line, null for any end location
color - the color of the line, null for any color.
visible - whether the line is visible on the canvas or not. pass null, if either.

assertNoLine

public void assertNoLine(String hint,
                         objectdraw.Location start,
                         objectdraw.Location end,
                         Color color,
                         Boolean visible)
assertNoLine iasserts the non-existence of a line with the specified parameters. This method fails if such line exists. Displays a custom error message in the event of failure.

Parameters:
hint - error message that should be displayed for a failed assertion.
start - the starting point of the line, null for any starting location
end - the end location of the line, null for any end location
color - the color of the line, null for any color.
visible - whether the line is visible on the canvas or not. pass null, if either.

Last updated: Wed, Apr 1, 2009 • 12:29 AM EDT

Copyright © 2009 Virginia Tech.