Java DTV API 1.0
12-Dec-2008

com.sun.lwuit
Class DebugController

java.lang.Object
  extended bycom.sun.lwuit.DebugController

public class DebugController
extends Object

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

EDT_VIOLATION_IGNORE

public static final int EDT_VIOLATION_IGNORE
Indicates that LWUIT calls that are not on the EDT should be ignored.

See Also:
Constant Field Values

EDT_VIOLATION_WARN

public static final int EDT_VIOLATION_WARN
Indicates that LWUIT calls that are not on the EDT should produce a log warning.

See Also:
Constant Field Values

EDT_VIOLATION_RUNTIME_EXCEPTION

public static final int EDT_VIOLATION_RUNTIME_EXCEPTION
Indicates that LWUIT calls that are not on the EDT should throw an exception.

See Also:
Constant Field Values

SHORTCUT_START_RECORDING

public static final int SHORTCUT_START_RECORDING
Shortcut for activating the recording feature.

See Also:
Constant Field Values

SHORTCUT_FINISH_RECORDING

public static final int SHORTCUT_FINISH_RECORDING
Shortcut for finishing the recording feature.

See Also:
Constant Field Values

SHORTCUT_SCRIPT_MANAGER

public static final int SHORTCUT_SCRIPT_MANAGER
Shortcut for opening the script manager.

See Also:
Constant Field Values

SHORTCUT_ASSERTION_MANAGER

public static final int SHORTCUT_ASSERTION_MANAGER
Shortcut for opening the assertion manager.

See Also:
Constant Field Values
Constructor Detail

DebugController

public DebugController()
Method Detail

getInstance

public static DebugController getInstance()
Returns the singleton instance of the debug controller.

Returns:
the singleton DebugController instance

init

public static void init(Object app)
Initializes the debug controller.

Parameters:
app - object allowing binding to the device.

init

public static void init(Object app,
                        DebugController.ScriptStore store)
Initializes the debug controller.

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

Parameters:
app - object allowing binding to the device.
store - a ScriptStore object

pressPointer

public void pressPointer(int x,
                         int y)
Allows a developer to manually deliver an event to LWUIT, this method is thread safe.

Parameters:
x - x coordinate of the event
y - y coordinate of the event

releasePointer

public void releasePointer(int x,
                           int y)
Allows a developer to manually deliver an event to LWUIT, this method is thread safe.

Parameters:
x - x coordinate of the event
y - y coordinate of the event

dragPointer

public void dragPointer(int x,
                        int y)
Allows a developer to manually deliver an event to LWUIT, this method is thread safe.

Parameters:
x - x coordinate of the event
y - y coordinate of the event

pressKey

public void pressKey(int keyCode)
Allows a developer to manually deliver an event to LWUIT, this method is thread safe.

Parameters:
keyCode - key code of the event

releaseKey

public void releaseKey(int keyCode)
Allows a developer to manually deliver an event to LWUIT, this method is thread safe.

Parameters:
keyCode - key code of the event

waitForLWUIT

public void waitForLWUIT()
Holds and waits for LWUIT to complete pending urgent events in its queue such as running transitions etc. This is useful when switching from one screen to the next.


setPlaybackSpeed

public void setPlaybackSpeed(float ratio)
Sets the ratio for playback of scripts, this defaults to 1 but can be slowed down or sped up. Use 0.5 for double speed and use 2 for slowing down.

Parameters:
ratio - a float specifying the playback speed value

startRecording

public void startRecording()
Allows a user to record a test script which consists of the events sent internally in LWUIT. This script can then be executed using the runScript method.


finishRecording

public 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.

Returns:
"script" of events as described above

runScript

public 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.

Parameters:
script - a LWUIT Script object

fetchEDTException

public Throwable fetchEDTException()
Fetches any exception thrown on the EDT, returns null if no exception was thrown on the EDT.

Returns:
the exception

getEdtMode

public int getEdtMode()
Indicates the behavior of LWUIT when an EDT violation is detected (not all edt violations can be detected!) this can be one of: EDT_VIOLATION_IGNORE, EDT_VIOLATION_RUNTIME_EXCEPTION, EDT_VIOLATION_WARN.

Returns:
an int representing the edt mode value
See Also:
setEdtMode(int)

setEdtMode

public void setEdtMode(int edtMode)
Indicates the behavior of LWUIT when an EDT violation is detected (not all edt violations can be detected!) this can be one of: EDT_VIOLATION_IGNORE, EDT_VIOLATION_RUNTIME_EXCEPTION, EDT_VIOLATION_WARN.

Parameters:
edtMode - an int specifying the edt mode value
See Also:
getEdtMode()

takeScreenshot

public 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.

Returns:
an Image object

setScriptStore

public 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.

Parameters:
store - storage into which scripts should be saved

editScript

public void editScript(DebugController.Script s)
Shows the script editor dialog allowing a developer/tester to modify the scripts flow and behavior.

Parameters:
s - script for editing in the script editor.

setShortcut

public void setShortcut(int keyCode,
                        boolean longPress,
                        int feature)
A shortcut is a key binding which will be triggered when something happens.

Parameters:
keyCode - keycode to bind to the shortcut
longPress - whether to bind this key codes long press or normal press to this feature
feature - element that should be activated on this keyCode: SHORTCUT_FINISH_RECORDING, SHORTCUT_START_RECORDING, SHORTCUT_SCRIPT_MANAGER, SHORTCUT_ASSERTION_MANAGER

storeScript

public static void storeScript(OutputStream o,
                               DebugController.Script s)
                        throws IOException
Allows storing a script in an arbitrary stream.

Parameters:
o - an OutputStream object
s - a Script object
Throws:
IOException - if storing the script fails

loadScript

public static DebugController.Script loadScript(InputStream o)
                                         throws IOException
Allows loading a script from an arbitrary stream.

Parameters:
o - an InputStream object
Returns:
a Script object
Throws:
IOException - if loading the script fails

scriptToBytes

public static byte[] scriptToBytes(DebugController.Script s)
Allows storing a script in a byte array which is useful for RMS storage.

Parameters:
s - the script to store
Returns:
a byte stream

scriptFromBytes

public static DebugController.Script scriptFromBytes(byte[] bytes)
Allows loading a script from an arbitrary stream.

Parameters:
bytes - the byte array to load from.
Returns:
the script

Java DTV API 1.0
12-Dec-2008

Copyright © 2008 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, California 95054, U.S.A. All rights reserved.

U.S. Government Rights - Commercial software. Government users are subject to the Sun Microsystems, Inc. standard license agreement and applicable provisions of the FAR and its supplements. Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries.Products covered by and information contained in this service manual are controlled by U.S. Export Control laws and may be subject to the export or import laws in other countries. Nuclear, missile, chemical biological weapons or nuclear maritime end uses or end users, whether direct or indirect, are strictly prohibited. Export or reexport to countries subject to U.S. embargo or to entities identified on U.S. export exclusion lists, including, but not limited to, the denied persons and specially designated nationals lists is strictly prohibited.

DOCUMENTATION IS PROVIDED AS IS AND ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD TO BE LEGALLY INVALID.

Use of this document is subject to license terms.