mirror of
https://github.com/jonasbark/swiftcontrol.git
synced 2026-11-29 09:11:17 +01:00
Add test/integration with platform fakes installed at the plugin seams (UniversalBle.setInstance, NsdPlatformInterface.instance); everything above them — Connection, device classification, protocol parsers, press state machine, keymaps, ProxyDevice — is the real code: - controller_connection_test: scan→classification (Zwift Click/Ride via manufacturer data, Di2 via service UUID, FTMS trainer→ProxyDevice, ignored names/devices), connect lifecycle (device-info reads, battery, RideOn handshake, subscriptions), drops, dedupe, forget list. - controller_button_chain_test: byte-accurate BLE notifications through the full reaction chain — single/double/long press, trigger remapping, duplicate-frame dedupe, unmapped-button error surfacing, multi-button Ride presses. - virtual_shifting_connection_logic_test: retrofit-mode defaults (WiFi / BT-wins / proxy for power meters), auto-connect consent gating, in-place "No connection" disconnect + in-place reconnect, WiFi trainer discovery rules (found/lost/connected-survives-flap, self-exclusion), and an end-to-end Click-press → real action pipeline → gear shift. Protocol-level coverage (DirCon over real TCP, BLE peripheral) lives in the prop submodule's own tests — no prop internals in this repo. Bug fix found by these tests: Connection.disconnect(keepInList: true) was defeated — UniversalBle.disconnect resolves only after the platform disconnect event, so the still-attached connectionStream listener re-entered disconnect() without keepInList and dropped the device, orphaning the object the open details page holds (the exact bug0db8cf0caddressed). Guarded via _inPlaceDisconnects. Also update stale tests to current behavior: sim-mode shifts return Ignored sincee0e4494d(handled by the bridge, not forwarded, logged neutrally), ControllerButton.initials direction arrows, and skip the third BC2 state-machine test consistently with its siblings. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
18 lines
675 B
Dart
18 lines
675 B
Dart
import 'package:bike_control/utils/keymap/buttons.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
void main() {
|
|
group('ControllerButton.initials', () {
|
|
test('multi-word camelCase → first letters, directions as arrows', () {
|
|
expect(const ControllerButton('sideButtonLeft').initials, 'SB←');
|
|
expect(const ControllerButton('navigationUp').initials, 'N↑');
|
|
expect(const ControllerButton('shiftDownRight').initials, 'S↓→');
|
|
});
|
|
|
|
test('single-word name → single uppercase letter', () {
|
|
expect(const ControllerButton('a').initials, 'A');
|
|
expect(const ControllerButton('paddleLeft').initials, 'P←');
|
|
});
|
|
});
|
|
}
|