MockRecommendations class
A test double for RecommendationsApi, with no MethodChannel and no
network call involved.
Install with Recommendations.instance = MockRecommendations(); so every
call through Recommendations.fetch resolves instantly with recommendations
instead of hitting the real native fetch. Set error to make fetch
throw instead, simulating a native fetch failure.
Viewability reporting itself is untouched by this mock:
RecommendationsViewabilityReporter already exposes a postOverride
constructor seam for inspecting/suppressing its POST in a test, since the
underlying method-channel call it makes is a separate concern from
fetching the list this mock stands in for.
- Implemented types
Constructors
-
MockRecommendations({List<
TeadsRecommendation> ? recommendations})
Properties
-
adChoicesUrl
→ Future<
String?> -
The URL your AdChoices icon must open when tapped. Null if native has none.
no setteroverride
- adChoicesUrlResult ↔ String?
-
The URL adChoicesUrl resolves to.
getter/setter pair
- clickUrl ↔ String?
-
The URL registerClick resolves to, for every recommendation.
getter/setter pair
- error ↔ Object?
-
When set, fetch throws this instead of returning recommendations.
getter/setter pair
- fetchCallCount ↔ int
-
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
- lastClickedRecommendation ↔ TeadsRecommendation?
-
getter/setter pair
- lastConfig ↔ RecommendationsPlacementConfig?
-
getter/setter pair
-
lastReleased
↔ List<
TeadsRecommendation> ? -
getter/setter pair
-
recommendations
↔ List<
TeadsRecommendation> -
getter/setter pair
- registerClickCallCount ↔ int
-
getter/setter pair
- releaseCallCount ↔ int
-
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- testRtb ↔ bool?
-
The last value passed to setTestRtb, or null if it was never called.
getter/setter pair
Methods
-
fetch(
RecommendationsPlacementConfig config) → Future< List< TeadsRecommendation> > -
Fetches recommendations for
config. Throws a PlatformException if the native fetch fails.override -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
registerClick(
TeadsRecommendation recommendation) → Future< String?> -
Resolves
recommendation's destination URL at the moment of an actual user tap — and, for an organic recommendation, reports the click to the traffic endpoint as native's owngetUrl(rec)does. Returns null ifrecommendationhas no TeadsRecommendation.clickId. Throws a PlatformException with codeclick_id_not_foundif native no longer has the recommendation cached.override -
release(
List< TeadsRecommendation> recommendations) → Future<void> -
Proactively frees native's cached click-lookup entries for
recommendations— call this once a fetched list is no longer shown (e.g. from the publisher widget'sdispose()).override -
setTestRtb(
bool enabled) → Future< void> -
Forces paid (RTB) recommendations into fetch responses, so the
disclosure-icon handling can be tested without a live campaign.
Process-wide; set it before fetch. Remove before release.
override
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited