blob: e617c2e5d3aa29d2b1273436dd4b9a67e25ef866 [file] [log] [blame]
package com.airbnb.lottie;
import android.graphics.Rect;
import android.support.v4.util.LongSparseArray;
import android.support.v4.util.SparseArrayCompat;
import com.airbnb.lottie.model.Font;
import com.airbnb.lottie.model.FontCharacter;
import com.airbnb.lottie.model.Marker;
import com.airbnb.lottie.model.layer.Layer;
import org.junit.Test;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import static junit.framework.Assert.assertEquals;
public class LottieDrawableTest extends BaseTest {
@SuppressWarnings("SameParameterValue")
private LottieComposition createComposition(int startFrame, int endFrame) {
LottieComposition composition = new LottieComposition();
composition.init(new Rect(), startFrame, endFrame, 1000, new ArrayList<Layer>(),
new LongSparseArray<Layer>(0), new HashMap<String, List<Layer>>(0),
new HashMap<String, LottieImageAsset>(0), new SparseArrayCompat<FontCharacter>(0),
new HashMap<String, Font>(0), new ArrayList<Marker>());
return composition;
}
@Test
public void testMinFrame() {
LottieComposition composition = createComposition(31, 391);
LottieDrawable drawable = new LottieDrawable();
drawable.setComposition(composition);
drawable.setMinProgress(0.42f);
assertEquals(182f, drawable.getMinFrame());
}
@Test
public void testMinWithStartFrameFrame() {
LottieComposition composition = createComposition(100, 200);
LottieDrawable drawable = new LottieDrawable();
drawable.setComposition(composition);
drawable.setMinProgress(0.5f);
assertEquals(150f, drawable.getMinFrame());
}
@Test
public void testMaxFrame() {
LottieComposition composition = createComposition(31, 391);
LottieDrawable drawable = new LottieDrawable();
drawable.setComposition(composition);
drawable.setMaxProgress(0.25f);
assertEquals(121.99f, drawable.getMaxFrame());
}
@Test
public void testMinMaxFrame() {
LottieComposition composition = createComposition(31, 391);
LottieDrawable drawable = new LottieDrawable();
drawable.setComposition(composition);
drawable.setMinAndMaxProgress(0.25f, 0.42f);
assertEquals(121f, drawable.getMinFrame());
assertEquals(182.99f, drawable.getMaxFrame());
}
}