mirror of
https://github.com/dz0ny/meshcore-sar.git
synced 2026-08-11 16:30:28 +00:00
fix: Keep composer and sensor sheets closable #123
This commit is contained in:
@@ -7,6 +7,7 @@ import 'package:meshcore_sar_app/models/contact.dart';
|
||||
import 'package:meshcore_sar_app/providers/contacts_provider.dart';
|
||||
import 'package:meshcore_sar_app/providers/sensors_provider.dart';
|
||||
import 'package:meshcore_sar_app/screens/sensors_tab.dart';
|
||||
import 'package:meshcore_sar_app/widgets/sensors/sensor_telemetry_card.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
@@ -22,9 +23,12 @@ void main() {
|
||||
expect(provider.isLoaded, isTrue);
|
||||
}
|
||||
|
||||
Contact buildSensorContact() {
|
||||
Contact buildSensorContact({
|
||||
int firstByte = 0x44,
|
||||
String name = 'WX Station',
|
||||
}) {
|
||||
final publicKey = Uint8List(32);
|
||||
publicKey[0] = 0x44;
|
||||
publicKey[0] = firstByte;
|
||||
|
||||
return Contact(
|
||||
publicKey: publicKey,
|
||||
@@ -32,7 +36,7 @@ void main() {
|
||||
flags: 0,
|
||||
outPathLen: 0,
|
||||
outPath: Uint8List(64),
|
||||
advName: 'WX Station',
|
||||
advName: name,
|
||||
lastAdvert: DateTime.now().millisecondsSinceEpoch ~/ 1000,
|
||||
advLat: 0,
|
||||
advLon: 0,
|
||||
@@ -70,19 +74,22 @@ void main() {
|
||||
child: MaterialApp(
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
home: const SensorsTab(),
|
||||
home: SensorCustomizeView(
|
||||
publicKeyHex: contact.publicKeyHex,
|
||||
initialContact: contact,
|
||||
onRenameMetric:
|
||||
({
|
||||
required BuildContext context,
|
||||
required String publicKeyHex,
|
||||
required SensorMetricOption option,
|
||||
required SensorsProvider sensorsProvider,
|
||||
}) async {},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pump();
|
||||
|
||||
await tester.tap(find.byIcon(Icons.more_vert));
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 300));
|
||||
await tester.tap(find.text('Customize fields'));
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 300));
|
||||
|
||||
expect(find.text('Customize WX Station'), findsOneWidget);
|
||||
expect(find.text('Live preview'), findsOneWidget);
|
||||
expect(find.text('Refresh schedule'), findsOneWidget);
|
||||
@@ -94,4 +101,49 @@ void main() {
|
||||
);
|
||||
expect(find.text('Channel 2'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('add sensor sheet keeps close action available when scrolled', (
|
||||
tester,
|
||||
) async {
|
||||
tester.view.physicalSize = const Size(320, 480);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.reset);
|
||||
|
||||
var didClose = false;
|
||||
final candidates = List<Contact>.generate(
|
||||
20,
|
||||
(index) =>
|
||||
buildSensorContact(firstByte: index + 1, name: 'Sensor ${index + 1}'),
|
||||
);
|
||||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
home: Scaffold(
|
||||
body: AddSensorSheet(
|
||||
candidates: candidates,
|
||||
onSelect: (_) async {},
|
||||
onClose: () {
|
||||
didClose = true;
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pump();
|
||||
|
||||
final closeButton = find.byTooltip('Close');
|
||||
expect(closeButton, findsOneWidget);
|
||||
|
||||
await tester.drag(find.byType(ListView).last, const Offset(0, -600));
|
||||
await tester.pump();
|
||||
|
||||
expect(closeButton, findsOneWidget);
|
||||
|
||||
await tester.tap(closeButton);
|
||||
await tester.pump();
|
||||
|
||||
expect(didClose, isTrue);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user