Search in sources :

Example 51 with LogRec

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

the class StateMachineTest method testStateMachine5.

@MediumTest
public void testStateMachine5() throws Exception {
    StateMachine5 sm5 = new StateMachine5("sm5");
    sm5.start();
    if (sm5.isDbg())
        tlog("testStateMachine5 E");
    synchronized (sm5) {
        // Send 6 messages
        sm5.sendMessage(TEST_CMD_1);
        sm5.sendMessage(TEST_CMD_2);
        sm5.sendMessage(TEST_CMD_3);
        sm5.sendMessage(TEST_CMD_4);
        sm5.sendMessage(TEST_CMD_5);
        sm5.sendMessage(TEST_CMD_6);
        try {
            // wait for the messages to be handled
            sm5.wait();
        } catch (InterruptedException e) {
            tloge("testStateMachine5: exception while waiting " + e.getMessage());
        }
    }
    assertEquals(6, sm5.getLogRecSize());
    assertEquals(1, sm5.mParentState1EnterCount);
    assertEquals(1, sm5.mParentState1ExitCount);
    assertEquals(1, sm5.mChildState1EnterCount);
    assertEquals(1, sm5.mChildState1ExitCount);
    assertEquals(1, sm5.mChildState2EnterCount);
    assertEquals(1, sm5.mChildState2ExitCount);
    assertEquals(2, sm5.mParentState2EnterCount);
    assertEquals(2, sm5.mParentState2ExitCount);
    assertEquals(1, sm5.mChildState3EnterCount);
    assertEquals(1, sm5.mChildState3ExitCount);
    assertEquals(2, sm5.mChildState4EnterCount);
    assertEquals(2, sm5.mChildState4ExitCount);
    assertEquals(1, sm5.mChildState5EnterCount);
    assertEquals(1, sm5.mChildState5ExitCount);
    LogRec lr;
    lr = sm5.getLogRec(0);
    assertEquals(TEST_CMD_1, lr.getWhat());
    assertEquals(sm5.mChildState1, lr.getState());
    assertEquals(sm5.mChildState1, lr.getOriginalState());
    lr = sm5.getLogRec(1);
    assertEquals(TEST_CMD_2, lr.getWhat());
    assertEquals(sm5.mChildState2, lr.getState());
    assertEquals(sm5.mChildState2, lr.getOriginalState());
    lr = sm5.getLogRec(2);
    assertEquals(TEST_CMD_3, lr.getWhat());
    assertEquals(sm5.mChildState5, lr.getState());
    assertEquals(sm5.mChildState5, lr.getOriginalState());
    lr = sm5.getLogRec(3);
    assertEquals(TEST_CMD_4, lr.getWhat());
    assertEquals(sm5.mChildState3, lr.getState());
    assertEquals(sm5.mChildState3, lr.getOriginalState());
    lr = sm5.getLogRec(4);
    assertEquals(TEST_CMD_5, lr.getWhat());
    assertEquals(sm5.mChildState4, lr.getState());
    assertEquals(sm5.mChildState4, lr.getOriginalState());
    lr = sm5.getLogRec(5);
    assertEquals(TEST_CMD_6, lr.getWhat());
    assertEquals(sm5.mParentState2, lr.getState());
    assertEquals(sm5.mParentState2, lr.getOriginalState());
    if (sm5.isDbg())
        tlog("testStateMachine5 X");
}
Also used : LogRec(com.android.internal.util.StateMachine.LogRec) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 52 with LogRec

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

the class StateMachineTest method testStateMachine4.

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

Example 53 with LogRec

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

the class StateMachineTest method dumpLogRecs.

private void dumpLogRecs(StateMachine sm) {
    int size = sm.getLogRecSize();
    tlog("size=" + size + " count=" + sm.getLogRecCount());
    for (int i = 0; i < size; i++) {
        LogRec lr = sm.getLogRec(i);
        tlog(lr.toString());
    }
}
Also used : LogRec(com.android.internal.util.StateMachine.LogRec)

Example 54 with LogRec

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

the class StateMachineTest method testStateMachineQuitNow.

@SmallTest
public void testStateMachineQuitNow() throws Exception {
    if (WAIT_FOR_DEBUGGER)
        Debug.waitForDebugger();
    StateMachineQuitNowTest smQuitNowTest = new StateMachineQuitNowTest("smQuitNowTest");
    smQuitNowTest.start();
    if (smQuitNowTest.isDbg())
        tlog("testStateMachineQuitNow E");
    synchronized (smQuitNowTest) {
        // we send 6 only one will be processed.
        for (int i = 1; i <= 6; i++) {
            smQuitNowTest.sendMessage(smQuitNowTest.obtainMessage(i));
        }
        try {
            // wait for the messages to be handled
            smQuitNowTest.wait();
        } catch (InterruptedException e) {
            tloge("testStateMachineQuitNow: exception while waiting " + e.getMessage());
        }
    }
    tlog("testStateMachineQuiteNow: logRecs=" + smQuitNowTest.mLogRecs);
    assertEquals(3, smQuitNowTest.mLogRecs.size());
    Iterator<LogRec> itr = smQuitNowTest.mLogRecs.iterator();
    LogRec lr = itr.next();
    assertEquals(1, lr.getWhat());
    assertEquals(smQuitNowTest.mS1, lr.getState());
    assertEquals(smQuitNowTest.mS1, lr.getOriginalState());
    lr = itr.next();
    assertEquals(EXIT, lr.getInfo());
    assertEquals(smQuitNowTest.mS1, lr.getState());
    lr = itr.next();
    assertEquals(ON_QUITTING, lr.getInfo());
    if (smQuitNowTest.isDbg())
        tlog("testStateMachineQuitNow X");
}
Also used : LogRec(com.android.internal.util.StateMachine.LogRec) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 55 with LogRec

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

the class StateMachineTest method testStateMachine5.

@MediumTest
public void testStateMachine5() throws Exception {
    StateMachine5 sm5 = new StateMachine5("sm5");
    sm5.start();
    if (sm5.isDbg())
        tlog("testStateMachine5 E");
    synchronized (sm5) {
        // Send 6 messages
        sm5.sendMessage(TEST_CMD_1);
        sm5.sendMessage(TEST_CMD_2);
        sm5.sendMessage(TEST_CMD_3);
        sm5.sendMessage(TEST_CMD_4);
        sm5.sendMessage(TEST_CMD_5);
        sm5.sendMessage(TEST_CMD_6);
        try {
            // wait for the messages to be handled
            sm5.wait();
        } catch (InterruptedException e) {
            tloge("testStateMachine5: exception while waiting " + e.getMessage());
        }
    }
    assertEquals(6, sm5.getLogRecSize());
    assertEquals(1, sm5.mParentState1EnterCount);
    assertEquals(1, sm5.mParentState1ExitCount);
    assertEquals(1, sm5.mChildState1EnterCount);
    assertEquals(1, sm5.mChildState1ExitCount);
    assertEquals(1, sm5.mChildState2EnterCount);
    assertEquals(1, sm5.mChildState2ExitCount);
    assertEquals(2, sm5.mParentState2EnterCount);
    assertEquals(2, sm5.mParentState2ExitCount);
    assertEquals(1, sm5.mChildState3EnterCount);
    assertEquals(1, sm5.mChildState3ExitCount);
    assertEquals(2, sm5.mChildState4EnterCount);
    assertEquals(2, sm5.mChildState4ExitCount);
    assertEquals(1, sm5.mChildState5EnterCount);
    assertEquals(1, sm5.mChildState5ExitCount);
    LogRec lr;
    lr = sm5.getLogRec(0);
    assertEquals(TEST_CMD_1, lr.getWhat());
    assertEquals(sm5.mChildState1, lr.getState());
    assertEquals(sm5.mChildState1, lr.getOriginalState());
    lr = sm5.getLogRec(1);
    assertEquals(TEST_CMD_2, lr.getWhat());
    assertEquals(sm5.mChildState2, lr.getState());
    assertEquals(sm5.mChildState2, lr.getOriginalState());
    lr = sm5.getLogRec(2);
    assertEquals(TEST_CMD_3, lr.getWhat());
    assertEquals(sm5.mChildState5, lr.getState());
    assertEquals(sm5.mChildState5, lr.getOriginalState());
    lr = sm5.getLogRec(3);
    assertEquals(TEST_CMD_4, lr.getWhat());
    assertEquals(sm5.mChildState3, lr.getState());
    assertEquals(sm5.mChildState3, lr.getOriginalState());
    lr = sm5.getLogRec(4);
    assertEquals(TEST_CMD_5, lr.getWhat());
    assertEquals(sm5.mChildState4, lr.getState());
    assertEquals(sm5.mChildState4, lr.getOriginalState());
    lr = sm5.getLogRec(5);
    assertEquals(TEST_CMD_6, lr.getWhat());
    assertEquals(sm5.mParentState2, lr.getState());
    assertEquals(sm5.mParentState2, lr.getOriginalState());
    if (sm5.isDbg())
        tlog("testStateMachine5 X");
}
Also used : LogRec(com.android.internal.util.StateMachine.LogRec) MediumTest(android.test.suitebuilder.annotation.MediumTest)

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