Skip to content

Commit

Permalink
Add dev prefix to test method to bypass 'Demo' gear filters
Browse files Browse the repository at this point in the history
  • Loading branch information
Codel1417 committed Jun 5, 2024
1 parent 88af0cb commit d9fdd19
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion test/Backend/move_lists_test.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions test/testing_utils/gear_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<BaseStatefulDevice> createAndStoreGear(String gearBtName, ProviderContainer ref) async {
Future<BaseStatefulDevice> 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;
Expand All @@ -21,13 +21,13 @@ Future<BaseStatefulDevice> createAndStoreGear(String gearBtName, ProviderContain
return statefulDevice;
}

Future<ProviderContainer> testGearAdd(String name) async {
Future<ProviderContainer> testGearAdd(String name, {String gearMacPrefix = 'DEV'}) async {
final container = ProviderContainer(
overrides: [],
);
expect(container.read(knownDevicesProvider).length, 0);
expect(HiveProxy.getAll<BaseStoredDevice>('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);
Expand Down

0 comments on commit d9fdd19

Please sign in to comment.