From 6d2b690c92272278158011d8618f13f1d18a8428 Mon Sep 17 00:00:00 2001 From: Codel1417 Date: Wed, 5 Jun 2024 14:31:03 -0400 Subject: [PATCH] Test setup changes --- test/testing_utils/bluetooth_test_utils.dart | 26 ++++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/test/testing_utils/bluetooth_test_utils.dart b/test/testing_utils/bluetooth_test_utils.dart index e0a3531c..99acfc4e 100644 --- a/test/testing_utils/bluetooth_test_utils.dart +++ b/test/testing_utils/bluetooth_test_utils.dart @@ -9,23 +9,23 @@ import 'package:tail_app/Backend/Bluetooth/bluetooth_utils.dart'; import 'bluetooth_test_utils.mocks.dart'; void setupBTMock(String btName, String btMac) { - flutterBluePlus = MockFlutterBluePlusMockable(); - - when(flutterBluePlus.isSupported).thenAnswer((_) async => true); - when(flutterBluePlus.adapterState).thenAnswer((_) => Stream.fromIterable([BluetoothAdapterState.on])); - when(flutterBluePlus.isScanning).thenAnswer((_) => Stream.fromIterable([false])); - when(flutterBluePlus.isScanningNow).thenAnswer((_) => true); - when(flutterBluePlus.isSupported).thenAnswer((_) async => true); - when(flutterBluePlus.isSupported).thenAnswer((_) async => true); - when(flutterBluePlus.connectedDevices).thenAnswer((_) => [BluetoothDevice(remoteId: DeviceIdentifier(btMac))]); - when(flutterBluePlus.scanResults).thenAnswer((_) => + MockFlutterBluePlusMockable flutterBluePlusMock = MockFlutterBluePlusMockable(); + flutterBluePlus = flutterBluePlusMock; + when(flutterBluePlusMock.isSupported).thenAnswer((_) async => true); + when(flutterBluePlusMock.adapterState).thenAnswer((_) => Stream.fromIterable([BluetoothAdapterState.on])); + when(flutterBluePlusMock.isScanning).thenAnswer((_) => Stream.fromIterable([false])); + when(flutterBluePlusMock.isScanningNow).thenAnswer((_) => true); + when(flutterBluePlusMock.isSupported).thenAnswer((_) async => true); + when(flutterBluePlusMock.isSupported).thenAnswer((_) async => true); + when(flutterBluePlusMock.connectedDevices).thenAnswer((_) => [BluetoothDevice(remoteId: DeviceIdentifier(btMac))]); + when(flutterBluePlusMock.scanResults).thenAnswer((_) => Stream.value([ScanResult(rssi: 50, advertisementData: AdvertisementData(advName: btName, txPowerLevel: null, appearance: null, connectable: true, manufacturerData: {}, serviceData: {}, serviceUuids: []), device: BluetoothDevice(remoteId: DeviceIdentifier(btMac)), timeStamp: DateTime.now())])); - when(flutterBluePlus.onScanResults).thenAnswer((_) => + when(flutterBluePlusMock.onScanResults).thenAnswer((_) => Stream.value([ScanResult(rssi: 50, advertisementData: AdvertisementData(advName: btName, txPowerLevel: null, appearance: null, connectable: true, manufacturerData: {}, serviceData: {}, serviceUuids: []), device: BluetoothDevice(remoteId: DeviceIdentifier(btMac)), timeStamp: DateTime.now())])); - when(flutterBluePlus.setLogLevel(LogLevel.warning, color: true)).thenReturn(Future(() {})); + when(flutterBluePlusMock.setLogLevel(any, color: any)).thenReturn(Future(() {})); BluetoothEvents bluetoothEvents = MockBluetoothEvents(); - when(flutterBluePlus.events).thenAnswer((_) => bluetoothEvents); + when(flutterBluePlusMock.events).thenAnswer((_) => bluetoothEvents); when(bluetoothEvents.onMtuChanged).thenAnswer((_) => Stream.fromIterable([OnMtuChangedEvent(BmMtuChangedResponse(mtu: 50, success: true, remoteId: DeviceIdentifier(btMac)))])); when(bluetoothEvents.onReadRssi).thenAnswer((_) => Stream.fromIterable([OnReadRssiEvent(BmReadRssiResult(rssi: 50, success: true, remoteId: DeviceIdentifier(btMac), errorCode: 0, errorString: ''))])); when(bluetoothEvents.onServicesReset).thenAnswer((_) => Stream.fromIterable([OnServicesResetEvent(BmBluetoothDevice(remoteId: DeviceIdentifier(btMac), platformName: btName))]));