mirror of
https://github.com/jonasbark/swiftcontrol.git
synced 2026-02-18 00:17:40 +01:00
unit test adjustments
This commit is contained in:
@@ -176,11 +176,11 @@ abstract class BaseActions {
|
||||
class StubActions extends BaseActions {
|
||||
StubActions({super.supportedModes = const []});
|
||||
|
||||
final List<ControllerButton> performedActions = [];
|
||||
final List<(ControllerButton button, bool isDown, bool isUp)> performedActions = [];
|
||||
|
||||
@override
|
||||
Future<ActionResult> performAction(ControllerButton button, {bool isKeyDown = true, bool isKeyUp = false}) async {
|
||||
performedActions.add(button);
|
||||
performedActions.add((button, isKeyDown, isKeyUp));
|
||||
return Future.value(Ignored('${button.name.splitByUpperCase()} clicked'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:bike_control/bluetooth/devices/shimano/shimano_di2.dart';
|
||||
import 'package:bike_control/utils/actions/base_actions.dart';
|
||||
import 'package:bike_control/utils/core.dart';
|
||||
import 'package:bike_control/utils/keymap/apps/openbikecontrol.dart';
|
||||
import 'package:bike_control/utils/keymap/buttons.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:universal_ble/universal_ble.dart';
|
||||
|
||||
Future<void> main() async {
|
||||
@@ -38,5 +39,37 @@ Future<void> main() async {
|
||||
);
|
||||
expect(stubActions.performedActions.isEmpty, false);
|
||||
});
|
||||
|
||||
test('should transmit all events', () async {
|
||||
final instance = ShimanoDi2(BleDevice(name: 'Di2', deviceId: ''));
|
||||
await instance.processCharacteristic(
|
||||
ShimanoDi2Constants.D_FLY_CHANNEL_UUID,
|
||||
Uint8List.fromList([0x21, 0x13, 0xF0, 0xF0]),
|
||||
);
|
||||
|
||||
expect(stubActions.performedActions.isEmpty, true);
|
||||
|
||||
await instance.processCharacteristic(
|
||||
ShimanoDi2Constants.D_FLY_CHANNEL_UUID,
|
||||
Uint8List.fromList([0x21, 0x13, 0xF0, 0xF0]),
|
||||
);
|
||||
expect(stubActions.performedActions.isEmpty, true);
|
||||
|
||||
await instance.processCharacteristic(
|
||||
ShimanoDi2Constants.D_FLY_CHANNEL_UUID,
|
||||
Uint8List.fromList([0x21, 0x14, 0xF0, 0xF0]),
|
||||
);
|
||||
final button = ControllerButton('D-Fly Channel 1');
|
||||
expect(stubActions.performedActions, equals([(button, true, false), (button, false, true)]));
|
||||
|
||||
await instance.processCharacteristic(
|
||||
ShimanoDi2Constants.D_FLY_CHANNEL_UUID,
|
||||
Uint8List.fromList([0x21, 0x15, 0xF0, 0xF0]),
|
||||
);
|
||||
expect(
|
||||
stubActions.performedActions,
|
||||
equals([(button, true, false), (button, false, true), (button, true, false), (button, false, true)]),
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user