mirror of
https://github.com/dz0ny/meshcore-sar.git
synced 2026-08-11 16:30:28 +00:00
feat: Add send mode localization #123
This commit is contained in:
@@ -207,6 +207,22 @@ void main() {
|
||||
},
|
||||
);
|
||||
|
||||
test('clear history removes stored direct paths for one contact', () async {
|
||||
final service = PathHistoryService();
|
||||
|
||||
await service.initialize();
|
||||
await service.recordReceivedBytePath('abc123', [0x01, 0x02], 1);
|
||||
await service.recordReceivedBytePath('def456', [0x03, 0x04], 1);
|
||||
|
||||
expect(service.historyFor('abc123').directPaths, hasLength(1));
|
||||
expect(service.historyFor('def456').directPaths, hasLength(1));
|
||||
|
||||
await service.clearHistoryFor('abc123');
|
||||
|
||||
expect(service.historyFor('abc123').directPaths, isEmpty);
|
||||
expect(service.historyFor('def456').directPaths, hasLength(1));
|
||||
});
|
||||
|
||||
test('last successful direct path is chosen by location fit', () async {
|
||||
final service = PathHistoryService();
|
||||
final contact = _buildContact(
|
||||
|
||||
@@ -415,8 +415,11 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
final scaffoldKey = GlobalKey<ScaffoldMessengerState>();
|
||||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
scaffoldMessengerKey: scaffoldKey,
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
home: Scaffold(
|
||||
@@ -431,15 +434,43 @@ void main() {
|
||||
);
|
||||
|
||||
await tester.tap(find.byIcon(Icons.more_vert));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 300));
|
||||
|
||||
expect(find.text('Copy raw response'), findsOneWidget);
|
||||
|
||||
// Capture clipboard writes via the test platform channel mock.
|
||||
String? clipboardText;
|
||||
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(
|
||||
SystemChannels.platform,
|
||||
(MethodCall call) async {
|
||||
if (call.method == 'Clipboard.setData') {
|
||||
final args = call.arguments as Map<dynamic, dynamic>;
|
||||
clipboardText = args['text'] as String?;
|
||||
}
|
||||
if (call.method == 'Clipboard.getData') {
|
||||
return <String, dynamic>{'text': clipboardText};
|
||||
}
|
||||
return null;
|
||||
},
|
||||
);
|
||||
addTearDown(() {
|
||||
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(
|
||||
SystemChannels.platform,
|
||||
null,
|
||||
);
|
||||
});
|
||||
|
||||
await tester.tap(find.text('Copy raw response'));
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 300));
|
||||
|
||||
final clipboardData = await Clipboard.getData(Clipboard.kTextPlain);
|
||||
expect(clipboardData?.text, '01 67 00 d7');
|
||||
expect(clipboardText, '01 67 00 d7');
|
||||
expect(find.text('Raw response copied'), findsOneWidget);
|
||||
|
||||
// Clear the SnackBar to prevent its timer from blocking teardown.
|
||||
scaffoldKey.currentState?.clearSnackBars();
|
||||
await tester.pump(const Duration(seconds: 5));
|
||||
await tester.pump(const Duration(seconds: 5));
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user