aboutsummaryrefslogtreecommitdiffstats
path: root/ui-desktop/src/test/java/market/guess/ui/desktop/AnimTest.java
diff options
context:
space:
mode:
authorKostya <mail@sartin.in>2026-09-10 11:55:50 +0300
committerKostya <mail@sartin.in>2026-09-10 11:55:50 +0300
commit1a8b75f96f0c6855581be3a38069f09eca37d1f5 (patch)
treede174d70987afa21fd0588c551c111e028ff020f /ui-desktop/src/test/java/market/guess/ui/desktop/AnimTest.java
parentf23c20c1c66b39fb1f49307e08e8593fa708e026 (diff)
downloadguess-market-master.tar.gz
guess-market-master.tar.xz
guess-market-master.zip
tests: cover the ex-2 loader, order book trading and desktop stateHEAD2.0master
Add tests for the behaviour introduced in the last few commits, so later changes to matching, settlement or the UI state can't quietly break it. On the service side, Ex2LoaderTest loads the ex-2 fixtures and checks that every invalid file is rejected for its own reason, including events with no market maker or two of them, and v1 files. The order book tests cover buys and sells that match or rest in the ladder, self-trade prevention, cash and shares reserved by resting orders, price bounds, risk rejections, and resolution cancelling resting orders and paying the holders. A simulation checks that LMSR settlement conserves money. LedgerMapperTest used to pin the unmapped seq and at fields to their defaults. Now that the mapper fills them from the entry id and time, assert the real values and add a case for a null time. On the desktop side, AppStateTest drives the real ServiceEngine through loading, event creation, LMSR and order book trading, and checks that the observable state updates. Smaller tests check chart timestamps, money and probability formatting, and that every animation settles on its final frame, which is what the UI shows when animations are off.
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.java70
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 @@
1package market.guess.ui.desktop;
2
3import static org.junit.jupiter.api.Assertions.assertEquals;
4
5import market.guess.ui.desktop.components.graphic.GraphicHelper;
6import market.guess.ui.desktop.components.graphic.MarketChartGraphic;
7import market.guess.ui.desktop.components.graphic.Motion;
8import market.guess.ui.desktop.components.graphic.SparklineGraphic;
9import 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 */
16class 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}