Search in sources :

Example 21 with LogRec

use of com.android.internal.util.StateMachine.LogRec in project android_frameworks_base by AOSPA.

the class StateMachineTest method testStateMachineQuit.

@SmallTest
public void testStateMachineQuit() throws Exception {
    if (WAIT_FOR_DEBUGGER)
        Debug.waitForDebugger();
    StateMachineQuitTest smQuitTest = new StateMachineQuitTest("smQuitTest");
    smQuitTest.start();
    if (smQuitTest.isDbg())
        tlog("testStateMachineQuit E");
    synchronized (smQuitTest) {
        // Send 6 message we'll quit on the first but all 6 should be processed before quitting.
        for (int i = 1; i <= 6; i++) {
            smQuitTest.sendMessage(smQuitTest.obtainMessage(i));
        }
        try {
            // wait for the messages to be handled
            smQuitTest.wait();
        } catch (InterruptedException e) {
            tloge("testStateMachineQuit: exception while waiting " + e.getMessage());
        }
    }
    dumpLogRecs(smQuitTest.mLogRecs);
    assertEquals(8, smQuitTest.mLogRecs.size());
    LogRec lr;
    Iterator<LogRec> itr = smQuitTest.mLogRecs.iterator();
    for (int i = 1; i <= 6; i++) {
        lr = itr.next();
        assertEquals(i, lr.getWhat());
        assertEquals(smQuitTest.mS1, lr.getState());
        assertEquals(smQuitTest.mS1, lr.getOriginalState());
    }
    lr = itr.next();
    assertEquals(EXIT, lr.getInfo());
    assertEquals(smQuitTest.mS1, lr.getState());
    lr = itr.next();
    assertEquals(ON_QUITTING, lr.getInfo());
    if (smQuitTest.isDbg())
        tlog("testStateMachineQuit X");
}
Also used : LogRec(com.android.internal.util.StateMachine.LogRec) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 22 with LogRec

use of com.android.internal.util.StateMachine.LogRec in project android_frameworks_base by AOSPA.

the class StateMachineTest method testHsm1.

@MediumTest
public void testHsm1() throws Exception {
    if (DBG)
        tlog("testHsm1 E");
    Hsm1 sm = Hsm1.makeHsm1();
    // Send messages
    sm.sendMessage(Hsm1.CMD_1);
    sm.sendMessage(Hsm1.CMD_2);
    synchronized (sm) {
        // Wait for the last state machine to notify its done
        try {
            sm.wait();
        } catch (InterruptedException e) {
            tloge("testHsm1: exception while waiting " + e.getMessage());
        }
    }
    dumpLogRecs(sm);
    assertEquals(7, sm.getLogRecCount());
    LogRec lr = sm.getLogRec(0);
    assertEquals(Hsm1.CMD_1, lr.getWhat());
    assertEquals(sm.mS1, lr.getState());
    assertEquals(sm.mS1, lr.getOriginalState());
    lr = sm.getLogRec(1);
    assertEquals(Hsm1.CMD_2, lr.getWhat());
    assertEquals(sm.mP1, lr.getState());
    assertEquals(sm.mS1, lr.getOriginalState());
    lr = sm.getLogRec(2);
    assertEquals(Hsm1.CMD_2, lr.getWhat());
    assertEquals(sm.mS2, lr.getState());
    assertEquals(sm.mS2, lr.getOriginalState());
    lr = sm.getLogRec(3);
    assertEquals(Hsm1.CMD_3, lr.getWhat());
    assertEquals(sm.mS2, lr.getState());
    assertEquals(sm.mS2, lr.getOriginalState());
    lr = sm.getLogRec(4);
    assertEquals(Hsm1.CMD_3, lr.getWhat());
    assertEquals(sm.mP2, lr.getState());
    assertEquals(sm.mP2, lr.getOriginalState());
    lr = sm.getLogRec(5);
    assertEquals(Hsm1.CMD_4, lr.getWhat());
    assertEquals(sm.mP2, lr.getState());
    assertEquals(sm.mP2, lr.getOriginalState());
    lr = sm.getLogRec(6);
    assertEquals(Hsm1.CMD_5, lr.getWhat());
    assertEquals(sm.mP2, lr.getState());
    assertEquals(sm.mP2, lr.getOriginalState());
    if (DBG)
        tlog("testStateMachineSharedThread X");
}
Also used : LogRec(com.android.internal.util.StateMachine.LogRec) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 23 with LogRec

use of com.android.internal.util.StateMachine.LogRec in project android_frameworks_base by AOSPA.

the class StateMachineTest method testStateMachineSharedThread.

