FileDocCategorySizeDatePackage
LcduiTestMIDlet.javaAPI DocphoneME MR2 API (J2ME)4002Wed May 02 18:00:00 BST 2007com.sun.midp.util

LcduiTestMIDlet

public class LcduiTestMIDlet extends javax.microedition.midlet.MIDlet
A MIDlet for use by i3tests. This MIDlet includes utility functions that start the midlet, activate it, and bring its display into the foreground. Invoke this from a test class with the statement LcduiTestMIDlet.invoke(); and clean it up with the statement LcduiTestMIDlet.cleanup();

Fields Summary
static LcduiTestMIDlet
midlet
static javax.microedition.lcdui.Display
display
static Object
lock
static boolean
canvasPainted
static LcduiTestCanvas
cv
Constructors Summary
public LcduiTestMIDlet()
Should be called only by the MIDlet runtime.

        midlet = this;
        display = Display.getDisplay(this);
    
Methods Summary
public static voidcleanup()
Destroys the test MIDlet and waits for the AMS to finish its processing.

        midlet.notifyDestroyed();

        try {
            midlet.destroyApp(true);
        } catch (MIDletStateChangeException ignore) { }

        // Wait for the AMS to finish processing.
        // IMPL NOTE: there should be a better way than to sleep.
        try {
            Thread.sleep(1000);
        } catch (InterruptedException ignore) { }
    
public voiddestroyApp(boolean unconditional)
Should be called only by the MIDlet runtime.

        midlet = null;
        display = null;
    
public static javax.microedition.lcdui.DisplaygetDisplay()
Gets the Display object for the test MIDlet. This is non-null only between calls to invoke() and cleanup().

        return display;
    
public static javax.microedition.midlet.MIDletgetMIDlet()
Gets the MIDlet instance. This is non-null only between calls to invoke() and cleanup().

        return midlet;
    
public static booleaninvoke()
Starts the test MIDlet and waits for it to be created, activated, and for its Display to be put into the foreground and painted. Returns true if this all worked; returns false if the operation timed out. Passes on any exceptions that occurred in starting up the MIDlet.


        midlet = null;
        display = null;
        cv = new LcduiTestCanvas();

        MIDletStateHandler.getMidletStateHandler().startMIDlet(
            "com.sun.midp.util.LcduiTestMIDlet",
            "LCDUI Test MIDlet");

        return cv.awaitPaint();
    
public voidpauseApp()
Should be called only by the MIDlet runtime.

    
public voidstartApp()
Should be called only by the MIDlet runtime.

        display.setCurrent(cv);