FileDocCategorySizeDatePackage
TestNamsStartMidlet.javaAPI DocphoneME MR2 API (J2ME)4801Wed May 02 18:00:04 BST 2007com.sun.midp.main

TestNamsStartMidlet

public class TestNamsStartMidlet extends com.sun.midp.i3test.NamsTestCase

Fields Summary
static final int
WAIT_SEC
static final int
WAIT_MS
static final int
NUMBER
int[]
dummyId
Constructors Summary
public TestNamsStartMidlet()

    
      
        dummyId = new int[3];
    
Methods Summary
booleandelay()

        boolean result = true;
        try {
            Thread.currentThread().sleep(WAIT_MS);
        } catch (InterruptedException e) {
            result = false;
        };
        return result;
    
voidrunTestDisplay()

        boolean wait_status;
        int i, j;
        
        declare("test FG/BG Display");
        
        for (i = 0; i < NUMBER; ++i) {
            dummyId[i] = NamsManager.startInternalMidlet(
                    "com.sun.midp.main.DummyNamsMIDlet" + (i+1), true, true);
            wait_status = namsNotifier.waitForState(
                    dummyId[i], NamsStorage.NAMS_STATE_PAUSED, WAIT_MS); 
            assertTrue(" Wait interrupted !", wait_status);
        }
        
        for (i = 0; i < NUMBER; ++i) {
            NamsManager.midletResume(dummyId[i]);
            wait_status = namsNotifier.waitForState(
                    dummyId[i], NamsStorage.NAMS_STATE_ACTIVE, WAIT_MS); 
            assertTrue(" Wait interrupted !", wait_status);
            
            NamsManager.midletSetForeground(dummyId[i]);
            wait_status = namsNotifier.waitForFG(dummyId[i], WAIT_MS); 
            assertTrue(" Wait interrupted !", wait_status);

            for (j = 0; j < NUMBER; ++j) {
                if (i == j) {
                    assertTrue("#" + (i+1) + " Dummy" + (j+1) + " in FG", 
                            NamsStorage.getDisplayStatus(dummyId[j]));
                    assertFalse("#" + (i+1) + " Dummy" + (j+1) + " state !", 
                        (NamsStorage.getMIDletState(dummyId[j]) == 
                            NamsStorage.NAMS_STATE_PAUSED));
                }
                else
                    assertFalse("#" + (i+1) + " Dummy"+ (j+1) + " in BG", 
                            NamsStorage.getDisplayStatus(dummyId[j]));
            }
        }
        
        delay();

        for (i = 0; i < NUMBER; ++i) {
            NamsManager.midletPause(dummyId[i]);
            wait_status = namsNotifier.waitForState(
                    dummyId[i], NamsStorage.NAMS_STATE_PAUSED, WAIT_MS); 
            assertTrue(" Wait interrupted !", wait_status);
        }
        for (i = 0; i < NUMBER; ++i) {
            assertFalse("#Paused Dummy" + (i+1) + " in BG !", 
                    NamsStorage.getDisplayStatus(dummyId[i]));
            assertTrue("#Paused Dummy" + (i+1) + " state !", 
                    (NamsStorage.getMIDletState(dummyId[i]) == 
                    NamsStorage.NAMS_STATE_PAUSED));
        }
        
        delay();
        
        for (i = 0; i < NUMBER; ++i) {
            NamsManager.midletDestroy(dummyId[i]);
            wait_status = namsNotifier.waitForState(
                    dummyId[i], NamsStorage.NAMS_STATE_DESTROYED, WAIT_MS); 
            assertTrue(" Wait interrupted !", wait_status);
        }
        for (i = 0; i < NUMBER; ++i) {
            assertFalse("#Destroyed Dummy" + (i+1) + " in BG !", 
                    NamsStorage.getDisplayStatus(dummyId[i]));
            assertTrue("#Destroyed Dummy" + (i+1) + " state !", 
                    (NamsStorage.getMIDletState(dummyId[i]) == 
                    NamsStorage.NAMS_STATE_DESTROYED));
        }

        delay();
    
public voidrunTests()

        runTestDisplay();