diff options
Diffstat (limited to 'ui-desktop/src/test/java/market/guess/ui/desktop/AnimTest.java')
| -rw-r--r-- | ui-desktop/src/test/java/market/guess/ui/desktop/AnimTest.java | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/ui-desktop/src/test/java/market/guess/ui/desktop/AnimTest.java b/ui-desktop/src/test/java/market/guess/ui/desktop/AnimTest.java new file mode 100644 index 0000000..1a39ba1 --- /dev/null +++ b/ui-desktop/src/test/java/market/guess/ui/desktop/AnimTest.java | |||
| @@ -0,0 +1,70 @@ | |||
| 1 | package market.guess.ui.desktop; | ||
| 2 | |||
| 3 | import static org.junit.jupiter.api.Assertions.assertEquals; | ||
| 4 | |||
| 5 | import market.guess.ui.desktop.components.graphic.GraphicHelper; | ||
| 6 | import market.guess.ui.desktop.components.graphic.MarketChartGraphic; | ||
| 7 | import market.guess.ui.desktop.components.graphic.Motion; | ||
| 8 | import market.guess.ui.desktop.components.graphic.SparklineGraphic; | ||
| 9 | import org.junit.jupiter.api.Test; | ||
| 10 | |||
| 11 | /** | ||
| 12 | * The handoff requires "animations off" to show the frozen final frame, fully legible and never | ||
| 13 | * blank. Since every graphic renders as a function of progress, that contract is exactly: at | ||
| 14 | * progress 1, every driver lands on its designed end value. | ||
| 15 | */ | ||
| 16 | class AnimTest { | ||
| 17 | private static final double[] BAR1 = {0, .35, .30, 1, .60, .6, 1, .35}; | ||
| 18 | |||
| 19 | @Test | ||
| 20 | void keyframesHoldTheirEndValue() { | ||
| 21 | assertEquals(.35, GraphicHelper.at(0, BAR1), 1e-9); | ||
| 22 | assertEquals(1.0, GraphicHelper.at(.30, BAR1), 1e-9); | ||
| 23 | assertEquals(.35, GraphicHelper.at(1, BAR1), 1e-9); | ||
| 24 | assertEquals(.675, GraphicHelper.at(.15, BAR1), 1e-9); // interpolates linearly between stops | ||
| 25 | assertEquals(.35, Motion.at(0, BAR1), 1e-9); | ||
| 26 | } | ||
| 27 | |||
| 28 | @Test | ||
| 29 | void ridersEndOnTheLastPointOfTheirPath() { | ||
| 30 | assertEquals( | ||
| 31 | MarketChartGraphic.YES_CURVE[6], | ||
| 32 | MarketChartGraphic.rideCurve(MarketChartGraphic.YES_CURVE, 1)[0], | ||
| 33 | 1e-6); | ||
| 34 | assertEquals( | ||
| 35 | MarketChartGraphic.YES_CURVE[7], | ||
| 36 | MarketChartGraphic.rideCurve(MarketChartGraphic.YES_CURVE, 1)[1], | ||
| 37 | 1e-6); | ||
| 38 | |||
| 39 | int last = SparklineGraphic.SPARK.length; | ||
| 40 | assertEquals( | ||
| 41 | SparklineGraphic.SPARK[last - 2], | ||
| 42 | SparklineGraphic.ridePolyline(SparklineGraphic.SPARK, 1)[0], | ||
| 43 | 1e-6); | ||
| 44 | assertEquals( | ||
| 45 | SparklineGraphic.SPARK[last - 1], | ||
| 46 | SparklineGraphic.ridePolyline(SparklineGraphic.SPARK, 1)[1], | ||
| 47 | 1e-6); | ||
| 48 | } | ||
| 49 | |||
| 50 | @Test | ||
| 51 | void ridersStartOnTheFirstPointOfTheirPath() { | ||
| 52 | assertEquals( | ||
| 53 | MarketChartGraphic.YES_CURVE[0], | ||
| 54 | MarketChartGraphic.rideCurve(MarketChartGraphic.YES_CURVE, 0)[0], | ||
| 55 | 1e-6); | ||
| 56 | assertEquals( | ||
| 57 | MarketChartGraphic.YES_CURVE[1], | ||
| 58 | MarketChartGraphic.rideCurve(MarketChartGraphic.YES_CURVE, 0)[1], | ||
| 59 | 1e-6); | ||
| 60 | |||
| 61 | assertEquals( | ||
| 62 | SparklineGraphic.SPARK[0], | ||
| 63 | SparklineGraphic.ridePolyline(SparklineGraphic.SPARK, 0)[0], | ||
| 64 | 1e-6); | ||
| 65 | assertEquals( | ||
| 66 | SparklineGraphic.SPARK[1], | ||
| 67 | SparklineGraphic.ridePolyline(SparklineGraphic.SPARK, 0)[1], | ||
| 68 | 1e-6); | ||
| 69 | } | ||
| 70 | } | ||