|
Java DTV API 1.0 12-Dec-2008 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sun.lwuit.DebugController
Allows us to instrument LWUIT with tools to debug and test LWUIT applications. This class provides tools for automatically testing LWUIT applications by allowing control and inspection of running applications.
It is suggested that standard applications do not reference this class outside of unit testing to avoid overhead.
Nested Class Summary | |
static class |
DebugController.Script
A script is an instance of a recording that can be stored/loaded and manipulated by a test agent. |
static interface |
DebugController.ScriptStore
A test application should implement this interface to store and load and list scripts for the automation UI. |
Field Summary | |
static int |
EDT_VIOLATION_IGNORE
Indicates that LWUIT calls that are not on the EDT should be ignored. |
static int |
EDT_VIOLATION_RUNTIME_EXCEPTION
Indicates that LWUIT calls that are not on the EDT should throw an exception. |
static int |
EDT_VIOLATION_WARN
Indicates that LWUIT calls that are not on the EDT should produce a log warning. |
static int |
SHORTCUT_ASSERTION_MANAGER
Shortcut for opening the assertion manager. |
static int |
SHORTCUT_FINISH_RECORDING
Shortcut for finishing the recording feature. |
static int |
SHORTCUT_SCRIPT_MANAGER
Shortcut for opening the script manager. |
static int |
SHORTCUT_START_RECORDING
Shortcut for activating the recording feature. |
Constructor Summary | |
DebugController()
|
Method Summary | |
void |
dragPointer(int x,
int y)
Allows a developer to manually deliver an event to LWUIT, this method is thread safe. |
void |
editScript(DebugController.Script s)
Shows the script editor dialog allowing a developer/tester to modify the scripts flow and behavior. |
Throwable |
fetchEDTException()
Fetches any exception thrown on the EDT, returns null if no exception was thrown on the EDT. |
DebugController.Script |
finishRecording()
Returns the "script" of events that occurred in LWUIT since recording started allowing us to preserve this script for playback in testing. |
int |
getEdtMode()
Indicates the behavior of LWUIT when an EDT violation is detected (not all edt violations can be detected!) |
static DebugController |
getInstance()
Returns the singleton instance of the debug controller. |
static void |
init(Object app)
Initializes the debug controller. |
static void |
init(Object app,
DebugController.ScriptStore store)
Initializes the debug controller. |
static DebugController.Script |
loadScript(InputStream o)
Allows loading a script from an arbitrary stream. |
void |
pressKey(int keyCode)
Allows a developer to manually deliver an event to LWUIT, this method is thread safe. |
void |
pressPointer(int x,
int y)
Allows a developer to manually deliver an event to LWUIT, this method is thread safe. |
void |
releaseKey(int keyCode)
Allows a developer to manually deliver an event to LWUIT, this method is thread safe. |
void |
releasePointer(int x,
int y)
Allows a developer to manually deliver an event to LWUIT, this method is thread safe. |
void |
runScript(DebugController.Script script)
Plays a LWUIT script recorded using the start/finishRecording methods, this method will block the calling thread unless it is called on the EDT. |
static DebugController.Script |
scriptFromBytes(byte[] bytes)
Allows loading a script from an arbitrary stream. |
static byte[] |
scriptToBytes(DebugController.Script s)
Allows storing a script in a byte array which is useful for RMS storage. |
void |
setEdtMode(int edtMode)
Indicates the behavior of LWUIT when an EDT violation is detected (not all edt violations can be detected!) |
void |
setPlaybackSpeed(float ratio)
Sets the ratio for playback of scripts, this defaults to 1 but can be slowed down or sped up. |
void |
setScriptStore(DebugController.ScriptStore store)
Install a script store into the controller to allow it to save the scripts and load them for later usage. |
void |
setShortcut(int keyCode,
boolean longPress,
int feature)
A shortcut is a key binding which will be triggered when something happens. |
void |
startRecording()
Allows a user to record a test script which consists of the events sent internally in LWUIT. |
static void |
storeScript(OutputStream o,
DebugController.Script s)
Allows storing a script in an arbitrary stream. |
Image |
takeScreenshot()
Returns a LWUIT image containing a screen shot of the current UI, this method is not 100% accurate and might cause a refresh and ignore some artifacts such as the ones created during transition. |
void |
waitForLWUIT()
Holds and waits for LWUIT to complete pending urgent events in its queue such as running transitions etc. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int EDT_VIOLATION_IGNORE
public static final int EDT_VIOLATION_WARN
public static final int EDT_VIOLATION_RUNTIME_EXCEPTION
public static final int SHORTCUT_START_RECORDING
public static final int SHORTCUT_FINISH_RECORDING
public static final int SHORTCUT_SCRIPT_MANAGER
public static final int SHORTCUT_ASSERTION_MANAGER
Constructor Detail |
public DebugController()
Method Detail |
public static DebugController getInstance()
public static void init(Object app)
app
- object allowing binding to the device.public static void init(Object app, DebugController.ScriptStore store)
This method is identical to init however it also binds shortcuts to the keypad to allow easier testing all shortcuts are bound to long presses. '1' is bound to start recording. '2' is bound to the assertion manager '3' is bound to stop recording. '4' is bound to the script manager
app
- object allowing binding to the device.store
- a ScriptStore objectpublic void pressPointer(int x, int y)
x
- x coordinate of the eventy
- y coordinate of the eventpublic void releasePointer(int x, int y)
x
- x coordinate of the eventy
- y coordinate of the eventpublic void dragPointer(int x, int y)
x
- x coordinate of the eventy
- y coordinate of the eventpublic void pressKey(int keyCode)
keyCode
- key code of the eventpublic void releaseKey(int keyCode)
keyCode
- key code of the eventpublic void waitForLWUIT()
public void setPlaybackSpeed(float ratio)
ratio
- a float specifying the playback speed valuepublic void startRecording()
public DebugController.Script finishRecording()
public void runScript(DebugController.Script script)
script
- a LWUIT Script objectpublic Throwable fetchEDTException()
public int getEdtMode()
setEdtMode(int)
public void setEdtMode(int edtMode)
edtMode
- an int specifying the edt mode valuegetEdtMode()
public Image takeScreenshot()
public void setScriptStore(DebugController.ScriptStore store)
store
- storage into which scripts should be savedpublic void editScript(DebugController.Script s)
s
- script for editing in the script editor.public void setShortcut(int keyCode, boolean longPress, int feature)
keyCode
- keycode to bind to the shortcutlongPress
- whether to bind this key codes long press or normal press to this featurefeature
- element that should be activated on this keyCode: SHORTCUT_FINISH_RECORDING,
SHORTCUT_START_RECORDING, SHORTCUT_SCRIPT_MANAGER, SHORTCUT_ASSERTION_MANAGERpublic static void storeScript(OutputStream o, DebugController.Script s) throws IOException
o
- an OutputStream objects
- a Script object
IOException
- if storing the script failspublic static DebugController.Script loadScript(InputStream o) throws IOException
o
- an InputStream object
IOException
- if loading the script failspublic static byte[] scriptToBytes(DebugController.Script s)
s
- the script to store
public static DebugController.Script scriptFromBytes(byte[] bytes)
bytes
- the byte array to load from.
|
Java DTV API 1.0 12-Dec-2008 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |