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);
}
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);
}
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);
}
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);
}
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"));
}
Aggregations