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