MockInterstitial class
A test double for Interstitial, with no MethodChannel involved.
load/isReady/show/dispose resolve deterministically; the
fire* methods let a test simulate native events synchronously,
including fireFailed with a specific TeadsAdError reason — real
ad-server failure reasons can't be reliably reproduced on demand
against the real SDK, which is the main reason this exists.
Mirrors InterstitialPlacement's post-dispose behaviour: after
dispose, isReady goes back to false and load/show throw a
StateError, so a test asserting "never touched after dispose" behaves
the same against this mock as against the real SDK.
- Implemented types
Constructors
Properties
- disposed ↔ bool
-
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
-
isReady
→ Future<
bool> -
Whether an unexpired ad is loaded. Re-check immediately before show; the
answer can change on its own when the native TTL lapses.
no setteroverride
- loadCallCount ↔ int
-
getter/setter pair
- onClicked ↔ void Function(TeadsAdClick click)?
-
Called when a paid ad is clicked.
getter/setter pairoverride
- onClickedOrganic ↔ void Function(TeadsAdClick click)?
-
Called when organic (non-paid) content is clicked.
getter/setter pairoverride
- onClosed ↔ void Function()?
-
Fires when the interstitial has been dismissed, so the host can resume.
Backed by native's
dismissedfullscreen event.getter/setter pairoverride -
onEvent
↔ void Function(TeadsAdEvent event, Map<
String, dynamic> ? data)? -
Called for every event, including those with a typed callback above.
datais the event's native payload, if any.getter/setter pairoverride - onFailed ↔ void Function(TeadsAdError error)?
-
Called when the request or render failed, with the native reason.
getter/setter pairoverride
- onReady ↔ void Function()?
-
Called when an ad is loaded and ready to show.
getter/setter pairoverride
- ready ↔ bool
-
Whether isReady resolves
true. A test flips this directly, or relies on fireReady having set it, to model the native TTL.getter/setter pair - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- showCallCount ↔ int
-
getter/setter pair
- showResult ↔ bool
-
Set before calling show to control its return value. Defaults to
true, matching a normal successful presentation.getter/setter pair
Methods
-
dispose(
) → Future< void> -
Releases the native placement, its WebView and its Open Measurement session.
override
-
fireClicked(
[TeadsAdClick click = const TeadsAdClick(null)]) → void -
fireClickedOrganic(
[TeadsAdClick click = const TeadsAdClick(null)]) → void -
fireClosed(
) → void -
Simulates the interstitial being dismissed: fires onClosed then
onEvent, matching InterstitialPlacement's actual dispatch order
(its
onEventwrapper invokes onClosed before forwarding to the publisher's ownonEvent), and marks ready false, matching native's "spent, will not show again". -
fireEvent(
TeadsAdEvent event, [Map< String, dynamic> ? data]) → void - Fires a generic event. TeadsAdEvent.dismissed is routed through fireClosed so onClosed and the dismissed event always fire together, in the same order as the real widget — the real widget has no way to produce one without the other.
-
fireFailed(
TeadsAdError error) → void -
Simulates a load/show failure for
error— the single most useful capability here, since a specific ad-server failure reason can't be reliably reproduced live. -
fireReady(
) → void - Simulates the ad becoming ready: sets ready and fires onEvent then onReady, matching InterstitialPlacement's dispatch order.
-
load(
) → Future< void> -
Requests an ad. Completes when the request has been dispatched, NOT when the
ad is ready — wait for onReady or poll isReady for that.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
show(
) → Future< bool> -
Presents the ad fullscreen. Returns false when there was nothing to show,
which is also what native returns rather than throwing.
override
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited