marciodrosa/ZineMob — Issue #8: Functional tests
Author: marciodrosa
Created: 2012-03-06 02:48:31+00:00
State: open
Labels: feature

class FunctionalTestCase: this is where are the automatized behavior and the assertions. The user should create a class that inherits FunctionalTestCase and calls those methods:

waitFrames(int) // relative to the current frame
waitUntilFrame(int) // absolute frame (since the begin of this test)
pressKey(int)
releaseKey(int)
setKeyStates(int)
touchScreen(int, int)
releaseTouchScreen()
// most of the below methods should have a version without the "assert" prefix:
assertTextIsPresent(String)
assertElementIsAtLastPartiallyVisibleOnScreen(DrawableElement)
assertElementIsEntirelyVisibleOnScreen(DrawableElement)
assertElementIsOnTop(DrawableElement) // no one element appears above this
assertElementIsVisible(DrawableElement) // just checks the visible flag
assertCrop(x, y, w, h)
assertEquals
assertTrue
assertFalse
assertNotEquals
assertPosition(DrawableElement)
assertLeftPosition(DrawableElement, int)
assertRightPosition(DrawableElement, int)
assertTopPosition(DrawableElement, int)
assertBottomPosition(DrawableElement, int)
assertSize(DrawableElement, int, int)
assertFrame(SpriteElement, int)

class FunctionalTestSuite: contains a list of FunctionalTestCases that will be executed.
addTestCase(FunctionalTestCase)
static setTestSuite(FunctionalTestSuite) // the user should call this method at the begin of midlet execution. So, all scenes will ignore the user input and will be controlled by the test cases (until the end of the suite).

class FunctionalTestCodeGenerator: utility class to record the behavior to be tested.
printCode()
String getCode()
static setCodeGenerator(FunctionalTestCodeGenerator) // when the user is playing the game, the generator will start record all input events, that can be retrieved with the printCode and getCode.
assertCurrentState()

about the assertCurrentState methods: parses all scene drawable elements (or it should do that only with elements with some kind of mark??), doing the following asserts:
- assertTextIsPresent // if it is a text
- assertElementIsAtLastPartiallyVisibleOnScreen // if it is partially visible
- assertElementIsEntirelyVisibleOnScreen // if it is totally visible
- assertElementIsOnTop // is is on the top
- assertLeftPosition
- assertRightPosition
- assertTopPosition
- assertBottomPosition
- assertSize
- assertFrame // if it is a sprite

Scene
- setControlPanel(ControlPanel) - gui panel over the scene, contains buttons to pause, step one frame or play, + custom commands. Only can be accessed by the touch screen.

ControlPanel
- GuiScene guiScene
- addCustomCommand(String name, Runnable runnable)

* When there is a FunctionalTestCodeGenerator setted, then a ControlPanel is automatically visible, with one custom command to do the assertions ("assert").