use of com.android.internal.util.StateMachine.LogRec in project android_frameworks_base by ParanoidAndroid.
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");
}
use of com.android.internal.util.StateMachine.LogRec in project platform_frameworks_base by android.
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");
}
use of com.android.internal.util.StateMachine.LogRec in project platform_frameworks_base by android.
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");
}
use of com.android.internal.util.StateMachine.LogRec in project platform_frameworks_base by android.
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");
}
use of com.android.internal.util.StateMachine.LogRec in project platform_frameworks_base by android.
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());
}
}
Aggregations