63 lines
2.3 KiB
Dart
63 lines
2.3 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:geolocator/geolocator.dart';
|
|
|
|
void main() {
|
|
group('LocationService Physical & GPS Threshold Tests', () {
|
|
test('Position accuracy under 5.0m is classified as best precision', () {
|
|
final pos = Position(
|
|
latitude: 37.7749, longitude: -122.4194, timestamp: DateTime.now(),
|
|
accuracy: 3.2, altitude: 10.0, heading: 90.0, speed: 25.0,
|
|
speedAccuracy: 0.5, altitudeAccuracy: 1.0, headingAccuracy: 1.0,
|
|
);
|
|
expect(pos.accuracy, lessThanOrEqualTo(5.0));
|
|
expect(pos.speed * 2.23694, closeTo(55.92, 0.05));
|
|
});
|
|
|
|
test('Position speed exceeding 100 m/s is over physical 223 MPH limit', () {
|
|
final pos = Position(
|
|
latitude: 37.7749, longitude: -122.4194, timestamp: DateTime.now(),
|
|
accuracy: 5.0, altitude: 0.0, heading: 0.0, speed: 110.0,
|
|
speedAccuracy: 0.0, altitudeAccuracy: 0.0, headingAccuracy: 0.0,
|
|
);
|
|
expect(pos.speed, greaterThan(100.0));
|
|
expect(pos.speed * 2.23694, greaterThan(223.0));
|
|
});
|
|
|
|
test('Haversine distance between 1 degree latitude delta is ~111.19 km', () {
|
|
final dist = Geolocator.distanceBetween(37.0, -122.0, 38.0, -122.0);
|
|
expect(dist, closeTo(111195.0, 200.0));
|
|
});
|
|
|
|
test('Stationary jitter speed threshold (0.6 m/s) corresponds to 1.34 MPH', () {
|
|
const thresholdMps = 0.6;
|
|
const thresholdMph = thresholdMps * 2.23694;
|
|
expect(thresholdMph, closeTo(1.342, 0.01));
|
|
});
|
|
|
|
test('Acceleration calculation for 0 to 60 MPH in 3.0s is ~8.94 m/s^2 (~0.91g)', () {
|
|
const deltaSpeedMps = (60.0 / 2.23694);
|
|
const dtSec = 3.0;
|
|
final accel = deltaSpeedMps / dtSec;
|
|
expect(accel, closeTo(8.94, 0.05));
|
|
expect(accel / 9.80665, closeTo(0.91, 0.02));
|
|
});
|
|
|
|
test('GPS heading normalization keeps values in 0 to 360 degree range', () {
|
|
const heading = 359.5;
|
|
expect(heading >= 0.0 && heading < 360.0, isTrue);
|
|
});
|
|
|
|
test('GPS accuracy over 100m is flagged degraded during lock acquisition', () {
|
|
const poorAccuracy = 125.0;
|
|
expect(poorAccuracy > 100.0, isTrue);
|
|
});
|
|
|
|
test('Altitude delta of 5.0m across 1.0s is realistic mountain road grade', () {
|
|
const altDelta = 5.0;
|
|
const timeDelta = 1.0;
|
|
final climbRate = altDelta / timeDelta;
|
|
expect(climbRate, 5.0);
|
|
});
|
|
});
|
|
}
|