fix(devices): cache platform device names, dedupe placeholder ids, purge collided EQ entries
Dart half of bt-device-identity. EstadoEcualizador now caches each device's platform-reported name in memory so the settings screen shows the device's own Bluetooth name instead of its raw id when no custom rename exists, and skips auto-creating preset entries for the composite-placeholder sentinel. Enabling multi-device EQ triggers the Bluetooth permission request through the new channel contract. A flag-guarded one-time migration purges only entries keyed by the exact literal placeholder id from the three per-device preference maps, since those collided entries cannot be attributed to a device. Work unit 2/2 of bt-device-identity (Dart state + migration).
This commit is contained in:
@@ -37,6 +37,16 @@ void main() {
|
||||
});
|
||||
}
|
||||
|
||||
void stubRequestBluetoothConnect(bool? response) {
|
||||
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
|
||||
.setMockMethodCallHandler(const MethodChannel(methodChannelName), (
|
||||
call,
|
||||
) async {
|
||||
if (call.method == 'requestBluetoothConnect') return response;
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
test('obtenerDispositivoActual maps builtin_speaker (type=2)', () async {
|
||||
stubGetActiveDevice({
|
||||
'id': 'builtin_speaker',
|
||||
@@ -105,5 +115,36 @@ void main() {
|
||||
test('onDispositivoCambiado is a broadcast stream', () {
|
||||
expect(servicio.onDispositivoCambiado.isBroadcast, isTrue);
|
||||
});
|
||||
|
||||
// ── bt-device-identity Phase 2: permission contract ──────────────────────
|
||||
|
||||
test(
|
||||
'solicitarPermisoBluetooth invokes requestBluetoothConnect and '
|
||||
'returns true when granted',
|
||||
() async {
|
||||
stubRequestBluetoothConnect(true);
|
||||
final granted = await servicio.solicitarPermisoBluetooth();
|
||||
expect(granted, isTrue);
|
||||
},
|
||||
);
|
||||
|
||||
test(
|
||||
'solicitarPermisoBluetooth returns false when the platform denies',
|
||||
() async {
|
||||
stubRequestBluetoothConnect(false);
|
||||
final granted = await servicio.solicitarPermisoBluetooth();
|
||||
expect(granted, isFalse);
|
||||
},
|
||||
);
|
||||
|
||||
test(
|
||||
'solicitarPermisoBluetooth returns false when the platform channel '
|
||||
'returns null',
|
||||
() async {
|
||||
stubRequestBluetoothConnect(null);
|
||||
final granted = await servicio.solicitarPermisoBluetooth();
|
||||
expect(granted, isFalse);
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user