FB-01: fix ambient GPS's first fix not correcting the initial zoom-2
Emulator verification caught a real bug the widget tests missed: the shell background map builds before any location fix has resolved, so ambientPosition starts null and the initial camera locks at zoom 2. The first fix to arrive only re-centered (preserving that stale zoom forever) instead of also jumping to ambientZoom.
This commit is contained in:
@@ -250,6 +250,45 @@ void main() {
|
||||
expect(center.longitude, closeTo(fix2.longitude, 1e-9));
|
||||
});
|
||||
|
||||
testWidgets('the first ambient fix to arrive after construction corrects the '
|
||||
'zoom, not just the center -- a plain re-center would otherwise leave the '
|
||||
'map at the initial zoom-2 forever', (tester) async {
|
||||
// Reproduces a real device bug found in emulator verification: the shell
|
||||
// background map builds before any location permission/fix has resolved, so
|
||||
// `ambientPosition` starts null and the initial camera locks at zoom 2 (the
|
||||
// `bounds == null` fallback). The first fix to actually arrive must jump to
|
||||
// `ambientZoom`, not just re-center at whatever zoom the map already happens
|
||||
// to be sitting at.
|
||||
const fix = ll.LatLng(51.0, -114.0);
|
||||
|
||||
Widget build(ll.LatLng? ambient) => MaterialApp(
|
||||
theme: ripprTheme(),
|
||||
home: Scaffold(
|
||||
body: RideMap(
|
||||
points: const [],
|
||||
segments: const [],
|
||||
showEmptyLabel: false,
|
||||
follow: true,
|
||||
ambientPosition: ambient,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await tester.pumpWidget(build(null));
|
||||
await tester.pump();
|
||||
|
||||
var map = tester.widget<FlutterMap>(find.byType(FlutterMap));
|
||||
expect(map.mapController!.camera.zoom, 2);
|
||||
|
||||
await tester.pumpWidget(build(fix));
|
||||
await tester.pump();
|
||||
|
||||
map = tester.widget<FlutterMap>(find.byType(FlutterMap));
|
||||
expect(map.mapController!.camera.zoom, ambientZoom);
|
||||
expect(map.mapController!.camera.center.latitude, closeTo(fix.latitude, 1e-9));
|
||||
expect(map.mapController!.camera.center.longitude, closeTo(fix.longitude, 1e-9));
|
||||
});
|
||||
|
||||
testWidgets('a manual pan cancels ambient following the same way it cancels '
|
||||
'recording-follow', (tester) async {
|
||||
const fix1 = ll.LatLng(51.0, -114.0);
|
||||
|
||||
Reference in New Issue
Block a user