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

TestHandlerThread

public abstract class TestHandlerThread extends Object

Fields Summary
private boolean
mDone
private boolean
mSuccess
private RuntimeException
mFailure
private android.os.Looper
mLooper
Constructors Summary
public TestHandlerThread()

    
       

      
    
Methods Summary
public voiddoTest(long timeout)

        (new LooperThread()).start();

        synchronized (this) {
            long now = System.currentTimeMillis();
            long endTime = now + timeout;
            while (!mDone && now < endTime) {
                try {
                    wait(endTime-now);
                }
                catch (InterruptedException e) {
                }
                now = System.currentTimeMillis();
            }
        }

        mLooper.quit();

        if (!mDone) {
            throw new RuntimeException("test timed out");
        }
        if (!mSuccess) {
            throw mFailure;
        }
    
public voidfailure(java.lang.RuntimeException failure)

        synchronized (this) {
            mSuccess = false;
            mFailure = failure;
            quit();
        }
    
public android.os.LoopergetLooper()

        return mLooper;
    
public abstract voidgo()

private voidquit()

        synchronized (this) {
            mDone = true;
            notifyAll();
        }
    
public voidsuccess()

        synchronized (this) {
            mSuccess = true;
            quit();
        }