live mission details in footer implemented
This commit is contained in:
@@ -34,4 +34,80 @@ void main() {
|
||||
expect(stats.durationSec, closeTo(leg1 / 20 + leg2 / 10, 0.1));
|
||||
});
|
||||
});
|
||||
|
||||
group('computeFlyMissionStatus', () {
|
||||
final waypoints = [_wp(0, 0), _wp(0, 0.01), _wp(0, 0.02)];
|
||||
|
||||
test('kein aktiver Wegpunkt (null) ergibt null', () {
|
||||
expect(
|
||||
computeFlyMissionStatus(waypoints: waypoints, activeWaypointIndex: null),
|
||||
isNull,
|
||||
);
|
||||
});
|
||||
|
||||
test('activeWaypointIndex ausserhalb der Liste ergibt null', () {
|
||||
expect(
|
||||
computeFlyMissionStatus(waypoints: waypoints, activeWaypointIndex: 3),
|
||||
isNull,
|
||||
);
|
||||
expect(
|
||||
computeFlyMissionStatus(waypoints: waypoints, activeWaypointIndex: -1),
|
||||
isNull,
|
||||
);
|
||||
});
|
||||
|
||||
test('activeWaypointNumber ist 1-basiert (Index 1 -> Nummer 2)', () {
|
||||
final status = computeFlyMissionStatus(
|
||||
waypoints: waypoints,
|
||||
activeWaypointIndex: 1,
|
||||
);
|
||||
expect(status!.activeWaypointNumber, 2);
|
||||
expect(status.waypointCount, 3);
|
||||
});
|
||||
|
||||
test('ohne Position (kein Fix) bleiben Distanz/ETA null', () {
|
||||
final status = computeFlyMissionStatus(
|
||||
waypoints: waypoints,
|
||||
activeWaypointIndex: 1,
|
||||
);
|
||||
expect(status!.distanceToActiveWaypointM, isNull);
|
||||
expect(status.etaToActiveWaypointSec, isNull);
|
||||
});
|
||||
|
||||
test('mit Position wird die Distanz zum aktiven Wegpunkt berechnet', () {
|
||||
final status = computeFlyMissionStatus(
|
||||
waypoints: waypoints,
|
||||
activeWaypointIndex: 1,
|
||||
currentLat: 0,
|
||||
currentLon: 0,
|
||||
);
|
||||
// Wegpunkt 1 (Index 1) liegt bei (0, 0.01) - rund 1112.6 m vom
|
||||
// Ursprung entfernt.
|
||||
expect(status!.distanceToActiveWaypointM, closeTo(1112.6, 1));
|
||||
// Ohne Geschwindigkeit keine ETA.
|
||||
expect(status.etaToActiveWaypointSec, isNull);
|
||||
});
|
||||
|
||||
test('mit Position und Geschwindigkeit wird die ETA berechnet', () {
|
||||
final status = computeFlyMissionStatus(
|
||||
waypoints: waypoints,
|
||||
activeWaypointIndex: 1,
|
||||
currentLat: 0,
|
||||
currentLon: 0,
|
||||
currentSpeedMs: 10,
|
||||
);
|
||||
expect(status!.etaToActiveWaypointSec, closeTo(1112.6 / 10, 0.1));
|
||||
});
|
||||
|
||||
test('unter 0.5 m/s wird keine (irrefuehrende) ETA berechnet', () {
|
||||
final status = computeFlyMissionStatus(
|
||||
waypoints: waypoints,
|
||||
activeWaypointIndex: 1,
|
||||
currentLat: 0,
|
||||
currentLon: 0,
|
||||
currentSpeedMs: 0.1,
|
||||
);
|
||||
expect(status!.etaToActiveWaypointSec, isNull);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -89,6 +89,9 @@ void main() {
|
||||
expect(frame.batteryPercent, 77);
|
||||
expect(frame.linkQuality, 88);
|
||||
expect(frame.flightMode, 'Waypoint mission (en route to WP)');
|
||||
// Fake-FC meldet activeWpNumber=3 (1-basiert) - als 0-basierter Index
|
||||
// in die App-eigene Wegpunktliste entspricht das Index 2.
|
||||
expect(frame.activeWaypointIndex, 2);
|
||||
|
||||
await link.disconnect();
|
||||
responder.cancel();
|
||||
@@ -122,9 +125,10 @@ void main() {
|
||||
|
||||
await link.connect();
|
||||
// Der Poller laeuft bereits mit, aber readActiveWaypointIndex() fragt
|
||||
// unabhaengig davon direkt ab.
|
||||
// unabhaengig davon direkt ab. Fake-FC meldet activeWpNumber=3
|
||||
// (1-basiert) - als 0-basierter Index entspricht das 2.
|
||||
final index = await link.readActiveWaypointIndex();
|
||||
expect(index, 3);
|
||||
expect(index, 2);
|
||||
|
||||
await link.disconnect();
|
||||
responder.cancel();
|
||||
|
||||
@@ -90,8 +90,12 @@ void main() {
|
||||
expect(parseMspNavStatusActiveWaypoint(navStatusPayload(0)), isNull);
|
||||
});
|
||||
|
||||
test('activeWpNumber > 0 wird durchgereicht', () {
|
||||
expect(parseMspNavStatusActiveWaypoint(navStatusPayload(5)), 5);
|
||||
test('activeWpNumber > 0 wird zu einem 0-basierten Index umgerechnet', () {
|
||||
expect(parseMspNavStatusActiveWaypoint(navStatusPayload(5)), 4);
|
||||
});
|
||||
|
||||
test('activeWpNumber 1 (erster Wegpunkt aktiv) wird zu Index 0', () {
|
||||
expect(parseMspNavStatusActiveWaypoint(navStatusPayload(1)), 0);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user