Merge remote-tracking branch 'origin/dev' into pr-593
# Conflicts: # lib/models/app_settings.dart # lib/screens/channel_chat_screen.dart # lib/screens/chat_screen.dart # untranslated.json
This commit is contained in:
commit
7e7e7a48db
87 files changed
+4822
-882
No files matched your search
@@ -0,0 +1,37 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:meshcore_open/models/app_settings.dart';
|
||||
|
||||
void main() {
|
||||
test('channel notification modes round-trip by name', () {
|
||||
final settings = AppSettings(
|
||||
channelNotificationModes: {
|
||||
'a': ChannelNotificationMode.mentionsOnly,
|
||||
'b': ChannelNotificationMode.muted,
|
||||
},
|
||||
);
|
||||
final json = settings.toJson();
|
||||
expect(json['channel_notification_modes'], {
|
||||
'a': 'mentionsOnly',
|
||||
'b': 'muted',
|
||||
});
|
||||
expect(json['muted_channels'], ['b']);
|
||||
expect(
|
||||
AppSettings.fromJson(json).channelNotificationModes,
|
||||
settings.channelNotificationModes,
|
||||
);
|
||||
});
|
||||
|
||||
test('invalid channel notification mode entries are skipped', () {
|
||||
final settings = AppSettings.fromJson({
|
||||
'channel_notification_modes': {
|
||||
'ok': 'muted',
|
||||
'unknown': 'loud',
|
||||
'int': 2,
|
||||
'null': null,
|
||||
},
|
||||
});
|
||||
expect(settings.channelNotificationModes, {
|
||||
'ok': ChannelNotificationMode.muted,
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:meshcore_open/connector/meshcore_protocol.dart';
|
||||
import 'package:meshcore_open/models/contact.dart';
|
||||
|
||||
Contact _contact(List<int> key) => Contact(
|
||||
publicKey: Uint8List.fromList(key),
|
||||
name: 'Node',
|
||||
type: advTypeChat,
|
||||
pathLength: -1,
|
||||
path: Uint8List(0),
|
||||
lastSeen: DateTime.fromMillisecondsSinceEpoch(0),
|
||||
);
|
||||
|
||||
void main() {
|
||||
final contact = _contact([0xA3, 0x0F, 0xB2, 0x44]);
|
||||
|
||||
test('formats the first pathHashByteWidth bytes as uppercase hex', () {
|
||||
expect(contact.publicKeyPrefixHex(1), 'A3');
|
||||
expect(contact.publicKeyPrefixHex(2), 'A30F');
|
||||
expect(contact.publicKeyPrefixHex(3), 'A30FB2');
|
||||
});
|
||||
|
||||
test('clamps width to the supported 1-3 range', () {
|
||||
expect(contact.publicKeyPrefixHex(0), 'A3');
|
||||
expect(contact.publicKeyPrefixHex(4), 'A30FB2');
|
||||
});
|
||||
|
||||
test('handles keys shorter than the width', () {
|
||||
expect(_contact([0x01]).publicKeyPrefixHex(3), '01');
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:latlong2/latlong.dart';
|
||||
import 'package:meshcore_open/models/map_path_trace_draft.dart';
|
||||
import 'package:meshcore_open/services/ui_view_state_service.dart';
|
||||
|
||||
void main() {
|
||||
test('draft survives on the shared view state service', () {
|
||||
final service = UiViewStateService();
|
||||
final draft = service.mapPathTrace
|
||||
..active = true
|
||||
..returnPath = false;
|
||||
draft.pathBytes.addAll([0xAB, 0xCD]);
|
||||
draft.points.add(const LatLng(1, 2));
|
||||
|
||||
expect(identical(service.mapPathTrace, draft), isTrue);
|
||||
expect(service.mapPathTrace.hasHops, isTrue);
|
||||
expect(service.mapPathTrace.returnPath, isFalse);
|
||||
});
|
||||
|
||||
test('clear drops hops and the last result but keeps the mode', () {
|
||||
final draft = MapPathTraceDraft()
|
||||
..returnPath = false
|
||||
..lastResultFrame = Uint8List.fromList([1, 2, 3]);
|
||||
draft.pathBytes.add(0xAB);
|
||||
draft.hopWidths.add(1);
|
||||
draft.points.add(const LatLng(1, 2));
|
||||
|
||||
draft.clear();
|
||||
|
||||
expect(draft.hasHops, isFalse);
|
||||
expect(draft.hopWidths, isEmpty);
|
||||
expect(draft.points, isEmpty);
|
||||
expect(draft.lastResultFrame, isNull);
|
||||
expect(draft.returnPath, isFalse);
|
||||
});
|
||||
|
||||
test('belongsTo matches only the radio it was built on', () {
|
||||
final draft = MapPathTraceDraft();
|
||||
expect(draft.belongsTo(Uint8List.fromList([1, 2])), isTrue);
|
||||
draft.radioKey = Uint8List.fromList([1, 2]);
|
||||
expect(draft.belongsTo(Uint8List.fromList([1, 2])), isTrue);
|
||||
expect(draft.belongsTo(Uint8List.fromList([3, 4])), isFalse);
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user