Search in sources :

Example 76 with LogRec

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

the class StateMachineTest method testStateMachineEnterExitTransitionToTest.

@SmallTest
public void testStateMachineEnterExitTransitionToTest() throws Exception {
    //if (WAIT_FOR_DEBUGGER) Debug.waitForDebugger();
    StateMachineEnterExitTransitionToTest smEnterExitTranstionToTest = new StateMachineEnterExitTransitionToTest("smEnterExitTranstionToTest");
    smEnterExitTranstionToTest.start();
    if (smEnterExitTranstionToTest.isDbg()) {
        tlog("testStateMachineEnterExitTransitionToTest E");
    }
    synchronized (smEnterExitTranstionToTest) {
        smEnterExitTranstionToTest.sendMessage(TEST_CMD_1);
        try {
            // wait for the messages to be handled
            smEnterExitTranstionToTest.wait();
        } catch (InterruptedException e) {
            tloge("testStateMachineEnterExitTransitionToTest: exception while waiting " + e.getMessage());
        }
    }
    dumpLogRecs(smEnterExitTranstionToTest);
    assertEquals(9, smEnterExitTranstionToTest.getLogRecCount());
    LogRec lr;
    lr = smEnterExitTranstionToTest.getLogRec(0);
    assertEquals(ENTER, lr.getInfo());
    assertEquals(smEnterExitTranstionToTest.mS1, lr.getState());
    lr = smEnterExitTranstionToTest.getLogRec(1);
    assertEquals(EXIT, lr.getInfo());
    assertEquals(smEnterExitTranstionToTest.mS1, lr.getState());
    lr = smEnterExitTranstionToTest.getLogRec(2);
    assertEquals(ENTER, lr.getInfo());
    assertEquals(smEnterExitTranstionToTest.mS2, lr.getState());
    lr = smEnterExitTranstionToTest.getLogRec(3);
    assertEquals(TEST_CMD_1, lr.getWhat());
    assertEquals(smEnterExitTranstionToTest.mS2, lr.getState());
    assertEquals(smEnterExitTranstionToTest.mS2, lr.getOriginalState());
    assertEquals(smEnterExitTranstionToTest.mS3, lr.getDestState());
    lr = smEnterExitTranstionToTest.getLogRec(4);
    assertEquals(TEST_CMD_1, lr.getWhat());
    assertEquals(smEnterExitTranstionToTest.mS2, lr.getState());
    assertEquals(smEnterExitTranstionToTest.mS2, lr.getOriginalState());
    assertEquals(smEnterExitTranstionToTest.mS4, lr.getDestState());
    assertEquals(EXIT, lr.getInfo());
    lr = smEnterExitTranstionToTest.getLogRec(5);
    assertEquals(TEST_CMD_1, lr.getWhat());
    assertEquals(ENTER, lr.getInfo());
    assertEquals(smEnterExitTranstionToTest.mS3, lr.getState());
    assertEquals(smEnterExitTranstionToTest.mS3, lr.getOriginalState());
    assertEquals(smEnterExitTranstionToTest.mS4, lr.getDestState());
    lr = smEnterExitTranstionToTest.getLogRec(6);
    assertEquals(TEST_CMD_1, lr.getWhat());
    assertEquals(EXIT, lr.getInfo());
    assertEquals(smEnterExitTranstionToTest.mS3, lr.getState());
    assertEquals(smEnterExitTranstionToTest.mS3, lr.getOriginalState());
    assertEquals(smEnterExitTranstionToTest.mS4, lr.getDestState());
    lr = smEnterExitTranstionToTest.getLogRec(7);
    assertEquals(TEST_CMD_1, lr.getWhat());
    assertEquals(ENTER, lr.getInfo());
    assertEquals(smEnterExitTranstionToTest.mS4, lr.getState());
    assertEquals(smEnterExitTranstionToTest.mS4, lr.getOriginalState());
    assertEquals(smEnterExitTranstionToTest.mS4, lr.getDestState());
    lr = smEnterExitTranstionToTest.getLogRec(8);
    assertEquals(TEST_CMD_1, lr.getWhat());
    assertEquals(EXIT, lr.getInfo());
    assertEquals(smEnterExitTranstionToTest.mS4, lr.getState());
    assertEquals(smEnterExitTranstionToTest.mS4, lr.getOriginalState());
    if (smEnterExitTranstionToTest.isDbg()) {
        tlog("testStateMachineEnterExitTransitionToTest X");
    }
}
Also used : LogRec(com.android.internal.util.StateMachine.LogRec) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 77 with LogRec

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

the class StateMachineTest method dumpLogRecs.

private void dumpLogRecs(Collection<LogRec> clr) {
    int size = clr.size();
    tlog("size=" + size);
    for (LogRec lr : clr) {
        tlog(lr.toString());
    }
}
Also used : LogRec(com.android.internal.util.StateMachine.LogRec)

Example 78 with LogRec

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

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