Search in sources :

Example 41 with Handler

use of android.os.Handler in project platform_frameworks_base by android.

the class EventsTest method testPlayingDelayedEnd.

/**
     * Same as testPlayingEnd, but with a startDelayed animator
     */
@MediumTest
public void testPlayingDelayedEnd() throws Exception {
    mAnimator.setStartDelay(ANIM_DELAY);
    mFutureListener = new FutureReleaseListener(mFuture);
    getActivity().runOnUiThread(new Runnable() {

        @Override
        public void run() {
            try {
                Handler handler = new Handler();
                mAnimator.addListener(mFutureListener);
                mRunning = true;
                mAnimator.start();
                handler.postDelayed(new Ender(mAnimator, mFuture), ANIM_MID_DURATION);
            } catch (junit.framework.AssertionFailedError e) {
                mFuture.setException(new RuntimeException(e));
            }
        }
    });
    mFuture.get(getTimeout(), TimeUnit.MILLISECONDS);
}
Also used : Handler(android.os.Handler) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 42 with Handler

use of android.os.Handler in project platform_frameworks_base by android.

the class EventsTest method testPlayingDelayedCancel.

/**
     * Same as testPlayingCancel, but with a startDelayed animator
     */
@MediumTest
public void testPlayingDelayedCancel() throws Exception {
    mAnimator.setStartDelay(ANIM_DELAY);
    mFutureListener = new FutureReleaseListener(mFuture);
    getActivity().runOnUiThread(new Runnable() {

        @Override
        public void run() {
            try {
                Handler handler = new Handler();
                mAnimator.addListener(mFutureListener);
                mRunning = true;
                mAnimator.start();
                handler.postDelayed(new Canceler(mAnimator, mFuture), ANIM_MID_DURATION);
            } catch (junit.framework.AssertionFailedError e) {
                mFuture.setException(new RuntimeException(e));
            }
        }
    });
    mFuture.get(getTimeout(), TimeUnit.MILLISECONDS);
}
Also used : Handler(android.os.Handler) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 43 with Handler

use of android.os.Handler in project platform_frameworks_base by android.

the class EventsTest method testPlayingEnd.

/**
     * Verify that ending an animator that is playing does the right thing.
     */
@MediumTest
public void testPlayingEnd() throws Exception {
    mFutureListener = new FutureReleaseListener(mFuture);
    getActivity().runOnUiThread(new Runnable() {

        @Override
        public void run() {
            try {
                Handler handler = new Handler();
                mAnimator.addListener(mFutureListener);
                mRunning = true;
                mAnimator.start();
                handler.postDelayed(new Ender(mAnimator, mFuture), ANIM_MID_DURATION);
            } catch (junit.framework.AssertionFailedError e) {
                mFuture.setException(new RuntimeException(e));
            }
        }
    });
    mFuture.get(getTimeout(), TimeUnit.MILLISECONDS);
}
Also used : Handler(android.os.Handler) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 44 with Handler

use of android.os.Handler in project platform_frameworks_base by android.

the class EventsTest method testPlayingDelayedCancelMidDelay.

/**
     * Same as testPlayingDelayedCancel, but cancel during the startDelay period
     */
@MediumTest
public void testPlayingDelayedCancelMidDelay() throws Exception {
    mAnimator.setStartDelay(ANIM_DELAY);
    getActivity().runOnUiThread(new Runnable() {

        @Override
        public void run() {
            try {
                // Set the listener to automatically timeout after an uncanceled animation
                // would have finished. This tests to make sure that we're not calling
                // the listeners with cancel/end callbacks since they won't be called
                // with the start event.
                mFutureListener = new FutureReleaseListener(mFuture, getTimeout());
                Handler handler = new Handler();
                mRunning = true;
                mAnimator.start();
                handler.postDelayed(new Canceler(mAnimator, mFuture), ANIM_MID_DELAY);
            } catch (junit.framework.AssertionFailedError e) {
                mFuture.setException(new RuntimeException(e));
            }
        }
    });
    mFuture.get(getTimeout() + 100, TimeUnit.MILLISECONDS);
}
Also used : Handler(android.os.Handler) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 45 with Handler

use of android.os.Handler in project platform_frameworks_base by android.

the class NetworkRecommendationProviderTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    // Configuration needed to make mockito/dexcache work.
    final Context context = getInstrumentation().getTargetContext();
    System.setProperty("dexmaker.dexcache", context.getCacheDir().getPath());
    ClassLoader newClassLoader = getInstrumentation().getClass().getClassLoader();
    Thread.currentThread().setContextClassLoader(newClassLoader);
    MockitoAnnotations.initMocks(this);
    HandlerThread thread = new HandlerThread("NetworkRecommendationProviderTest");
    thread.start();
    mRecRequestLatch = new CountDownLatch(1);
    mScoreRequestLatch = new CountDownLatch(1);
    mHandler = new Handler(thread.getLooper());
    mRecProvider = new NetworkRecProvider(mHandler, mRecRequestLatch, mScoreRequestLatch);
    mStub = INetworkRecommendationProvider.Stub.asInterface(mRecProvider.getBinder());
    mTestNetworkKeys = new NetworkKey[2];
    mTestNetworkKeys[0] = new NetworkKey(new WifiKey("\"ssid_01\"", "00:00:00:00:00:11"));
    mTestNetworkKeys[1] = new NetworkKey(new WifiKey("\"ssid_02\"", "00:00:00:00:00:22"));
}
Also used : Context(android.content.Context) HandlerThread(android.os.HandlerThread) Handler(android.os.Handler) CountDownLatch(java.util.concurrent.CountDownLatch)

Aggregations

Handler (android.os.Handler)1904 Message (android.os.Message)254 View (android.view.View)207 Intent (android.content.Intent)174 HandlerThread (android.os.HandlerThread)156 TextView (android.widget.TextView)118 MediumTest (android.test.suitebuilder.annotation.MediumTest)116 ArrayList (java.util.ArrayList)97 Test (org.junit.Test)85 Context (android.content.Context)71 IntentFilter (android.content.IntentFilter)69 RemoteException (android.os.RemoteException)63 IOException (java.io.IOException)63 ComponentName (android.content.ComponentName)57 ImageView (android.widget.ImageView)57 Bundle (android.os.Bundle)56 RecyclerView (android.support.v7.widget.RecyclerView)54 Looper (android.os.Looper)53 File (java.io.File)46 ContentObserver (android.database.ContentObserver)44