@MediumTest
public void testStateMachineSharedThread() throws Exception {
    if (DBG)
        tlog("testStateMachineSharedThread E");
    // Create and start the handler thread
    HandlerThread smThread = new HandlerThread("testStateMachineSharedThread");
    smThread.start();
    // Create the state machines
    StateMachineSharedThread[] sms = new StateMachineSharedThread[10];
    for (int i = 0; i < sms.length; i++) {
        sms[i] = new StateMachineSharedThread("smSharedThread", smThread.getLooper(), sms.length);
        sms[i].start();
    }
    synchronized (waitObject) {
        // Send messages to each of the state machines
        for (StateMachineSharedThread sm : sms) {
            for (int i = 1; i <= 4; i++) {
                sm.sendMessage(i);
            }
        }
        // Wait for the last state machine to notify its done
        try {
            waitObject.wait();
        } catch (InterruptedException e) {
            tloge("testStateMachineSharedThread: exception while waiting " + e.getMessage());
        }
    }
    for (StateMachineSharedThread sm : sms) {
        assertEquals(4, sm.getLogRecCount());
        for (int i = 0; i < sm.getLogRecSize(); i++) {
            LogRec lr = sm.getLogRec(i);
            assertEquals(i + 1, lr.getWhat());
            assertEquals(sm.mS1, lr.getState());
            assertEquals(sm.mS1, lr.getOriginalState());
        }
    }
    if (DBG)
        tlog("testStateMachineSharedThread X");
}
Also used : LogRec(com.android.internal.util.StateMachine.LogRec) HandlerThread(android.os.HandlerThread) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 24 with LogRec

use of com.android.internal.util.StateMachine.LogRec in project android_frameworks_base by AOSPA.

the class StateMachineTest method testStateMachine1.

@MediumTest
public void testStateMachine1() throws Exception {
    StateMachine1 sm1 = new StateMachine1("sm1");
    sm1.start();
    if (sm1.isDbg())
        tlog("testStateMachine1 E");
    synchronized (sm1) {
        // Send two messages
        sm1.sendMessage(TEST_CMD_1);
        sm1.sendMessage(TEST_CMD_2);
        try {
            // wait for the messages to be handled
            sm1.wait();
        } catch (InterruptedException e) {
            tloge("testStateMachine1: exception while waiting " + e.getMessage());
        }
    }
    assertEquals(2, sm1.mEnterCount);
    assertEquals(2, sm1.mExitCount);
    assertEquals(2, sm1.getLogRecSize());
    LogRec lr;
    lr = sm1.getLogRec(0);
    assertEquals(TEST_CMD_1, lr.getWhat());
    assertEquals(sm1.mS1, lr.getState());
    assertEquals(sm1.mS1, lr.getOriginalState());
    lr = sm1.getLogRec(1);
    assertEquals(TEST_CMD_2, lr.getWhat());
    assertEquals(sm1.mS1, lr.getState());
    assertEquals(sm1.mS1, lr.getOriginalState());
    assertEquals(2, sm1.mEnterCount);
    assertEquals(2, sm1.mExitCount);
    if (sm1.isDbg())
        tlog("testStateMachine1 X");
}
Also used : LogRec(com.android.internal.util.StateMachine.LogRec) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 25 with LogRec

use of com.android.internal.util.StateMachine.LogRec in project android_frameworks_base by AOSPA.

the class StateMachineTest method testStateMachine0.

@SmallTest
public void testStateMachine0() throws Exception {
    //if (WAIT_FOR_DEBUGGER) Debug.waitForDebugger();
    StateMachine0 sm0 = new StateMachine0("sm0");
    sm0.start();
    if (sm0.isDbg())
        tlog("testStateMachine0 E");
    synchronized (sm0) {
        // Send 6 messages
        for (int i = 1; i <= 6; i++) {
            sm0.sendMessage(sm0.obtainMessage(i));
        }
        try {
            // wait for the messages to be handled
            sm0.wait();
        } catch (InterruptedException e) {
            tloge("testStateMachine0: exception while waiting " + e.getMessage());
        }
    }
    assertEquals(6, sm0.getLogRecCount());
    assertEquals(3, sm0.getLogRecSize());
    dumpLogRecs(sm0);
    LogRec lr;
    lr = sm0.getLogRec(0);
    assertEquals(TEST_CMD_4, lr.getWhat());
    assertEquals(sm0.mS1, lr.getState());
    assertEquals(sm0.mS1, lr.getOriginalState());
    lr = sm0.getLogRec(1);
    assertEquals(TEST_CMD_5, lr.getWhat());
    assertEquals(sm0.mS1, lr.getState());
    assertEquals(sm0.mS1, lr.getOriginalState());
    lr = sm0.getLogRec(2);
    assertEquals(TEST_CMD_6, lr.getWhat());
    assertEquals(sm0.mS1, lr.getState());
    assertEquals(sm0.mS1, lr.getOriginalState());
    if (sm0.isDbg())
        tlog("testStateMachine0 X");
}
Also used : LogRec(com.android.internal.util.StateMachine.LogRec) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Aggregations

LogRec (com.android.internal.util.StateMachine.LogRec)78 MediumTest (android.test.suitebuilder.annotation.MediumTest)42 SmallTest (android.test.suitebuilder.annotation.SmallTest)24 HandlerThread (android.os.HandlerThread)6