From d9fdd1944cabe27687520e5140abc09a2d565453 Mon Sep 17 00:00:00 2001 From: Codel1417 Date: Wed, 5 Jun 2024 13:17:45 -0400 Subject: [PATCH] Add dev prefix to test method to bypass 'Demo' gear filters --- pubspec.lock | 2 +- test/Backend/move_lists_test.dart | 3 ++- test/testing_utils/gear_utils.dart | 8 ++++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/pubspec.lock b/pubspec.lock index e4e1387f..cf09229f 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -444,7 +444,7 @@ packages: description: path: feedback_sentry ref: HEAD - resolved-ref: b9b78756085e0326eb745d0ba5d2e7c1f5466fe5 + resolved-ref: e4f8a8f2c06b856c6ef77f68d8bb13149438fdd8 url: "https://github.com/ueman/feedback" source: git version: "3.0.1" diff --git a/test/Backend/move_lists_test.dart b/test/Backend/move_lists_test.dart index 715dd50c..364ff0d9 100644 --- a/test/Backend/move_lists_test.dart +++ b/test/Backend/move_lists_test.dart @@ -1,4 +1,5 @@ import 'package:flutter_test/flutter_test.dart' as flTest; +import 'package:mockito/annotations.dart'; import 'package:riverpod/src/framework.dart'; import 'package:tail_app/Backend/Bluetooth/bluetooth_manager.dart'; import 'package:tail_app/Backend/Bluetooth/bluetooth_message.dart'; @@ -141,7 +142,7 @@ void main() { runAction(moveList, baseStatefulDevice); }); test('run Tail Custom Move', () async { - ProviderContainer container = await testGearAdd('MiTail'); + ProviderContainer container = await testGearAdd('MiTail', gearMacPrefix: 'test'); expect(container.read(knownDevicesProvider).values.length, 1); expect(container.read(knownDevicesProvider).values.first.baseDeviceDefinition.btName, 'MiTail'); MoveList moveList = MoveList(name: 'Test', uuid: 'test', deviceCategory: DeviceType.values); diff --git a/test/testing_utils/gear_utils.dart b/test/testing_utils/gear_utils.dart index 0dad0dbd..1633b5ae 100644 --- a/test/testing_utils/gear_utils.dart +++ b/test/testing_utils/gear_utils.dart @@ -6,11 +6,11 @@ import 'package:tail_app/Backend/Definitions/Device/device_definition.dart'; import 'package:tail_app/Backend/LoggingWrappers.dart'; import 'package:tail_app/Backend/device_registry.dart'; -Future createAndStoreGear(String gearBtName, ProviderContainer ref) async { +Future createAndStoreGear(String gearBtName, ProviderContainer ref, {String gearMacPrefix = 'Dev'}) async { BaseDeviceDefinition baseDeviceDefinition = DeviceRegistry.getByName(gearBtName)!; BaseStoredDevice baseStoredDevice; BaseStatefulDevice statefulDevice; - baseStoredDevice = BaseStoredDevice(baseDeviceDefinition.uuid, "DEV${baseDeviceDefinition.deviceType.name}", baseDeviceDefinition.deviceType.color(ref: ref).value); + baseStoredDevice = BaseStoredDevice(baseDeviceDefinition.uuid, "$gearMacPrefix${baseDeviceDefinition.deviceType.name}", baseDeviceDefinition.deviceType.color(ref: ref).value); baseStoredDevice.name = getNameFromBTName(baseDeviceDefinition.btName); statefulDevice = BaseStatefulDevice(baseDeviceDefinition, baseStoredDevice); statefulDevice.deviceConnectionState.value = ConnectivityState.connected; @@ -21,13 +21,13 @@ Future createAndStoreGear(String gearBtName, ProviderContain return statefulDevice; } -Future testGearAdd(String name) async { +Future testGearAdd(String name, {String gearMacPrefix = 'DEV'}) async { final container = ProviderContainer( overrides: [], ); expect(container.read(knownDevicesProvider).length, 0); expect(HiveProxy.getAll('devices').length, 0); - BaseStatefulDevice baseStatefulDevice = await createAndStoreGear(name, container); + BaseStatefulDevice baseStatefulDevice = await createAndStoreGear(name, container, gearMacPrefix: gearMacPrefix); expect(baseStatefulDevice.baseDeviceDefinition.btName, name); expect(container.read(knownDevicesProvider).length, 1); expect(container.read(knownDevicesProvider).values.first, baseStatefulDevice);