FileDocCategorySizeDatePackage
HandlerStateMachineTest.javaAPI DocAndroid 1.5 API3985Wed May 06 22:42:02 BST 2009com.android.unit_tests.os

HandlerStateMachineTest

public class HandlerStateMachineTest extends TestCase

Fields Summary
private static final int
TEST_WHAT_1
private static final int
TEST_WHAT_2
private static final boolean
DBG
private static final String
TAG
private boolean
mDidEnter
private boolean
mDidExit
private Vector
mGotMessagesWhat
Constructors Summary
Methods Summary
public voidtestStateMachine1()

    

    
         
        StateMachine1 sm1 = new StateMachine1("sm1");
        if (sm1.isDbg()) Log.d(TAG, "testStateMachine1 E");

        synchronized (sm1) {
            // Send two messages
            sm1.sendMessage(sm1.obtainMessage(TEST_WHAT_1));
            sm1.sendMessage(sm1.obtainMessage(TEST_WHAT_2));

            try {
                // wait for the messages to be handled
                sm1.wait();
            } catch (InterruptedException e) {
                Log.e(TAG, "testStateMachine1: exception while waiting " + e.getMessage());
            }
        }

        assertTrue(mDidEnter);
        assertTrue(mDidExit);
        assertTrue(mGotMessagesWhat.size() == 2);
        assertTrue(mGotMessagesWhat.get(0) == TEST_WHAT_1);
        assertTrue(mGotMessagesWhat.get(1) == TEST_WHAT_2);
        if (sm1.isDbg()) Log.d(TAG, "testStateMachine1 X");