ScrollerCompatTestBasepublic abstract class ScrollerCompatTestBase extends android.test.AndroidTestCase
Fields Summary |
---|
private static final boolean | DEBUG | private final String | TAG | private final int | mApiLevel | private ScrollerCompat | mScroller |
Constructors Summary |
---|
public ScrollerCompatTestBase(int apiLevel)
mApiLevel = apiLevel;
TAG = "ScrollerCompatTest api:" + apiLevel;
|
Methods Summary |
---|
protected void | createScroller(android.view.animation.Interpolator interpolator)
Constructor<ScrollerCompat> constructor = ScrollerCompat.class
.getDeclaredConstructor(int.class, Context.class, Interpolator.class);
constructor.setAccessible(true);
mScroller = constructor.newInstance(mApiLevel, getContext(), interpolator);
| public void | testAbort()
if (DEBUG) {
Log.d(TAG, "testing abort");
}
createScroller(null);
mScroller.fling(0, 0, 0, 10000,
Integer.MIN_VALUE, Integer.MAX_VALUE, Integer.MIN_VALUE, Integer.MAX_VALUE);
assertTrue("Scroller should have some offset", mScroller.computeScrollOffset());
mScroller.abortAnimation();
assertFalse("Scroller should clear offset after being aborted",
mScroller.computeScrollOffset());
| public void | testTargetReached()
if (DEBUG) {
Log.d(TAG, "testing if target is reached");
}
createScroller(null);
mScroller.fling(0, 0, 0, 1000,
Integer.MIN_VALUE, Integer.MAX_VALUE, Integer.MIN_VALUE, Integer.MAX_VALUE);
int target = mScroller.getFinalY();
while (mScroller.computeScrollOffset()) {
Thread.sleep(100);
}
assertEquals("given enough time, scroller should reach target position", target,
mScroller.getCurrY());
|
|