- Wheels/readouts now add max(MediaQuery.padding.left/right) on both sides symmetrically (HTML prototype: max(env(safe-area-inset-left), env(safe-area-inset-right))), so a front-camera cutout in landscape doesn't sit behind the altitude wheel, and both sides stay in sync. - WaypointListPanel is now pushed via Navigator (PageRouteBuilder + fade) instead of being an internal Stack overlay in PlanScreen. It was rendering *under* AppShell's TopModeBar before, since TopModeBar is always the last (topmost) child of AppShell's own Stack regardless of what PlanScreen draws internally - a plain bool flag inside PlanScreen had no way to paint above a sibling higher up the tree. A pushed route paints above the entire invoking route's content by construction, so this was the actual fix rather than reshuffling Z-order inside PlanScreen. - Extracted DefaultDroneProfile (T1 Ranger constants) out of PlanScreen's private statics into lib/domain/mission/, since WaypointListPanel now needs the same values to compute its own route geometry reactively (previously passed down as a vertexBad/altMin/altMax/... snapshot, which would have gone stale while the panel was open across a route boundary). - Bottom bar now has the prototype's rgba(15,15,15,0.72) background (previously fully transparent outside the stats pill), and gained MiniAltitudeProfile - the non-interactive height-profile sparkline that sits above the stats row. - Added the Altitude/Speed full-screen chart tabs (FullValueChart): drag any waypoint's point to adjust its altitude/speed, X position proportional to cumulative route distance, matching the prototype's buildFullChart()/attachChartDrag(). Terrain overlay and wind diamonds from the prototype aren't ported - terrain (doc 3.9) and wind (doc 3.8) systems don't exist yet in the Flutter app. - RouteGeometry now also exposes legClimbBad (was computed internally but not surfaced), needed by both the mini profile and the chart tabs. Discovered while updating the widget tests: a single tester.pump() after tapping something that triggers Navigator.push/pop isn't enough - the push/pop itself needs a frame to register before a duration-based pump can animate it, so both are needed in sequence. Added 2 new tests for the chart tabs; all 17 tests and flutter analyze pass. Verified all four changes on the Pixel_10a emulator: wheels, opaque bottom bar with the mini profile, the list panel now fully covering the top bar (confirmed by its complete absence while the panel is open), and dragging points on both chart tabs. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
313 lines
10 KiB
Dart
313 lines
10 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:flutter_map/flutter_map.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
import 'package:dmc_app/app_mode/app_mode_cubit.dart';
|
|
import 'package:dmc_app/domain/waypoint/flat_waypoint_list.dart';
|
|
import 'package:dmc_app/ui/app_shell.dart';
|
|
import 'package:dmc_app/ui/providers/current_mission_provider.dart';
|
|
import 'package:dmc_app/ui/widgets/full_value_chart.dart';
|
|
import 'package:dmc_app/ui/widgets/halo_menu.dart';
|
|
import 'package:dmc_app/ui/widgets/reticle_button.dart';
|
|
import 'package:dmc_app/ui/widgets/waypoint_chip.dart';
|
|
import 'package:dmc_app/ui/widgets/waypoint_list_panel.dart';
|
|
|
|
Widget _wrap(Widget child) => ProviderScope(
|
|
child: BlocProvider(
|
|
create: (_) => AppModeCubit(),
|
|
child: MaterialApp(home: child),
|
|
),
|
|
);
|
|
|
|
Future<ProviderContainer> _pumpWithContainer(WidgetTester tester) async {
|
|
final container = ProviderContainer();
|
|
await tester.pumpWidget(
|
|
UncontrolledProviderScope(
|
|
container: container,
|
|
child: BlocProvider(
|
|
create: (_) => AppModeCubit(),
|
|
child: const MaterialApp(home: AppShell()),
|
|
),
|
|
),
|
|
);
|
|
await tester.pump();
|
|
return container;
|
|
}
|
|
|
|
void main() {
|
|
testWidgets('AppShell zeigt die Karte und den Plan/Fly-Umschalter im Startzustand',
|
|
(tester) async {
|
|
await tester.pumpWidget(_wrap(const AppShell()));
|
|
// Nur ein Frame pumpen statt pumpAndSettle: TileLayer laedt echte
|
|
// Netzwerk-Kacheln, die in der Testumgebung nie ankommen.
|
|
await tester.pump();
|
|
|
|
expect(find.byType(FlutterMap), findsOneWidget);
|
|
expect(find.text('Plan'), findsOneWidget);
|
|
expect(find.text('Fly'), findsOneWidget);
|
|
});
|
|
|
|
testWidgets(
|
|
'Fly-Button ohne erfuellten Ready-to-Fly-Gate zeigt Hinweis statt Absturz',
|
|
(tester) async {
|
|
await tester.pumpWidget(_wrap(const AppShell()));
|
|
await tester.pump();
|
|
|
|
await tester.tap(find.text('Fly'));
|
|
await tester.pump();
|
|
|
|
expect(
|
|
find.text('Mission muss zuerst hochgeladen und verifiziert werden.'),
|
|
findsOneWidget,
|
|
);
|
|
// Weiterhin im Plan-Modus, da das Gate nicht erfuellt war.
|
|
expect(find.byType(FlutterMap), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('Reticle-Button fuegt einen Wegpunkt am Kartenzentrum hinzu',
|
|
(tester) async {
|
|
final container = ProviderContainer();
|
|
addTearDown(container.dispose);
|
|
|
|
await tester.pumpWidget(
|
|
UncontrolledProviderScope(
|
|
container: container,
|
|
child: BlocProvider(
|
|
create: (_) => AppModeCubit(),
|
|
child: const MaterialApp(home: AppShell()),
|
|
),
|
|
),
|
|
);
|
|
await tester.pump();
|
|
|
|
expect(container.read(currentMissionProvider), isEmpty);
|
|
|
|
await tester.tap(find.byType(ReticleButton));
|
|
await tester.pump();
|
|
|
|
final waypoints = container.read(currentMissionProvider);
|
|
expect(waypoints, hasLength(1));
|
|
expect(waypoints.single.lat, closeTo(52.3676, 0.0001));
|
|
expect(waypoints.single.lon, closeTo(4.9041, 0.0001));
|
|
});
|
|
|
|
testWidgets(
|
|
'Zweiter Tap auf den frisch gesetzten Wegpunkt oeffnet das Halo-Menue',
|
|
(tester) async {
|
|
final container = ProviderContainer();
|
|
addTearDown(container.dispose);
|
|
|
|
await tester.pumpWidget(
|
|
UncontrolledProviderScope(
|
|
container: container,
|
|
child: BlocProvider(
|
|
create: (_) => AppModeCubit(),
|
|
child: const MaterialApp(home: AppShell()),
|
|
),
|
|
),
|
|
);
|
|
await tester.pump();
|
|
|
|
// 1. Tap: idle -> snapped (legt Wegpunkt an).
|
|
await tester.tap(find.byType(ReticleButton));
|
|
await tester.pump();
|
|
expect(find.byType(HaloMenu), findsNothing);
|
|
|
|
// 2. Tap: snapped -> editing.
|
|
await tester.tap(find.byType(ReticleButton));
|
|
await tester.pump();
|
|
expect(find.byType(HaloMenu), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('Halo-Remove entfernt den Wegpunkt und schliesst das Menue',
|
|
(tester) async {
|
|
final container = ProviderContainer();
|
|
addTearDown(container.dispose);
|
|
|
|
await tester.pumpWidget(
|
|
UncontrolledProviderScope(
|
|
container: container,
|
|
child: BlocProvider(
|
|
create: (_) => AppModeCubit(),
|
|
child: const MaterialApp(home: AppShell()),
|
|
),
|
|
),
|
|
);
|
|
await tester.pump();
|
|
|
|
await tester.tap(find.byType(ReticleButton)); // idle -> snapped
|
|
await tester.pump();
|
|
await tester.tap(find.byType(ReticleButton)); // snapped -> editing
|
|
await tester.pump();
|
|
|
|
// Die Wedge-Bounding-Box-Mitte liegt ausserhalb der Keilform (Donut-
|
|
// Segment) - stattdessen exakt auf das (nicht hit-testbare) Icon tippen,
|
|
// das per Konstruktion innerhalb des Keils sitzt.
|
|
await tester.tapAt(tester.getCenter(find.byIcon(Icons.remove)));
|
|
await tester.pump();
|
|
|
|
expect(container.read(currentMissionProvider), isEmpty);
|
|
expect(find.byType(HaloMenu), findsNothing);
|
|
});
|
|
|
|
testWidgets('Halo-Loiter setzt die Execute-Aktion und schliesst das Menue',
|
|
(tester) async {
|
|
final container = ProviderContainer();
|
|
addTearDown(container.dispose);
|
|
|
|
await tester.pumpWidget(
|
|
UncontrolledProviderScope(
|
|
container: container,
|
|
child: BlocProvider(
|
|
create: (_) => AppModeCubit(),
|
|
child: const MaterialApp(home: AppShell()),
|
|
),
|
|
),
|
|
);
|
|
await tester.pump();
|
|
|
|
await tester.tap(find.byType(ReticleButton)); // idle -> snapped
|
|
await tester.pump();
|
|
await tester.tap(find.byType(ReticleButton)); // snapped -> editing
|
|
await tester.pump();
|
|
|
|
await tester.tapAt(tester.getCenter(find.byIcon(Icons.loop)));
|
|
await tester.pump();
|
|
|
|
final waypoints = container.read(currentMissionProvider);
|
|
expect(waypoints.single.action, WaypointAction.loiter);
|
|
expect(find.byType(HaloMenu), findsNothing);
|
|
});
|
|
|
|
testWidgets('Bottom-Stats-Bar oeffnet die leere Wegpunktliste',
|
|
(tester) async {
|
|
await _pumpWithContainer(tester);
|
|
|
|
await tester.tap(find.text('Details:'));
|
|
// Die Liste wird als eigene Route mit Fade-Transition gepusht: erst ein
|
|
// Frame ohne Dauer, damit der synchron ausgeloeste Navigator.push()
|
|
// registriert wird, danach die Animationszeit abwarten.
|
|
await tester.pump();
|
|
await tester.pump(const Duration(milliseconds: 200));
|
|
|
|
expect(find.byType(WaypointListPanel), findsOneWidget);
|
|
expect(find.text('No waypoints yet'), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('Zeile antippen zentriert die Karte und schliesst die Liste',
|
|
(tester) async {
|
|
await _pumpWithContainer(tester);
|
|
|
|
await tester.tap(find.byType(ReticleButton));
|
|
await tester.pump();
|
|
|
|
await tester.tap(find.text('Details:'));
|
|
await tester.pump();
|
|
await tester.pump(const Duration(milliseconds: 200));
|
|
expect(find.byType(WaypointListPanel), findsOneWidget);
|
|
|
|
await tester.tap(find.text('60 m').first);
|
|
// Navigator.pop() spielt ebenfalls eine (Rueck-)Transition ab.
|
|
await tester.pump();
|
|
await tester.pump(const Duration(milliseconds: 200));
|
|
|
|
expect(find.byType(WaypointListPanel), findsNothing);
|
|
});
|
|
|
|
testWidgets('Papierkorb-Icon in der Liste entfernt den Wegpunkt',
|
|
(tester) async {
|
|
final container = await _pumpWithContainer(tester);
|
|
|
|
await tester.tap(find.byType(ReticleButton));
|
|
await tester.pump();
|
|
await tester.tap(find.text('Details:'));
|
|
await tester.pump();
|
|
await tester.pump(const Duration(milliseconds: 200));
|
|
|
|
expect(container.read(currentMissionProvider), hasLength(1));
|
|
|
|
await tester.tap(find.byIcon(Icons.delete_outline));
|
|
await tester.pump();
|
|
|
|
expect(container.read(currentMissionProvider), isEmpty);
|
|
expect(find.text('No waypoints yet'), findsOneWidget);
|
|
});
|
|
|
|
testWidgets(
|
|
'Wertechip in der Liste aendert die Hoehe des Wegpunkts per Drag',
|
|
(tester) async {
|
|
final container = await _pumpWithContainer(tester);
|
|
|
|
await tester.tap(find.byType(ReticleButton));
|
|
await tester.pump();
|
|
await tester.tap(find.text('Details:'));
|
|
await tester.pump();
|
|
await tester.pump(const Duration(milliseconds: 200));
|
|
|
|
// Icons.edit erscheint auch auf dem ReticleButton im Modus "snapped" -
|
|
// gezielt das Edit-Icon der Listenzeile ansprechen.
|
|
await tester.tap(find.descendant(
|
|
of: find.byType(WaypointListPanel),
|
|
matching: find.byIcon(Icons.edit),
|
|
));
|
|
await tester.pump();
|
|
expect(find.byType(WaypointChip), findsNWidgets(3));
|
|
|
|
await tester.drag(find.byType(WaypointChip).first, const Offset(0, -140));
|
|
// Der Chip-Flash-Effekt setzt per Timer nach 120ms zurueck - abwarten,
|
|
// damit kein Timer nach Testende/Dispose noch aussteht.
|
|
await tester.pump(const Duration(milliseconds: 200));
|
|
|
|
final waypoints = container.read(currentMissionProvider);
|
|
expect(waypoints.single.altitudeM, greaterThan(60));
|
|
});
|
|
|
|
testWidgets(
|
|
'Altitude-Tab aendert die Hoehe per Drag auf dem Chart-Punkt',
|
|
(tester) async {
|
|
final container = await _pumpWithContainer(tester);
|
|
|
|
await tester.tap(find.byType(ReticleButton));
|
|
await tester.pump();
|
|
await tester.tap(find.text('Details:'));
|
|
await tester.pump();
|
|
await tester.pump(const Duration(milliseconds: 200));
|
|
|
|
await tester.tap(find.text('Altitude'));
|
|
await tester.pump();
|
|
expect(find.byType(FullValueChart), findsOneWidget);
|
|
|
|
final chartCenter = tester.getCenter(find.byType(FullValueChart));
|
|
await tester.dragFrom(chartCenter, const Offset(0, -100));
|
|
await tester.pump();
|
|
|
|
final waypoints = container.read(currentMissionProvider);
|
|
expect(waypoints.single.altitudeM, greaterThan(60));
|
|
});
|
|
|
|
testWidgets(
|
|
'Speed-Tab aendert die Geschwindigkeit per Drag auf dem Chart-Punkt',
|
|
(tester) async {
|
|
final container = await _pumpWithContainer(tester);
|
|
|
|
await tester.tap(find.byType(ReticleButton));
|
|
await tester.pump();
|
|
await tester.tap(find.text('Details:'));
|
|
await tester.pump();
|
|
await tester.pump(const Duration(milliseconds: 200));
|
|
|
|
await tester.tap(find.text('Speed'));
|
|
await tester.pump();
|
|
expect(find.byType(FullValueChart), findsOneWidget);
|
|
|
|
final chartCenter = tester.getCenter(find.byType(FullValueChart));
|
|
await tester.dragFrom(chartCenter, const Offset(0, -50));
|
|
await tester.pump();
|
|
|
|
final waypoints = container.read(currentMissionProvider);
|
|
expect(waypoints.single.speedMs, greaterThan(15));
|
|
});
|
|
}
|