use of com.facebook.imagepipeline.animated.testing.TestAnimatedDrawableSupportBackend in project fresco by facebook.
the class AnimatedDrawableSupportTest method testDoNotDropCacheIfFramesAreLongDurationSpecialCase.
@Test
public void testDoNotDropCacheIfFramesAreLongDurationSpecialCase() {
mBackend = new TestAnimatedDrawableSupportBackend(WIDTH, HEIGHT, FRAME_DURATIONS_LONG);
mCachingBackend = new TestAnimatedDrawableCachingBackend(mBackend);
mCallback = new MyCallback(mFakeClock);
mDrawable = new AnimatedDrawableSupport(mTestScheduledExecutorService, mCachingBackend, AnimatedDrawableDiagnosticsNoop.getInstance(), mFakeClock);
mDrawable.setCallback(mCallback);
Bitmap bitmap = Bitmap.createBitmap(WIDTH, HEIGHT, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
prepareDrawable();
// Draw and advance to next frame.
mDrawable.draw(canvas);
// After 10 seconds, it should move to the next frame. It shouldn't drop the caches though
// until it's 2 seconds after the invalidate.
assertFalse(mDrawable.isWaitingForDraw());
assertTrue(mDrawable.isWaitingForNextFrame());
assertEquals(0, mDrawable.getScheduledFrameNumber());
mFakeClock.incrementBy(10000);
assertTrue(mDrawable.isWaitingForDraw());
assertFalse(mDrawable.isWaitingForNextFrame());
assertEquals(1, mDrawable.getScheduledFrameNumber());
assertEquals(1, mBackend.getDropCachesCallCount());
mFakeClock.incrementBy(1000);
assertEquals(1, mBackend.getDropCachesCallCount());
mFakeClock.incrementBy(2000);
assertEquals(2, mBackend.getDropCachesCallCount());
}
use of com.facebook.imagepipeline.animated.testing.TestAnimatedDrawableSupportBackend in project fresco by facebook.
the class AnimatedDrawableSupportTest method setup.
@Before
public void setup() {
mFakeClock = new FakeClock();
mTestScheduledExecutorService = new TestScheduledExecutorService(mFakeClock);
mBackend = new TestAnimatedDrawableSupportBackend(WIDTH, HEIGHT, FRAME_DURATIONS);
mCachingBackend = new TestAnimatedDrawableCachingBackend(mBackend);
mCallback = new MyCallback(mFakeClock);
mDrawable = new AnimatedDrawableSupport(mTestScheduledExecutorService, mCachingBackend, AnimatedDrawableDiagnosticsNoop.getInstance(), mFakeClock);
mDrawable.setCallback(mCallback);
}
Aggregations