Refactor LoRa airtime tests and add new functionality

- Updated LoRa airtime calculations in `lora_airtime_test.dart` to reflect new reference values.
- Introduced new tests for LDRO behavior and preamble symbol calculations.
- Added `contact_path_width_test.dart` to validate path hash width handling in contacts.
- Enhanced `model_changes_test.dart` to ensure legacy data migration works correctly.
- Created `remote_node_stats_test.dart` to decode and validate remote node statistics.
- Implemented `map_marker_parse_test.dart` for parsing marker text with coordinate validation.
- Developed `map_tile_cache_key_test.dart` to ensure API keys are excluded from cache keys.
- Added `message_retry_failure_test.dart` to test message retry service behavior on failures.
- Extended `path_history_service_test.dart` to preserve learned state across path attempts.
- Enhanced `received_image_store_test.dart` to handle concurrent writes and review fixes.
- Implemented `repeater_command_service_test.dart` to validate command response handling.
- Created `store_tolerant_parsing_test.dart` to ensure stores skip malformed records gracefully.
- Cleared untranslated JSON file for localization updates.
This commit is contained in:
Zach committed 2026-09-25 10:01:18 -07:00
1 parent d5f54dfa11
commit d74587c167
105 files changed
+6419 -2072

No files matched your search

+30 -6
View File
@@ -54,6 +54,11 @@ class ByteCountedTextField extends StatelessWidget {
/// If provided, byte limits and counters will use the encoded text length.
final String Function(String)? encoder;
/// Optional byte count above which [softLimitNote] is shown next to the
/// counter (the text is still allowed up to [maxBytes]).
final int? softLimitBytes;
final String? softLimitNote;
const ByteCountedTextField({
super.key,
required this.maxBytes,
@@ -69,6 +74,8 @@ class ByteCountedTextField extends StatelessWidget {
this.errorThreshold = 0.9,
this.hideCounterWhenEmpty = true,
this.encoder,
this.softLimitBytes,
this.softLimitNote,
});
@override
@@ -82,6 +89,10 @@ class ByteCountedTextField extends StatelessWidget {
final usedBytes = utf8.encode(effectiveText).length;
final ratio = maxBytes > 0 ? usedBytes / maxBytes : 0.0;
final showCounter = !(hideCounterWhenEmpty && value.text.isEmpty);
final showSoftLimitNote =
softLimitNote != null &&
softLimitBytes != null &&
usedBytes > softLimitBytes!;
final counterColor = ratio > errorThreshold
? Theme.of(context).colorScheme.error
@@ -122,12 +133,25 @@ class ByteCountedTextField extends StatelessWidget {
opacity: showCounter ? 1 : 0,
child: Padding(
padding: const EdgeInsets.only(top: 4, right: 4),
child: Align(
alignment: Alignment.centerRight,
child: Text(
'$usedBytes / $maxBytes',
style: TextStyle(fontSize: 11, color: counterColor),
),
child: Row(
children: [
Expanded(
child: showSoftLimitNote
? Text(
softLimitNote!,
style: TextStyle(
fontSize: 11,
color: Theme.of(context).colorScheme.tertiary,
),
)
: const SizedBox.shrink(),
),
const SizedBox(width: 8),
Text(
'$usedBytes / $maxBytes',
style: TextStyle(fontSize: 11, color: counterColor),
),
],
),
),
),
+5
View File
@@ -13,6 +13,7 @@ import '../connector/meshcore_protocol.dart';
import '../theme/mesh_theme.dart';
import '../widgets/mesh_ui.dart';
import '../utils/app_logger.dart';
import '../helpers/utf8_length_limiter.dart';
import 'routing_sheet.dart';
class RepeaterLoginDialog extends StatefulWidget {
@@ -351,6 +352,10 @@ class _RepeaterLoginDialogState extends State<RepeaterLoginDialog> {
TextField(
controller: _passwordController,
obscureText: _obscurePassword,
// Firmware stores at most 15 bytes (CommonCLI.h password[16]).
inputFormatters: const [
Utf8LengthLimitingTextInputFormatter(15),
],
decoration: InputDecoration(
labelText: l10n.login_password,
hintText: l10n.login_enterPassword,
+5
View File
@@ -14,6 +14,7 @@ import '../theme/mesh_theme.dart';
import '../widgets/mesh_ui.dart';
import '../utils/app_logger.dart';
import '../helpers/snack_bar_builder.dart';
import '../helpers/utf8_length_limiter.dart';
import 'routing_sheet.dart';
class RoomLoginDialog extends StatefulWidget {
@@ -288,6 +289,10 @@ class _RoomLoginDialogState extends State<RoomLoginDialog> {
TextField(
controller: _passwordController,
obscureText: _obscurePassword,
// Firmware stores at most 15 bytes (CommonCLI.h password[16]).
inputFormatters: const [
Utf8LengthLimitingTextInputFormatter(15),
],
decoration: InputDecoration(
labelText: l10n.login_password,
hintText: l10n.login_enterPassword,
+18 -15
View File
@@ -99,7 +99,10 @@ class _RoutingSheetBodyState extends State<_RoutingSheetBody> {
final override = contact.pathOverride;
final initial = override != null && override > 0
? (contact.pathOverrideBytes ?? Uint8List(0))
: (contact.pathLength > 0 ? contact.path : Uint8List(0));
: (contact.pathLength > 0 &&
contact.pathHashWidth == connector.pathHashByteWidth
? contact.path
: Uint8List(0));
final available = connector.allContacts
.where((c) => c.publicKeyHex != contact.publicKeyHex)
.toList();
@@ -169,7 +172,7 @@ class _RoutingSheetBodyState extends State<_RoutingSheetBody> {
for (var i = 0; i < ranked.length && i < 3; i++) {
if (ranked[i].matchesPathStart(
record.pathBytes,
connector.pathHashByteWidth,
_recordPathHashWidth(record),
)) {
return switch (i) {
0 => _PathQuality.strong,
@@ -252,7 +255,7 @@ class _RoutingSheetBodyState extends State<_RoutingSheetBody> {
return PathHelper.resolvePathNames(
contact.path,
connector.allContacts,
connector.pathHashByteWidth,
contact.pathHashWidth,
);
}
}
@@ -285,21 +288,26 @@ class _RoutingSheetBodyState extends State<_RoutingSheetBody> {
);
}
int _recordPathHashWidth(PathRecord record) =>
Contact.inferPathHashWidth(record.hopCount, record.pathBytes.length);
void _showPathDetail(
BuildContext context,
MeshCoreConnector connector,
Contact contact,
List<int> pathBytes,
PathRecord record,
) {
final l10n = context.l10n;
final pathBytes = record.pathBytes;
final width = _recordPathHashWidth(record);
final formattedPath = PathHelper.splitPathBytes(
pathBytes,
connector.pathHashByteWidth,
width,
).map(PathHelper.formatHopHex).join(',');
final resolvedNames = PathHelper.resolvePathNames(
pathBytes,
connector.allContacts,
connector.pathHashByteWidth,
width,
);
showDialog(
@@ -545,13 +553,13 @@ class _RoutingSheetBodyState extends State<_RoutingSheetBody> {
? PathHelper.resolvePathNames(
record.pathBytes,
connector.allContacts,
connector.pathHashByteWidth,
_recordPathHashWidth(record),
)
: l10n.chat_hopsCount(record.hopCount);
final displayHopCount = hasBytes
? PathHelper.splitPathBytes(
record.pathBytes,
connector.pathHashByteWidth,
_recordPathHashWidth(record),
).length
: record.hopCount;
@@ -570,7 +578,7 @@ class _RoutingSheetBodyState extends State<_RoutingSheetBody> {
behavior: HitTestBehavior.opaque,
onSecondaryTapUp: PlatformInfo.isDesktop && hasBytes
? (_) =>
_showPathDetail(context, connector, contact, record.pathBytes)
_showPathDetail(context, connector, contact, record)
: null,
child: Card(
margin: const EdgeInsets.symmetric(vertical: 4),
@@ -619,12 +627,7 @@ class _RoutingSheetBodyState extends State<_RoutingSheetBody> {
? () => _applyHistoryPath(connector, contact, record)
: null,
onLongPress: hasBytes
? () => _showPathDetail(
context,
connector,
contact,
record.pathBytes,
)
? () => _showPathDetail(context, connector, contact, record)
: null,
),
),