App 2.22.0: Overview style Cockpit, segmented rings and a power trace
A third Overview style beside Tiles and Dashboard: rings for battery, power (zero at the top, regeneration anticlockwise in green) with the speed and gear inside, and 5-minute usage with a tick for the average since start; below, the power of the last two minutes, the clock, climate and odometer. Unread values light nothing and show "—"; the trace leaves gaps (PowerTrace, unit-tested). Emulator only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LhzAVaUyqcw5PkGjz4mWW6
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
package com.evsuite.abrp;
|
||||
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/** The Cockpit's power trace buffer — pure JVM. */
|
||||
public class PowerTraceTest {
|
||||
|
||||
private static final float NaN = Float.NaN;
|
||||
|
||||
@Test
|
||||
public void emptyIsAllGaps() {
|
||||
float[] v = new PowerTrace(4000, 4).snapshot();
|
||||
assertEquals(4, v.length);
|
||||
for (float f : v) assertTrue(Float.isNaN(f));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void newestIsLastAndOlderSlide() {
|
||||
PowerTrace t = new PowerTrace(4000, 4); // 1 s slots
|
||||
t.add(10_000, 5f);
|
||||
t.add(11_000, 10f);
|
||||
t.add(12_000, -3f);
|
||||
assertArrayEquals(new float[] { NaN, 5f, 10f, -3f }, t.snapshot(), 0f);
|
||||
t.add(13_000, 1f);
|
||||
t.add(14_000, 2f);
|
||||
assertArrayEquals(new float[] { 10f, -3f, 1f, 2f }, t.snapshot(), 0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void unreadAndMissedSlotsAreGapsNotZero() {
|
||||
PowerTrace t = new PowerTrace(4000, 4);
|
||||
t.add(10_000, 5f);
|
||||
t.add(11_000, null);
|
||||
t.add(13_000, 7f); // nothing at 12 s
|
||||
assertArrayEquals(new float[] { 5f, NaN, NaN, 7f }, t.snapshot(), 0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aLongPauseClearsEverything() {
|
||||
PowerTrace t = new PowerTrace(4000, 4);
|
||||
t.add(10_000, 5f);
|
||||
t.add(11_000, 6f);
|
||||
t.add(60_000, 8f);
|
||||
assertArrayEquals(new float[] { NaN, NaN, NaN, 8f }, t.snapshot(), 0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void laterReadingInTheSameSlotWinsAndTheClockNeverRunsBack() {
|
||||
PowerTrace t = new PowerTrace(4000, 4);
|
||||
t.add(10_000, 5f);
|
||||
t.add(10_500, 6f);
|
||||
t.add(9_000, 99f);
|
||||
assertArrayEquals(new float[] { NaN, NaN, NaN, 6f }, t.snapshot(), 0f);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user