108 lines
3.9 KiB
Dart
108 lines
3.9 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:intaleq_maps/intaleq_maps.dart';
|
|
import 'package:tactical_app/models/military_operations_models.dart';
|
|
import 'package:tactical_app/services/artillery_ballistics_engine.dart';
|
|
import 'package:tactical_app/services/hlz_assessment_engine.dart';
|
|
import 'package:tactical_app/services/military_grid_utils.dart';
|
|
import 'package:tactical_app/services/minefield_engine.dart';
|
|
import 'package:tactical_app/services/tactical_isochrone_engine.dart';
|
|
|
|
void main() {
|
|
TestWidgetsFlutterBinding.ensureInitialized();
|
|
|
|
group('MilitaryGridUtils Calculations', () {
|
|
test('Haversine distance between Amman and Zarqa', () {
|
|
final d = MilitaryGridUtils.haversineDistance(31.9539, 35.9106, 32.0608, 36.0942);
|
|
expect(d, greaterThan(15000));
|
|
expect(d, lessThan(30000));
|
|
});
|
|
|
|
test('Azimuth and Cardinal Arabic direction', () {
|
|
final bearing = MilitaryGridUtils.calculateBearing(31.9539, 35.9106, 32.5568, 35.8469); // North to Irbid
|
|
final cardinal = MilitaryGridUtils.azimuthToCardinalArabic(bearing);
|
|
expect(cardinal, contains('شمال'));
|
|
});
|
|
|
|
test('MGRS Coordinate formatting', () {
|
|
final mgrs = MilitaryGridUtils.latLngToMgrs(31.9539, 35.9106);
|
|
expect(mgrs, contains('36R'));
|
|
expect(mgrs, contains('YA'));
|
|
});
|
|
});
|
|
|
|
group('Artillery Ballistics Engine', () {
|
|
test('Calculate firing solution for 155mm M109 Howitzer', () async {
|
|
const gun = LatLng(31.9300, 35.9100);
|
|
const target = LatLng(31.9800, 35.9800);
|
|
final weapon = ArtilleryWeaponSystem.standardSystems[0]; // M109 155mm
|
|
|
|
final sol = await ArtilleryBallisticsEngine.calculateFireMission(
|
|
weapon: weapon,
|
|
gunPos: gun,
|
|
targetPos: target,
|
|
highAngle: false,
|
|
);
|
|
|
|
expect(sol.distanceMeters, greaterThan(7000));
|
|
expect(sol.azimuthMilsNato, greaterThan(0));
|
|
expect(sol.azimuthMilsNato, lessThan(6400));
|
|
expect(sol.quadrantElevationMilsNato, greaterThan(0));
|
|
expect(sol.timeOfFlightSeconds, greaterThan(10));
|
|
expect(sol.trajectoryProfile.length, equals(61));
|
|
});
|
|
});
|
|
|
|
group('Helicopter Landing Zone (HLZ) Engine', () {
|
|
test('Assess medium lift helicopter pad', () async {
|
|
const center = LatLng(31.9539, 35.9106);
|
|
final hlz = await HlzAssessmentEngine.assessLandingZone(
|
|
center: center,
|
|
helicopterType: HelicopterType.mediumLift,
|
|
approachAzimuthDeg: 45.0,
|
|
);
|
|
|
|
expect(hlz.recommendedClearanceRadiusM, equals(40.0));
|
|
expect(hlz.padBoundary.length, greaterThan(10));
|
|
expect(hlz.approachFunnel.length, equals(4));
|
|
expect(hlz.suitabilityGrade, isNotEmpty);
|
|
});
|
|
});
|
|
|
|
group('Minefield Threat & Breaching Engine', () {
|
|
test('Calculate anti-tank minefield box and breaching lane', () {
|
|
const pA = LatLng(32.0000, 35.9000);
|
|
const pB = LatLng(32.0200, 35.9200);
|
|
|
|
final zone = MinefieldEngine.calculateMinefieldZone(
|
|
startPoint: pA,
|
|
endPoint: pB,
|
|
type: MinefieldType.antiTank,
|
|
widthMeters: 200.0,
|
|
);
|
|
|
|
expect(zone.lengthMeters, greaterThan(2000));
|
|
expect(zone.boundaryPolygon.length, equals(5));
|
|
expect(zone.breachLaneCenterline.length, equals(2));
|
|
expect(zone.breachLanePolygon.length, equals(5));
|
|
expect(zone.estimatedMinesCount, greaterThan(100));
|
|
});
|
|
});
|
|
|
|
group('Tactical Isochrone Reachability Engine', () {
|
|
test('Calculate 5, 10, 15 minute response time rings', () async {
|
|
const base = LatLng(31.9539, 35.9106);
|
|
final rings = await TacticalIsochroneEngine.calculateIsochrones(
|
|
center: base,
|
|
baseSpeedKmh: 60.0,
|
|
timeBuckets: [5, 10, 15],
|
|
);
|
|
|
|
expect(rings.length, equals(3));
|
|
expect(rings[0].timeMinutes, equals(5));
|
|
expect(rings[1].timeMinutes, equals(10));
|
|
expect(rings[2].timeMinutes, equals(15));
|
|
expect(rings[0].polygonCoordinates.length, equals(37)); // 36 rays + closed point
|
|
});
|
|
});
|
|
}
|