FileDocCategorySizeDatePackage
AutomationHandler.javaAPI DocJ2ME MIDP 2.07329Thu Nov 07 12:02:22 GMT 2002com.sun.midp.lcdui

AutomationHandler

public interface AutomationHandler
The automation handler class. This is an abstract class which which provides options to record and playback a sequence of events for automation purposes, as well as capture the contents of the screen.

Fields Summary
public static final int
START_RECORDING
The identifier for the 'start recording' action to be used when registering a new hotkey. The default hotkey for this action is 'F1'.
public static final int
STOP_RECORDING
The identifier for the 'stop recording' action to be used when registering a new hotkey. The default hotkey for this action is 'F2'.
public static final int
CAPTURE_SCREEN
The identifier for the 'capture screen' action to be used when registering a new hotkey. The default hotkey for this action is 'F3'.
Constructors Summary
Methods Summary
public byte[]captureScreen()
Capture the current contents of the physical display in the form of a byte array. The byte array may be some reduced form of the display, such as a checksum or hash, but must be guaranteed unique for the display such that no two differing displays will have the same return value

return
The byte[] of the captured screen contents

public voidregisterHotKey(int action, int keyCode)
Establish a specific key code for the given action to serve as a 'hotkey'. The action must be one of START_RECORDING, STOP_RECORDING, or CAPTURE_SCREEN.

param
action The action to register the hotkey for, one of START_RECORDING, STOP_RECORDING, or CAPTURE_SCREEN.
param
keyCode The key code of the new hotkey
throws
IllegalArgumentException If this particular port or platform cannot support hotkey activation, this method will throw an exception. An exception will also be thrown if the requested action or key code is invalid.

public voidregisterSequenceHandler(SequenceHandler handler)
Establish a SequenceHandler to handle the completion of EventSequences. and screen captures which occur as a result of a 'hotkey' press. If a sequence handler is set, that handler will be called when any event sequence is completed, either as a result of stopEventSequence() being called, or as a result of some "hot key" being pressed which the event handler recognizes as a signal to stop event recording. The EventSequence object passed to the handler will be the same as the return result of the stopEventSequence() method. If a handler has already been set, and this method is called again the old handler will be discarded and the new handler will be used. If 'null' is passed, any previous handler will be discarded.

param
handler The SequenceHandler which will get the callback whenever an event sequence is completed.
throws
IllegalArgumentException If this particular port or platform cannot support hotkey activation, this method will throw an exception

public booleanreplayEventSequence(EventSequence sequence)
Replay a given event sequence. This will replay a sequence of events represented in the given EventSequence object. It will then capture the contents of the screen at the end of the event sequence and compare it to the screen capture that is included in the EventSequence object.

param
sequence The EventSequence object to replay and test
return
True if the screen capture at the end of replaying the given event sequence matches that which is stored in the given EventSequence object.

public booleanreplayEventSequence(EventSequence sequence, int speed)
Replay a given event sequence. This will replay a sequence of events represented in the given EventSequence object. It will then capture the contents of the screen at the end of the event sequence and compare it to the screen capture that is included in the EventSequence object.

param
sequence The EventSequence object to replay and test
param
speed The factor by which to modify the replay speed of the event sequence. This is on a scale of 100, meaning a value of 100 would be normal speed, 50 would be half speed, and 200 would be double speed.
return
True if the screen capture at the end of replaying the given event sequence matches that which is stored in the given EventSequence object.

public voidstartEventSequence()
Start recording an event sequence. Any event sequence currently being recorded will be destroyed and a new event sequence will be started.

public EventSequencestopEventSequence()
Stop recording an event sequence. This will stop recording the current event sequence and capture the current contents of the screen. It will then return an EventSequence object which is the representation of the entire event sequence as well as the screen capture resulting at the end of the sequence. If no events occurred during the capture, the sequence will simply be a timed delay with a screen capture. The timed delay will be the time delay between the call to startEventSequence() and stopEventSequence(). If stopEventSequence() is called without previously calling startEventSequence(), an EventSequence will be returned which is essentially "empty" and only contains the current contents of the captured screen.

return
EventSequence The sequence of events recorded as well as the screen capture recorded at the end of the sequence of events.

public EventSequenceupdateScreenForSequence(EventSequence sequence)
Update the screen capture for this event sequence. Over time, the screen captures in a stored event sequence may become out of date. Calling this method will run the given event sequence, capture the resulting screen, and return the same EventSequence object with the updated screen value.

param
sequence The EventSequence to run and update the screen for
return
The updated EventSequence with the new captured screen value