Merge upstream/dev: repeater settings from a spec list (#614)
Conflict in repeater_settings_screen.dart: upstream #614 made the fetch-on-open of the settings screen opt-in (autoFetchRepeaterSettings, off by default) - what our kFetchRemoteOnOpen did there. Take upstream's setting so its toggle works; kFetchRemoteOnOpen stays for status, telemetry and neighbours. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
e8ea12c1c9
48 files changed
+4165
-3824
No files matched your search
@@ -0,0 +1,53 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:meshcore_open/models/repeater_setting_spec.dart';
|
||||
|
||||
void main() {
|
||||
test('every spec is well formed', () {
|
||||
final keys = repeaterSettingSpecs.map((s) => s.key).toList();
|
||||
expect(keys.toSet().length, keys.length, reason: 'duplicate keys');
|
||||
for (final spec in repeaterSettingSpecs) {
|
||||
switch (spec.input) {
|
||||
case RepeaterSettingInput.slider:
|
||||
expect(spec.min, isNotNull, reason: spec.key);
|
||||
expect(spec.max, isNotNull, reason: spec.key);
|
||||
expect(spec.min! < spec.max!, isTrue, reason: spec.key);
|
||||
case RepeaterSettingInput.choice:
|
||||
expect(spec.choices, isNotEmpty, reason: spec.key);
|
||||
case RepeaterSettingInput.number:
|
||||
expect(
|
||||
spec.min != null && spec.max != null,
|
||||
isTrue,
|
||||
reason: spec.key,
|
||||
);
|
||||
case RepeaterSettingInput.toggle:
|
||||
case RepeaterSettingInput.text:
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
group('extra.sf', () {
|
||||
final spec = repeaterSettingSpecsByKey['extra.sf']!;
|
||||
|
||||
test('reads the prefix-less reply', () {
|
||||
expect(spec.parseRawReply!('9,10'), '9,10');
|
||||
expect(spec.parseRawReply!('No extra SF configured'), '');
|
||||
// Firmware built without LR2021 support.
|
||||
expect(spec.parseRawReply!('unknown config: extra.sf'), isNull);
|
||||
});
|
||||
|
||||
test('accepts up to three spreading factors from 5 to 12', () {
|
||||
expect(spec.validate!(''), isTrue);
|
||||
expect(spec.validate!('9, 10'), isTrue);
|
||||
expect(spec.validate!('5,6,7,8'), isFalse);
|
||||
expect(spec.validate!('13'), isFalse);
|
||||
expect(spec.encode!('9, 10'), '9,10');
|
||||
});
|
||||
});
|
||||
|
||||
test('owner info round-trips newlines through the firmware form', () {
|
||||
final spec = repeaterSettingSpecsByKey['owner.info']!;
|
||||
expect(spec.encode!('a\nb'), 'a|b');
|
||||
expect(spec.decode!('a|b'), 'a\nb');
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user