fix(ads): force test ad units in release during closed testing

Closed-testing human testers cannot be registered as AdMob test
devices, so release builds serving real ad units risked invalid
traffic against an AdMob account that currently earns essentially
nothing. Add usarAnunciosDePruebaEnRelease, a single boolean switch
defaulted to true, that keeps bannerAdUnitId/interstitialAdUnitId on
Google's official test ids even in kReleaseMode. Flipping it to false
is the only change needed to go live. AndroidManifest's AdMob
application id is untouched, as it only initializes the SDK.
This commit is contained in:
2026-08-28 19:49:12 +02:00
parent e9f47d47c2
commit 2e15d05431
2 changed files with 50 additions and 5 deletions
@@ -161,6 +161,36 @@ void main() {
});
});
group('usarAnunciosDePruebaEnRelease — interruptor de fase de pruebas', () {
test('mientras esta en true, bannerAdUnitId e interstitialAdUnitId son los '
'ids oficiales de prueba de Google', () {
expect(usarAnunciosDePruebaEnRelease, isTrue);
expect(bannerAdUnitId, equals('ca-app-pub-3940256099942544/6300978111'));
expect(
interstitialAdUnitId,
equals('ca-app-pub-3940256099942544/1033173712'),
);
});
test('los ids reales siguen presentes como constantes en el archivo (no se '
'pueden perder en un futuro edit)', () {
final source =
File('lib/servicios/servicio_anuncios.dart').readAsStringSync();
expect(
source.contains("'ca-app-pub-6038935671414339/5658618378'"),
isTrue,
reason: 'el id real del banner debe seguir presente en el archivo',
);
expect(
source.contains("'ca-app-pub-6038935671414339/4189478248'"),
isTrue,
reason:
'el id real del interstitial debe seguir presente en el '
'archivo',
);
});
});
group('debeMostrarBanner', () {
test('free: true', () {
final servicio = construir(