momeunit.runner
Class TestScreen

java.lang.Object
  extended by javax.microedition.lcdui.Displayable
      extended by javax.microedition.lcdui.Canvas
          extended by javax.microedition.lcdui.game.GameCanvas
              extended by momeunit.runner.TestScreen
All Implemented Interfaces:
TestListener

public class TestScreen
extends GameCanvas
implements TestListener

Canvas used by MIDletTestRunner. Displays progress bar and statistics of tests run at the top part of screen. Displays list of tests that fails or completed with errors at middle part of screen and detailed message of failure of selected test at bottom part of screen. See package description for more details about UI usage.

Version:
1.1.2
Author:
Sergio Morozov

Field Summary
 
Fields inherited from class javax.microedition.lcdui.game.GameCanvas
DOWN_PRESSED, FIRE_PRESSED, GAME_A_PRESSED, GAME_B_PRESSED, GAME_C_PRESSED, GAME_D_PRESSED, LEFT_PRESSED, RIGHT_PRESSED, UP_PRESSED
 
Fields inherited from class javax.microedition.lcdui.Canvas
DOWN, FIRE, GAME_A, GAME_B, GAME_C, GAME_D, KEY_NUM0, KEY_NUM1, KEY_NUM2, KEY_NUM3, KEY_NUM4, KEY_NUM5, KEY_NUM6, KEY_NUM7, KEY_NUM8, KEY_NUM9, KEY_POUND, KEY_STAR, LEFT, RIGHT, UP
 
Constructor Summary
TestScreen(String name)
          Instantiates TestScreen with given title and test cases number.
TestScreen(String name, boolean printStdErr, boolean printStackTrace)
          Instantiates TestScreen with given title and print behaviour flags.
TestScreen(String name, int testCasesNumber)
          Instantiates TestScreen with given title and test cases number.
TestScreen(String name, int testCasesNumber, boolean printStdErr, boolean printStackTrace)
          Instantiates TestScreen with given title, test cases number and print behaviour flags.
 
Method Summary
 void addError(Test test, Throwable t)
          Informs this listener that an error has occurred.
 void addFailure(Test test, AssertionFailedError t)
          Informs this listener that a failure has occurred.
 void clearResult(int testCasesNumber)
          Prepares TestScreen to a new tests execution.
 void endTest(Test test)
          Informs this listener about the end of test.
 boolean getFailureListType()
          Return if problem encountered while executing selected test is a failure or an error.
 String getLastTestName()
          Returns name of last started test.
static String getMessage(Throwable ex)
          Returns descriptive message based on exception thrown.
 Throwable getSelectedError()
          Returns error thrown while executing selected test.
 TestResult getTestResult()
          Returns the TestResult contained in TestScreen.
 boolean isPrintStackTrace()
          Checks if test failure and error stack-trace should be printed to standard error output.
 boolean isPrintToStdErr()
          Checks if test failure and error events should be printed to standard error output.
protected  void keyPressed(int key)
           
 void setBgColor(int color)
          Sets background color.
 void setErrorColor(int color)
          Sets color of progress bar when some tests completed with errors ans color of error statistics.
 void setFailureColor(int color)
          Sets color of progress bar when some tests fails and there are no errors ans color of failure statistics.
 void setFailureListType(boolean failureListType)
          Sets type of tests list to display.
 void setFgColor(int color)
          Sets foreground color.
 void setFont(Font font)
          Sets font of TestScreen.
 void setOkColor(int color)
          Sets color of progress bar when tests completed successfully.
 void setPrintStackTrace(boolean printStackTrace)
          Sets whether test failure and error stack-trace should be printed to standard error output.
 void setPrintToStdErr(boolean printToStdErr)
          Sets whether test failure and error events should be printed to standard error output.
 void setSelBgColor(int color)
          Sets background color of selected item.
 void setSelFgColor(int color)
          Sets foreground color of selected item.
 void setStatisticsFont(Font font)
          Sets font of statistics of TestScreen.
 void startTest(Test test)
          Informs this listener that a test has started.
 
Methods inherited from class javax.microedition.lcdui.game.GameCanvas
flushGraphics, flushGraphics, getGraphics, getKeyStates, paint
 
Methods inherited from class javax.microedition.lcdui.Canvas
getGameAction, getKeyCode, getKeyName, hasPointerEvents, hasPointerMotionEvents, hasRepeatEvents, hideNotify, isDoubleBuffered, keyReleased, keyRepeated, pointerDragged, pointerPressed, pointerReleased, repaint, repaint, serviceRepaints, setFullScreenMode, showNotify, sizeChanged
 
Methods inherited from class javax.microedition.lcdui.Displayable
addCommand, getHeight, getTicker, getTitle, getWidth, isShown, removeCommand, setCommandListener, setTicker, setTitle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TestScreen

public TestScreen(String name)
Instantiates TestScreen with given title and test cases number.

Parameters:
name - title of TestScreen.
Since:
1.0

TestScreen

public TestScreen(String name,
                  int testCasesNumber)
Instantiates TestScreen with given title and test cases number.

Parameters:
name - title of TestScreen.
testCasesNumber - number of test cases.
Since:
1.0

TestScreen

public TestScreen(String name,
                  int testCasesNumber,
                  boolean printStdErr,
                  boolean printStackTrace)
