Search in sources :

Example 56 with LogRec

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

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 57 with LogRec

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

the class StateMachineTest method testStateMachine3.

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

Example 58 with LogRec

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

the class StateMachineTest method testStateMachine2.

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

Example 59 with LogRec

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

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 60 with LogRec

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

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)

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