public void testReverseTransition() { MockCallBack cb = new MockCallBack(); mTransitionDrawable.setCallback(cb); // reverse when there is no transition cb.reset(); mTransitionDrawable.reverseTransition(2000); assertTrue(cb.hasCalledInvalidateDrawable()); assertTransition(COLOR0, COLOR1, 2000); // reverse after the other transition ends cb.reset(); mTransitionDrawable.reverseTransition(2000); assertTrue(cb.hasCalledInvalidateDrawable()); assertTransition(COLOR1, COLOR0, 2000); // reverse when there is a transition in progress makeTransitionInProgress(2000, 1000); cb.reset(); mTransitionDrawable.reverseTransition(20000); assertFalse(cb.hasCalledInvalidateDrawable()); int colorFrom = mBitmap.getPixel(0, 0); assertTransition(colorFrom, COLOR0, 1500); // reverse when there is a reverse transition in progress makeReverseTransitionInProgress(2000, 1000); cb.reset(); mTransitionDrawable.reverseTransition(20000); assertFalse(cb.hasCalledInvalidateDrawable()); colorFrom = mBitmap.getPixel(0, 0); assertTransition(colorFrom, COLOR1, 1500); // should not accept negative duration mTransitionDrawable.reverseTransition(-1); }
public void testResetTransition() { MockCallBack cb = new MockCallBack(); mTransitionDrawable.setCallback(cb); // reset when there is no transition cb.reset(); mTransitionDrawable.resetTransition(); assertTrue(cb.hasCalledInvalidateDrawable()); // reset when there is a transition in progress makeTransitionInProgress(2000, 1000); cb.reset(); mTransitionDrawable.resetTransition(); assertTrue(cb.hasCalledInvalidateDrawable()); assertTransitionStart(COLOR0); assertTransitionEnd(COLOR0, 2000); // reset when there is a reverse transition in progress makeReverseTransitionInProgress(2000, 1000); cb.reset(); mTransitionDrawable.resetTransition(); assertTrue(cb.hasCalledInvalidateDrawable()); assertTransitionStart(COLOR0); assertTransitionEnd(COLOR0, 2000); }
public void testStartTransition() { MockCallBack cb = new MockCallBack(); mTransitionDrawable.setCallback(cb); // start when there is no transition cb.reset(); mTransitionDrawable.startTransition(2000); assertTrue(cb.hasCalledInvalidateDrawable()); assertTransition(COLOR0, COLOR1, 2000); // start when there is a transition in progress makeTransitionInProgress(2000, 1000); cb.reset(); mTransitionDrawable.startTransition(2000); assertTrue(cb.hasCalledInvalidateDrawable()); assertTransition(COLOR0, COLOR1, 2000); // start when there is a reverse transition in progress makeReverseTransitionInProgress(2000, 1000); cb.reset(); mTransitionDrawable.startTransition(2000); assertTrue(cb.hasCalledInvalidateDrawable()); assertTransition(COLOR0, COLOR1, 2000); // should not accept negative duration mTransitionDrawable.startTransition(-1); }