Instantiates TestScreen with given title, test cases number and print behaviour flags. if printStdErr is true TestScreen will print test failures and errors to standard error output together with stack-trace if printStackTrace flag is true.

Parameters:
name - title of TestScreen.
testCasesNumber - number of test cases.
printStdErr - print to standard error flag.
printStackTrace - print stack-trace flag.
Since:
1.0

TestScreen

public TestScreen(String name,
                  boolean printStdErr,
                  boolean printStackTrace)
Instantiates TestScreen with given title and print behaviour flags. if printStdErr is true TestScreen will print test failures and errors to standard error output together with stack-trace if printStackTrace flag is true.

Parameters:
name - title of TestScreen.
printStdErr - print to standard error flag.
printStackTrace - print stack-trace flag.
Since:
1.0
Method Detail

setFont

public void setFont(Font font)
Sets font of TestScreen.

Parameters:
font - the font to set
Throws:
NullPointerException - if font is null.
Since:
1.0

setStatisticsFont

public void setStatisticsFont(Font font)
Sets font of statistics of TestScreen.

Parameters:
font - the font of statistics to set
Throws:
NullPointerException - if font is null.
Since:
1.0

setBgColor

public void setBgColor(int color)
Sets background color.

Parameters:
color - color to be set.
Since:
1.0

setSelBgColor

public void setSelBgColor(int color)
Sets background color of selected item.

Parameters:
color - color to be set.
Since:
1.0

setSelFgColor

public void setSelFgColor(int color)
Sets foreground color of selected item.

Parameters:
color - color to be set.
Since:
1.0

setErrorColor

public void setErrorColor(int color)
Sets color of progress bar when some tests completed with errors ans color of error statistics.

Parameters:
color - color to be set.
Since:
1.0

setFailureColor

public void setFailureColor(int color)
Sets color of progress bar when some tests fails and there are no errors ans color of failure statistics.

Parameters:
color - color to be set.
Since:
1.0

setFgColor

public void setFgColor(int color)
Sets foreground color.

Parameters:
color - color to be set.
Since:
1.0

setOkColor

public void setOkColor(int color)
Sets color of progress bar when tests completed successfully.

Parameters:
color - color to be set.
Since:
1.0

isPrintToStdErr

public boolean isPrintToStdErr()
Checks if test failure and error events should be printed to standard error output.

Returns:
true if test failure and error events should be printed to standard error output, false otherwise.
Since:
1.0

setPrintToStdErr

public void setPrintToStdErr(boolean printToStdErr)
Sets whether test failure and error events should be printed to standard error output.

Parameters:
printToStdErr - true if test failure and error events should be printed to standard error output.
Since:
1.0

getTestResult

public TestResult getTestResult()
Returns the TestResult contained in TestScreen.

Returns:
TestResult instance contained in TestScreen.
Since:
1.0

isPrintStackTrace

public boolean isPrintStackTrace()
Checks if test failure and error stack-trace should be printed to standard error output.

Returns:
true if test failure and error stack-trace should be printed to standard error output, false otherwise.
Since:
1.0

setPrintStackTrace

public void setPrintStackTrace(boolean printStackTrace)
Sets whether test failure and error stack-trace should be printed to standard error output.

Parameters:
printStackTrace - true if test failure and error stack-trace should be printed to standard error output.
Since:
1.0

clearResult

public void clearResult(int testCasesNumber)
Prepares TestScreen to a new tests execution.

Parameters:
testCasesNumber - number of test cases.
Since:
1.0

getFailureListType

public boolean getFailureListType()
Return if problem encountered while executing selected test is a failure or an error.

Returns:
true if problem encountered while executing selected test is a failure false otherwise.
Since:
1.0

setFailureListType

public void setFailureListType(boolean failureListType)
Sets type of tests list to display.

Parameters:
failureListType - if true shows list of tests that fails if there are some, list of error tests if there are some otherwise.
Since:
1.0

getSelectedError

public Throwable getSelectedError()
Returns error thrown while executing selected test.

Returns:
error thrown while executing selected test.
Since:
1.0

getMessage

public static String getMessage(Throwable ex)
Returns descriptive message based on exception thrown.

Parameters:
ex - exception thrown.
Returns:
descriptive message based on exception thrown.
Since:
1.0

addError

public void addError(Test test,
                     Throwable t)
Description copied from interface: TestListener
Informs this listener that an error has occurred.

Specified by:
addError in interface TestListener
Parameters:
test - test that threw an exception.
t - Throwable thrown while executing test.

addFailure

public void addFailure(Test test,
                       AssertionFailedError t)
Description copied from interface: TestListener
Informs this listener that a failure has occurred.

Specified by:
addFailure in interface TestListener
Parameters:
test - test that failed.
t - AssertionFailedError that describes failure.

endTest

public void endTest(Test test)
Description copied from interface: TestListener
Informs this listener about the end of test.

Specified by:
endTest in interface TestListener
Parameters:
test - ended test.

startTest

public void startTest(Test test)
Description copied from interface: TestListener
Informs this listener that a test has started.

Specified by:
startTest in interface TestListener
Parameters:
test - started test.

getLastTestName

public String getLastTestName()
Returns name of last started test.

Returns:
the name of last started test.
Since:
1.1.1

keyPressed

protected void keyPressed(int key)
Overrides:
keyPressed in class Canvas