Skip to content

Commit

Permalink
initial runAction test
Browse files Browse the repository at this point in the history
  • Loading branch information
Codel1417 committed Jun 5, 2024
1 parent 9f1565e commit a1f6b9b
Showing 1 changed file with 51 additions and 1 deletion.
52 changes: 51 additions & 1 deletion test/Backend/move_lists_test.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import 'package:flutter_test/flutter_test.dart' as flTest;
import 'package:flutter_test/flutter_test.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';
import 'package:tail_app/Backend/Definitions/Action/base_action.dart';
import 'package:tail_app/Backend/Definitions/Device/device_definition.dart';
import 'package:tail_app/Backend/LoggingWrappers.dart';
import 'package:tail_app/Backend/move_lists.dart';
import 'package:tail_app/Backend/sensors.dart';
import 'package:tail_app/main.dart';
import 'package:test/test.dart';

import '../testing_utils/gear_utils.dart';
import '../testing_utils/hive_utils.dart';
Expand Down Expand Up @@ -101,5 +104,52 @@ void main() {
moveList.moves.add(move);
expect(moveList.moves.length, 1);
});
group('runAction', () {
//TODO: Mock CommandQueue;
setUpAll(() {
initPlausible(enabled: false);
});
test('run Ear Move', () async {
ProviderContainer container = await testGearAdd('EG2');
expect(container.read(knownDevicesProvider).values.length, 1);
expect(container.read(knownDevicesProvider).values.first.baseDeviceDefinition.btName, 'EG2');
BaseAction? baseAction = container.read(getActionFromUUIDProvider("9a6be63e-36f5-4f50-88b6-7adf2680aa5c"));
expect(baseAction != null, true);
BaseStatefulDevice baseStatefulDevice = container.read(knownDevicesProvider).values.first;
runAction(baseAction!, baseStatefulDevice);
});
test('run Tail Move', () async {
ProviderContainer container = await testGearAdd('MiTail');
expect(container.read(knownDevicesProvider).values.length, 1);
expect(container.read(knownDevicesProvider).values.first.baseDeviceDefinition.btName, 'MiTail');
BaseAction? baseAction = container.read(getActionFromUUIDProvider("c53e980e-899e-4148-a13e-f57a8f9707f4"));
expect(baseAction != null, true);
BaseStatefulDevice baseStatefulDevice = container.read(knownDevicesProvider).values.first;
runAction(baseAction!, baseStatefulDevice);
});

test('run Ear Custom Move', () async {
ProviderContainer container = await testGearAdd('EG2');
expect(container.read(knownDevicesProvider).values.length, 1);
expect(container.read(knownDevicesProvider).values.first.baseDeviceDefinition.btName, 'EG2');
MoveList moveList = MoveList(name: 'Test', uuid: 'test', deviceCategory: DeviceType.values);
moveList.moves.add(Move.move(leftServo: 50, rightServo: 50));
moveList.moves.add(Move.delay(50));
moveList.moves.add(Move.move(leftServo: 50, rightServo: 50));
BaseStatefulDevice baseStatefulDevice = container.read(knownDevicesProvider).values.first;
runAction(moveList, baseStatefulDevice);
});
test('run Tail Custom Move', () async {
ProviderContainer container = await testGearAdd('MiTail');
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);
moveList.moves.add(Move.move(leftServo: 50, rightServo: 50));
moveList.moves.add(Move.delay(50));
moveList.moves.add(Move.move(leftServo: 50, rightServo: 50));
BaseStatefulDevice baseStatefulDevice = container.read(knownDevicesProvider).values.first;
runAction(moveList, baseStatefulDevice);
});
});
});
}

0 comments on commit a1f6b9b

Please sign in to comment.