FakeAdSdk class
A fully controllable AdSdk test double.
- Every
load*call records its arguments and returns a fresh fake handle (also kept in the per-format list, e.g. interstitials) that the test can drive: FakeFullScreenAdHandle.simulateDismissed, FakeFullScreenAdHandle.simulateReward, … - Failure knobs (nextLoadError, alwaysLoadError, consentUpdateError, consentFormError) make the corresponding calls throw.
- Consent state is plain mutable fields (canRequestAdsResult, consentStatus, …).
- emitAppForeground drives appForegroundEvents.
Event streams are synchronous broadcast streams: events are delivered inline to already-subscribed listeners and dropped otherwise — subscribe before driving.
- Implemented types
Constructors
Properties
- adInspectorCalls ↔ int
-
Number of openAdInspector calls.
getter/setter pair
- alwaysLoadError ↔ AdFlowError?
-
While set, every
load*call throws this.getter/setter pair -
appForegroundEvents
→ Stream<
AppForegroundEvent> -
Emits every time the app returns to the foreground (warm start).
no setteroverride
-
appOpens
→ List<
FakeFullScreenAdHandle> -
Fake handles created by loadAppOpen, in order.
final
- attRequestResult ↔ AttStatus
-
Value requestTrackingAuthorization resolves to (the post-prompt
status). The call also updates attStatus to this, mirroring the real
SDK transitioning out of AttStatus.notDetermined.
getter/setter pair
- attStatus ↔ AttStatus
-
Value returned by getTrackingAuthorizationStatus (the current ATT
status). Defaults to AttStatus.notSupported so tests that do not
exercise ATT behave as if off iOS.
getter/setter pair
-
Whether loaded fake banners report themselves collapsible.
getter/setter pair
-
Fake handles created by loadBanner, in order.
final
-
Default size given to loaded fake banners.
getter/setter pair
-
Every BannerLoadSpec passed to loadBanner, in order.
final
- canRequestAdsError ↔ AdFlowError?
-
If set, canRequestAds throws this instead of returning — models the
production gateway's final
canRequestAds()(which is outside its try/catch) failing, so a background_startcan reject.getter/setter pair - canRequestAdsResult ↔ bool
-
Value returned by canRequestAds.
getter/setter pair
- consentFormAvailable ↔ bool
-
Value returned by isConsentFormAvailable.
getter/setter pair
- consentFormError ↔ AdFlowError?
-
If set, loadAndShowConsentFormIfRequired throws this.
getter/setter pair
- consentStatus ↔ AdConsentStatus
-
Value returned by getConsentStatus.
getter/setter pair
-
consentUpdateCalls
→ List<
ConsentUpdateCall> -
Every consent info update request, in order.
final
- consentUpdateError ↔ AdFlowError?
-
If set, requestConsentInfoUpdate throws this.
getter/setter pair
-
consentUpdateHold
↔ Completer<
void> ? -
If set, requestConsentInfoUpdate awaits this before completing —
leave it incomplete to simulate a hanging network call.
getter/setter pair
- disableMediationInitializationCalls ↔ int
-
Number of disableMediationInitialization calls.
getter/setter pair
- enforceConsentGate ↔ bool
-
When true, any
load*while canRequestAdsResult is false throws a StateError — a tripwire for the "consent gates every load" invariant. Off by default so seam-level tests can exercise loads in isolation.getter/setter pair -
fullScreenRequests
→ List<
AdRequestOptions> -
The AdRequestOptions of every full-screen load (interstitial,
rewarded, rewarded interstitial, app open), in order.
final
- hasForegroundListener → bool
-
Whether anyone is currently subscribed to appForegroundEvents — lets a
test detect an app-open manager that (re)subscribed, e.g. after a
dispose-during-startup.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- initializeCalls ↔ int
-
Number of initialize calls.
getter/setter pair
-
initializeHold
↔ Completer<
void> ? -
If set, initialize awaits this before completing — leave it
incomplete to simulate a native SDK init call that never calls back.
getter/setter pair
- inspectorResult ↔ AdInspectorResult
-
Result returned by openAdInspector.
getter/setter pair
-
interstitials
→ List<
FakeFullScreenAdHandle> -
Fake handles created by loadInterstitial, in order.
final
- loadAndShowConsentFormCalls ↔ int
-
Number of loadAndShowConsentFormIfRequired calls.
getter/setter pair
-
loadHold
↔ Completer<
void> ? -
If set, every
load*call awaits this before proceeding — leave it incomplete to keep a load in flight (e.g. to dispose mid-load).getter/setter pair -
loadLog
→ List<
String> -
Every load in order, as
'<format>:<adUnitId>'entries.final - mediationInitDisabledBeforeInitialize ↔ bool?
-
Whether disableMediationInitialization was called before the first
initialize — the only ordering in which the real plugin honours it.
getter/setter pair
-
natives
→ List<
FakeNativeHandle> -
Fake handles created by loadNative, in order.
final
-
nativeSpecs
→ List<
NativeLoadSpec> -
Every NativeLoadSpec passed to loadNative, in order.
final
- nextLoadError ↔ AdFlowError?
-
If set, the next
load*call throws this and the knob clears.getter/setter pair - onConsentFormShown ↔ void Function()?
-
Invoked by loadAndShowConsentFormIfRequired (when it does not throw);
use it to flip canRequestAdsResult/consentStatus the way a real
form dismissal would.
getter/setter pair
- onConsentInfoUpdate ↔ void Function()?
-
Invoked by requestConsentInfoUpdate when it does NOT throw. Use it to
flip canRequestAdsResult the way a real UMP info update does once the
network is reachable — e.g. to model an offline launch (set
consentUpdateError, leave canRequestAdsResult false) that later
recovers (clear the error, set this to open the gate).
getter/setter pair
- onPrivacyOptionsFormShown ↔ void Function()?
-
Invoked when showPrivacyOptionsForm runs (after the error knob) —
mutate consent state here to simulate the user changing (or
withdrawing) consent in the privacy-options form.
getter/setter pair
- privacyOptionsFormError ↔ AdFlowError?
-
If set, showPrivacyOptionsForm throws this.
getter/setter pair
- privacyOptionsRequirement ↔ PrivacyOptionsRequirement
-
Value returned by getPrivacyOptionsRequirementStatus.
getter/setter pair
-
requestConfigs
→ List<
AdRequestConfig> -
Every configuration passed to updateRequestConfiguration, in order.
Recorded on COMPLETION (after the hold/error knobs) — see
updateRequestConfigurationCalls for dispatch counting.
final
- requestTrackingAuthorizationCalls ↔ int
-
Number of requestTrackingAuthorization calls.
getter/setter pair
- resetConsentCalls ↔ int
-
Number of resetConsent calls.
getter/setter pair
-
rewardedInterstitials
→ List<
FakeFullScreenAdHandle> -
Fake handles created by loadRewardedInterstitial, in order.
final
-
rewardedInterstitialSsvs
→ List<
ServerSideVerification?> -
The
ssvargument of every loadRewardedInterstitial call, in order.final -
rewardeds
→ List<
FakeFullScreenAdHandle> -
Fake handles created by loadRewarded, in order.
final
-
rewardedSsvs
→ List<
ServerSideVerification?> -
The
ssvargument of every loadRewarded call, in order.final - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- showPrivacyOptionsFormCalls ↔ int
-
Number of showPrivacyOptionsForm calls.
getter/setter pair
- ssvAttachError ↔ Object?
-
If set (and the load carries a non-null
ssv), loadRewarded / loadRewardedInterstitial throw this instead of returning a handle — mirrors the real seam FAILING a load whose server-side verification could not be attached (4.0 audit;AdFlowErrorKind.ssv).getter/setter pair - updateRequestConfigurationCalls ↔ int
-
Number of updateRequestConfiguration DISPATCHES (counted at entry,
before the hold/error knobs) — lets a test assert the ADR-028 rule that
no config call may even be dispatched while
initializeis in flight.getter/setter pair - updateRequestConfigurationError ↔ AdFlowError?
-
If set, updateRequestConfiguration throws this instead of recording.
getter/setter pair
-
updateRequestConfigurationHold
↔ Completer<
void> ? -
If set, updateRequestConfiguration awaits this before recording —
leave it incomplete to simulate a config call that hangs.
getter/setter pair
Methods
-
canRequestAds(
) → Future< bool> -
Whether ads may be requested. THE gate: no
load*call is allowed until this is true.override -
disableMediationInitialization(
) → Future< void> -
Defers mediation adapter initialization out of initialize — adapters
then initialize lazily at the first ad request for their network. Must
be called BEFORE initialize (the plugin documents it as a no-op
afterwards). Used by
AdFlowConfig.deferMediationInitso an app can forward per-network consent signals after UMP settles but before any network SDK spins up (4.0; see doc/MEDIATION_SETUP.md).override -
dispose(
) → Future< void> - Closes the streams this fake owns.
-
emitAppForeground(
) → void - Emits one AppForegroundEvent on appForegroundEvents.
-
getConsentStatus(
) → Future< AdConsentStatus> -
Current consent status.
override
-
getPrivacyOptionsRequirementStatus(
) → Future< PrivacyOptionsRequirement> -
Whether the app must surface a privacy-options entry point.
override
-
getTrackingAuthorizationStatus(
) → Future< AttStatus> -
The current ATT authorization status. Android/others →
AttStatus.notSupported.
override
-
initialize(
) → Future< void> -
Initializes the underlying Mobile Ads SDK.
override
-
isConsentFormAvailable(
) → Future< bool> -
Whether a consent form is available to show.
override
-
loadAndShowConsentFormIfRequired(
) → Future< void> -
Loads and shows the consent form if consent is required; completes when
dismissed. Throws an
AdFlowError(kindconsent) on form error.override -
loadAppOpen(
String adUnitId, AdRequestOptions options) → Future< AppOpenHandle> -
Loads an app open ad.
override
-
loadBanner(
BannerLoadSpec spec) → Future< BannerHandle> -
Loads a banner ad per
spec.override -
loadInterstitial(
String adUnitId, AdRequestOptions options) → Future< InterstitialHandle> -
Loads an interstitial ad.
override
-
loadNative(
NativeLoadSpec spec) → Future< NativeHandle> -
Loads a native ad per
spec.override -
loadRewarded(
String adUnitId, AdRequestOptions options, {ServerSideVerification? ssv}) → Future< RewardedHandle> -
Loads a rewarded ad.
ssvconfigures server-side reward verification.override -
loadRewardedInterstitial(
String adUnitId, AdRequestOptions options, {ServerSideVerification? ssv}) → Future< RewardedInterstitialHandle> -
Loads a rewarded interstitial ad.
ssvconfigures server-side reward verification.override -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
openAdInspector(
) → Future< AdInspectorResult> -
Opens the Ad Inspector debug overlay.
override
-
requestConsentInfoUpdate(
{bool? tagForUnderAgeOfConsent, ConsentDebugOptions? debug}) → Future< void> -
Refreshes UMP consent info. Call once every app launch.
override
-
requestTrackingAuthorization(
) → Future< AttStatus> -
Shows the iOS system tracking prompt (only when the current status is
AttStatus.notDetermined) and resolves to the resulting status. A
no-op returning AttStatus.notSupported off iOS.
override
-
resetConsent(
) → Future< void> -
Resets UMP consent state. Testing only — never call in production.
override
-
showPrivacyOptionsForm(
) → Future< void> -
Shows the privacy-options form (the "Manage consent" surface).
Throws an
AdFlowError(kindconsent) on form error.override -
toString(
) → String -
A string representation of this object.
inherited
-
updateRequestConfiguration(
AdRequestConfig config) → Future< void> -
Applies global request configuration (test devices, content rating,
COPPA/underage tags).
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited