use of com.facebook.imagepipeline.animated.testing.TestAnimatedDrawableBackend in project fresco by facebook.
the class AnimatedDrawableCachingBackendImplTest method setup.
@Before
public void setup() {
mActivityManager = (ActivityManager) RuntimeEnvironment.application.getSystemService(Context.ACTIVITY_SERVICE);
mFakeClock = new FakeClock();
mExecutorService = new TestExecutorService(mFakeClock);
mAnimatedDrawableUtil = new AnimatedDrawableUtil();
mDrawableBackend = new TestAnimatedDrawableBackend(WIDTH, HEIGHT, FRAME_DURATIONS);
}
use of com.facebook.imagepipeline.animated.testing.TestAnimatedDrawableBackend in project fresco by facebook.
the class AnimatedDrawableTest method setup.
@Before
public void setup() {
mFakeClock = new FakeClock();
mTestScheduledExecutorService = new TestScheduledExecutorService(mFakeClock);
mBackend = new TestAnimatedDrawableBackend(WIDTH, HEIGHT, FRAME_DURATIONS);
mCachingBackend = new TestAnimatedDrawableCachingBackend(mBackend);
mCallback = new MyCallback(mFakeClock);
mDrawable = new AnimatedDrawable(mTestScheduledExecutorService, mCachingBackend, AnimatedDrawableDiagnosticsNoop.getInstance(), mFakeClock);
mDrawable.setCallback(mCallback);
}
use of com.facebook.imagepipeline.animated.testing.TestAnimatedDrawableBackend in project fresco by facebook.
the class AnimatedDrawableTest method testDoNotDropCacheIfFramesAreLongDurationSpecialCase.
@Test
public void testDoNotDropCacheIfFramesAreLongDurationSpecialCase() {
mBackend = new TestAnimatedDrawableBackend(WIDTH, HEIGHT, FRAME_DURATIONS_LONG);
mCachingBackend = new TestAnimatedDrawableCachingBackend(mBackend);
mCallback = new MyCallback(mFakeClock);
mDrawable = new AnimatedDrawable(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());
}
Aggregations