- Charging: arrival briefing + geofence + automation rules - Audio: adaptive leveling manager + raw samples activity + speed audio curve - Display: brightness schedule + scheduler + widgets panel overlay - Trips: charts, database, tracking service, map activity - Theming: config store, theme editor, UI theme expansion - UX: control panel overlay + soundboard + settings overhaul - Tests: AdaptiveAudioCurveTest, BrightnessScheduleTest - Manifest: new permissions and queries for added features - README + THIRD_PARTY_NOTICES refreshed
58 lines
2.8 KiB
Java
58 lines
2.8 KiB
Java
import cloud.molberg.mgutility.AdaptiveAudioCurve;
|
|
|
|
public final class AdaptiveAudioCurveTest {
|
|
private static void check(boolean condition, String message) {
|
|
if (!condition) throw new AssertionError(message);
|
|
}
|
|
|
|
private static void close(float actual, float expected, String message) {
|
|
if (Math.abs(actual - expected) > 0.001f) {
|
|
throw new AssertionError(message + ": expected " + expected + ", got " + actual);
|
|
}
|
|
}
|
|
|
|
public static void main(String[] args) {
|
|
close(AdaptiveAudioCurve.multiplierPercent(0, 20, 90, 70, 100, 110, 110),
|
|
90, "below level 1");
|
|
close(AdaptiveAudioCurve.multiplierPercent(20, 20, 90, 70, 100, 110, 110),
|
|
90, "at level 1");
|
|
close(AdaptiveAudioCurve.multiplierPercent(45, 20, 90, 70, 100, 110, 110),
|
|
95, "between levels 1 and 2");
|
|
close(AdaptiveAudioCurve.multiplierPercent(70, 20, 90, 70, 100, 110, 110),
|
|
100, "at level 2");
|
|
close(AdaptiveAudioCurve.multiplierPercent(90, 20, 90, 70, 100, 110, 110),
|
|
105, "between levels 2 and 3");
|
|
close(AdaptiveAudioCurve.multiplierPercent(140, 20, 90, 70, 100, 110, 110),
|
|
110, "above level 3");
|
|
close(AdaptiveAudioCurve.multiplierPercent(300, 20, 90, 70, 100, 110, 110),
|
|
110, "level 3 is a hard plateau");
|
|
close(AdaptiveAudioCurve.multiplierPercent(Float.NaN, 20, 90, 70, 100, 110, 110),
|
|
90, "invalid speed is stationary");
|
|
|
|
check(AdaptiveAudioCurve.targetVolume(10, 0, 20, 90) == 9,
|
|
"90 percent scales the base volume");
|
|
check(AdaptiveAudioCurve.targetVolume(10, 0, 20, 110) == 11,
|
|
"110 percent scales the base volume");
|
|
check(AdaptiveAudioCurve.targetVolume(19, 0, 20, 150) == 20,
|
|
"target clamps to stream maximum");
|
|
check(AdaptiveAudioCurve.targetVolume(7, 2, 12, 50) == 5,
|
|
"nonzero stream minimum is respected");
|
|
check(AdaptiveAudioCurve.stepToward(5, 12, 0, 20) == 6,
|
|
"automatic increase is one notch");
|
|
check(AdaptiveAudioCurve.stepToward(12, 5, 0, 20) == 11,
|
|
"automatic decrease is one notch");
|
|
check(AdaptiveAudioCurve.stepToward(8, 8, 0, 20) == 8,
|
|
"settled volume does not move");
|
|
|
|
float at80 = AdaptiveAudioCurve.multiplierPercent(80, 20, 90, 70, 100, 110, 110);
|
|
float afterTwoNotches = 12f / 20f;
|
|
float newReference = AdaptiveAudioCurve.referenceFraction(afterTwoNotches, at80);
|
|
close(newReference * at80 / 100f, afterTwoNotches,
|
|
"manual two-notch change remains authoritative at 80 km/h");
|
|
close(AdaptiveAudioCurve.multiplierPercent(180, 20, 90, 70, 100, 110, 110),
|
|
110f, "speed above level 3 cannot increase multiplier further");
|
|
|
|
System.out.println("AdaptiveAudioCurveTest: OK");
|
|
}
|
|
}
|