connection settings cleanup and mock test added. removed bluetooth implementation
This commit is contained in:
@@ -1,83 +0,0 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import 'package:dmc_app/transport/bluetooth/bluetooth_device_info.dart';
|
||||
import 'package:dmc_app/transport/bluetooth/bluetooth_device_selector.dart';
|
||||
|
||||
void main() {
|
||||
const remembered = BluetoothDeviceInfo(address: '11:11:11:11:11:11', name: 'Alt-Geraet');
|
||||
const mLrs = BluetoothDeviceInfo(address: '22:22:22:22:22:22', name: 'mLRS-a1b2');
|
||||
const other = BluetoothDeviceInfo(address: '33:33:33:33:33:33', name: 'Kopfhoerer');
|
||||
|
||||
test('gemerkte MAC-Adresse hat Vorrang vor mLRS-Praefix (Doku 3.2a)', () {
|
||||
final result = selectBluetoothDevice(
|
||||
bondedDevices: [other, mLrs, remembered],
|
||||
rememberedAddress: remembered.address,
|
||||
);
|
||||
|
||||
expect(result, isA<BluetoothDeviceResolved>());
|
||||
expect((result as BluetoothDeviceResolved).device, remembered);
|
||||
});
|
||||
|
||||
test(
|
||||
'ohne (noch gueltige) gemerkte Adresse gewinnt das erste Geraet mit '
|
||||
'mLRS-Praefix (Doku 3.2b)', () {
|
||||
final result = selectBluetoothDevice(
|
||||
bondedDevices: [other, mLrs],
|
||||
rememberedAddress: null,
|
||||
);
|
||||
|
||||
expect(result, isA<BluetoothDeviceResolved>());
|
||||
expect((result as BluetoothDeviceResolved).device, mLrs);
|
||||
});
|
||||
|
||||
test(
|
||||
'gemerkte Adresse ist nicht mehr gekoppelt -> faellt auf mLRS-Praefix '
|
||||
'zurueck statt zu scheitern', () {
|
||||
final result = selectBluetoothDevice(
|
||||
bondedDevices: [other, mLrs],
|
||||
rememberedAddress: '99:99:99:99:99:99',
|
||||
);
|
||||
|
||||
expect(result, isA<BluetoothDeviceResolved>());
|
||||
expect((result as BluetoothDeviceResolved).device, mLrs);
|
||||
});
|
||||
|
||||
test(
|
||||
'weder gemerkte Adresse noch mLRS-Praefix -> Auswahlliste noetig '
|
||||
'(Doku 3.2c)', () {
|
||||
final result = selectBluetoothDevice(
|
||||
bondedDevices: [other],
|
||||
rememberedAddress: null,
|
||||
);
|
||||
|
||||
expect(result, isA<BluetoothDeviceSelectionRequired>());
|
||||
expect(
|
||||
(result as BluetoothDeviceSelectionRequired).candidates,
|
||||
[other],
|
||||
);
|
||||
});
|
||||
|
||||
test('keine gekoppelten Geraete -> Auswahlliste ist leer, kein Fehler', () {
|
||||
final result = selectBluetoothDevice(
|
||||
bondedDevices: const [],
|
||||
rememberedAddress: null,
|
||||
);
|
||||
|
||||
expect(result, isA<BluetoothDeviceSelectionRequired>());
|
||||
expect((result as BluetoothDeviceSelectionRequired).candidates, isEmpty);
|
||||
});
|
||||
|
||||
test('Praefix-Pruefung ist case-sensitiv wie in der Doku spezifiziert', () {
|
||||
const lowerCase = BluetoothDeviceInfo(
|
||||
address: '44:44:44:44:44:44',
|
||||
name: 'mlrs-nicht-erkannt',
|
||||
);
|
||||
|
||||
final result = selectBluetoothDevice(
|
||||
bondedDevices: [lowerCase],
|
||||
rememberedAddress: null,
|
||||
);
|
||||
|
||||
expect(result, isA<BluetoothDeviceSelectionRequired>());
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user