FileDocCategorySizeDatePackage
TestHandlerThread.javaAPI DocAndroid 5.1 API2675Thu Mar 12 22:22:12 GMT 2015android.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();
        }