- detectSystemMessages() erkennt jetzt auch den Uebergang zu einem GPS-Fix (flankengetriggert wie Battery/Failsafe), Meldung "GPS fix acquired (N satellites)". - Die automatisch erkannten Verbindungsmeldungen heissen jetzt "Drone connected"/"Drone disconnected" statt "Connected"/"Connection lost" - praeziser an die tatsaechliche Bedeutung angelehnt (Eintreffen/Ausbleiben echter Telemetrie-Frames, nicht nur des rohen Socket-Zustands). - DroneProfile: feste Pack-Alarmspannung (batteryVoltageGreenMinV/RedMinV) ersetzt durch batteryCellCount + Pro-Zelle-Schwellwerte (batteryVoltageGreenMinPerCellV/RedMinPerCellV, LiPo-Standardwerte 3.4/3.2 V als Default). Die alten Feldnamen bleiben als berechnete Getter (Zellenzahl * Pro-Zelle-Wert) erhalten, damit telemetry_field_status.dart unveraendert bleibt. T1-Ranger-Standardprofil auf 4S gesetzt. - DB-Schema v8 -> v9 (additiv, alte Pack-Spannungs-Spalten bleiben als tote Spalten stehen), Repository und Share-Codec-Im-/Export entsprechend angepasst; alte Exportdateien ohne die neuen Felder fallen auf die DroneProfile-Defaults zurueck statt eine unbekannte Zellenzahl zu raten. - DroneProfileEditor: "Battery voltage alarm"-Gruppe um ein Zellenzahl-Feld erweitert und auf V/Zelle umbenannt. - Tests ergaenzt/angepasst: GPS-Fix-Erkennung (Unit + Provider-Integration), neuer v8->v9-Migrationstest analog zum bestehenden v7->v8-Test, Connected/Disconnected-Umbenennung in Provider- und Widget-Tests, Cell-Count-Roundtrip in Repository- und Share-Codec-Tests. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
86 lines
3.0 KiB
Dart
86 lines
3.0 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
import 'package:dmc_app/domain/mission/drone_profile.dart';
|
|
import 'package:dmc_app/services/sharing/drone_share_codec.dart';
|
|
|
|
void main() {
|
|
final profile = DroneProfile.t1Ranger().copyWith(id: 7, name: 'T1 Ranger #2');
|
|
|
|
group('buildDroneExportJson / parseDroneImportJson', () {
|
|
test('round-trip erhaelt alle Flugleistungsfelder, aber nicht die id', () {
|
|
final json = buildDroneExportJson(profile);
|
|
final parsed = parseDroneImportJson(json);
|
|
|
|
expect(parsed.profile.id, isNull);
|
|
expect(parsed.profile.name, 'T1 Ranger #2');
|
|
expect(parsed.profile.minSpeed, profile.minSpeed);
|
|
expect(parsed.profile.maxSpeed, profile.maxSpeed);
|
|
expect(parsed.profile.maxAltitudeM, profile.maxAltitudeM);
|
|
expect(parsed.profile.batteryCellCount, profile.batteryCellCount);
|
|
expect(
|
|
parsed.profile.batteryVoltageGreenMinPerCellV,
|
|
profile.batteryVoltageGreenMinPerCellV,
|
|
);
|
|
expect(
|
|
parsed.profile.batteryVoltageRedMinPerCellV,
|
|
profile.batteryVoltageRedMinPerCellV,
|
|
);
|
|
expect(parsed.versionMismatch, isNull);
|
|
});
|
|
|
|
test('alte Exportdatei ohne batteryCellCount faellt auf die neuen '
|
|
'Defaults zurueck, statt die alte Pack-Spannung zu uebernehmen', () {
|
|
final json = buildDroneExportJson(profile).replaceFirst(
|
|
RegExp(
|
|
r',\s*"batteryCellCount": [\d.]+,\s*'
|
|
r'"batteryVoltageGreenMinPerCellV": [\d.]+,\s*'
|
|
r'"batteryVoltageRedMinPerCellV": [\d.]+',
|
|
),
|
|
'',
|
|
);
|
|
final parsed = parseDroneImportJson(json);
|
|
|
|
expect(parsed.profile.batteryCellCount, DroneProfile.defaultBatteryCellCount);
|
|
expect(
|
|
parsed.profile.batteryVoltageGreenMinPerCellV,
|
|
DroneProfile.defaultBatteryVoltageGreenMinPerCellV,
|
|
);
|
|
expect(
|
|
parsed.profile.batteryVoltageRedMinPerCellV,
|
|
DroneProfile.defaultBatteryVoltageRedMinPerCellV,
|
|
);
|
|
});
|
|
|
|
test('erkennt eine abweichende Hauptversion als Mismatch', () {
|
|
final json = buildDroneExportJson(profile).replaceFirst('"1.0.0"', '"2.0.0"');
|
|
final parsed = parseDroneImportJson(json);
|
|
expect(parsed.versionMismatch, '2.0.0');
|
|
});
|
|
|
|
test('wirft FormatException bei ungueltigem JSON', () {
|
|
expect(() => parseDroneImportJson('{not json'), throwsFormatException);
|
|
});
|
|
|
|
test('wirft FormatException wenn ein Pflichtfeld fehlt', () {
|
|
expect(
|
|
() => parseDroneImportJson('{"drone": {"name": "Incomplete"}}'),
|
|
throwsFormatException,
|
|
);
|
|
});
|
|
|
|
test('wirft FormatException wenn der Name fehlt', () {
|
|
final json = buildDroneExportJson(profile).replaceFirst(
|
|
'"name": "T1 Ranger #2"',
|
|
'"name": ""',
|
|
);
|
|
expect(() => parseDroneImportJson(json), throwsFormatException);
|
|
});
|
|
});
|
|
|
|
group('droneExportFilename', () {
|
|
test('ersetzt Sonderzeichen durch Unterstriche', () {
|
|
expect(droneExportFilename('T1 Ranger #2'), 'drone-T1_Ranger__2.json');
|
|
});
|
|
});
|
|
}
|