Adds a permanent, non-consumable premium unlock (EstadoEntitlement + PuertoCompras/ServicioComprasPlayBilling) that removes ads and unlocks alarm vacations, alarms past a 5-alarm free cap, recording start, and full Android Auto browsing. The phone equalizer stays free for everyone. - Entitlement is prefs-backed (compra_premium_v1), fail-open, and resolvable headlessly via esPremiumPersistido() for the Android Auto audio handler, which registers before runApp. - Android Auto reduced mode keeps the real root folder labels for free users; browsing into any of them (and playFromMediaId/playFromSearch/ skipToNext/skipToPrevious) is blocked at the getChildren/servicio_audio choke points, with a locked "Función Premium" item as the backstop. Current-station play/pause/stop stays untouched. A free -> premium transition actively invalidates the head unit's cached browse tree. - Ads (top banner + capped interstitial before adding a station or an alarm) are gated behind entitlement via ServicioAnuncios, using official Google test ad unit IDs pending AdMob provisioning. - Alarm cap UX shows an explanatory message with a secondary unlock action rather than a bare paywall jump; existing data is grandfathered. - 4 new localization keys translated across all 13 supported locales. Co-located tests use strict TDD (RED test before implementation) for every new pure-logic unit; full existing suite passes unchanged.
57 lines
1.8 KiB
Dart
57 lines
1.8 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:in_app_purchase/in_app_purchase.dart';
|
|
import 'package:pluriwave/servicios/servicio_compras.dart';
|
|
|
|
/// Pure port-boundary tests (Design ADR-2 "keeps Strict TDD viable with zero
|
|
/// plugin channels in unit tests"): [eventoDesdeEstadoCompra] is the ONLY
|
|
/// piece of `ServicioComprasPlayBilling` that is unit-testable without a
|
|
/// real `in_app_purchase` platform channel — [ServicioComprasPlayBilling]
|
|
/// itself is the sole call site (Design ADR-2), exercised instead through
|
|
/// `EstadoEntitlement` + a fake `PuertoCompras`
|
|
/// (`estado_entitlement_test.dart`).
|
|
void main() {
|
|
group('eventoDesdeEstadoCompra', () {
|
|
test('purchased -> comprada', () {
|
|
expect(
|
|
eventoDesdeEstadoCompra(PurchaseStatus.purchased).tipo,
|
|
TipoEventoCompra.comprada,
|
|
);
|
|
});
|
|
|
|
test('restored -> restaurada', () {
|
|
expect(
|
|
eventoDesdeEstadoCompra(PurchaseStatus.restored).tipo,
|
|
TipoEventoCompra.restaurada,
|
|
);
|
|
});
|
|
|
|
test('canceled -> cancelada', () {
|
|
expect(
|
|
eventoDesdeEstadoCompra(PurchaseStatus.canceled).tipo,
|
|
TipoEventoCompra.cancelada,
|
|
);
|
|
});
|
|
|
|
test('pending -> pendiente', () {
|
|
expect(
|
|
eventoDesdeEstadoCompra(PurchaseStatus.pending).tipo,
|
|
TipoEventoCompra.pendiente,
|
|
);
|
|
});
|
|
|
|
test('error conserva el mensaje diagnostico', () {
|
|
final evento = eventoDesdeEstadoCompra(
|
|
PurchaseStatus.error,
|
|
mensaje: 'BILLING_UNAVAILABLE',
|
|
);
|
|
|
|
expect(evento.tipo, TipoEventoCompra.error);
|
|
expect(evento.mensaje, 'BILLING_UNAVAILABLE');
|
|
});
|
|
});
|
|
|
|
test('idProducto es el identificador unico no-consumible', () {
|
|
expect(ServicioComprasPlayBilling.idProducto, 'pluriwave_premium');
|
|
});
|
|
}
|