forked from airbnb/lottie-android
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GradientColorKeyframeAnimation does not handle progress outside [0,1] (…
…airbnb#2427) - Closes airbnb#2426 - Improve performance by running GammaEvaluator once Co-authored-by: Sven Obser <[email protected]>
- Loading branch information
Showing
5 changed files
with
100 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
lottie/src/test/java/com/airbnb/lottie/model/content/GradientColorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.airbnb.lottie.model.content; | ||
|
||
import junit.framework.TestCase; | ||
import org.junit.Test; | ||
|
||
import java.util.Arrays; | ||
|
||
public class GradientColorTest extends TestCase { | ||
|
||
private final GradientColor start = new GradientColor(new float[]{0f, 1f}, new int[]{0xFF000000, 0xFF020202}); | ||
|
||
private final GradientColor end = new GradientColor(new float[]{0f, 1f}, new int[]{0xFF020202, 0xFF040404}); | ||
|
||
private final GradientColor gradient = new GradientColor(new float[2], new int[2]); | ||
|
||
@Test | ||
public void testLerpWithOutOfBoundsNegativeProgress() { | ||
gradient.lerp(start, end, -42f); | ||
assertEquals(start, gradient); | ||
} | ||
|
||
@Test | ||
public void testLerpWithZeroProgress() { | ||
gradient.lerp(start, end, 0f); | ||
assertEquals(start, gradient); | ||
} | ||
|
||
@Test | ||
public void testLerpWithHalfProgress() { | ||
gradient.lerp(start, end, 0.5f); | ||
GradientColor half = new GradientColor(new float[]{0f, 1f}, new int[]{0xFF010101, 0xFF030303}); | ||
assertEquals(half, gradient); | ||
} | ||
|
||
@Test | ||
public void testLerpWithOneProgress() { | ||
gradient.lerp(start, end, 1f); | ||
assertEquals(end, gradient); | ||
} | ||
|
||
@Test | ||
public void testLerpWithOutOfBoundsPositiveProgress() { | ||
gradient.lerp(start, end, 42f); | ||
assertEquals(end, gradient); | ||
} | ||
} |
Binary file added
BIN
+1.48 KB
snapshot-tests/src/main/assets/Tests/GradientColorKeyframeAnimation.zip
Binary file not shown.