Search in sources :

Example 66 with LogRec

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

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

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

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

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

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

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

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

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

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)

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