MockAppCubit class
Mock AppCubit for widget testing
Provides minimal AppState for widgets that depend on AppCubit context. Use wrapWithMockAppCubit helper for easy test setup.
Example:
await tester.pumpWidget(
wrapWithMockAppCubit(
MaterialApp(
home: MyWidget(),
),
),
);
Constructors
- MockAppCubit({NetworkStatus networkStatus = NetworkStatus.connected, AppAuthStatus authStatus = AppAuthStatus.noauth, AppStatus appStatus = AppStatus.normal})
Properties
- connectionFactoryForTest ↔ InternetConnection Function(String primaryUrl)?
-
Test-only seam (BEH-12): overrides how the
InternetConnectionis constructed in_initializeNetworkCheckingso the leak/idempotency test (BEH-3) can inject a fake that records dispose()/subscription lifecycle. When null, the realInternetConnection.createInstanceis used.getter/setter pairinherited - entranceUri ↔ Uri?
-
getter/setter pairinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasProcessedEntrance ↔ bool
-
getter/setter pairinherited
- isClosed → bool
-
Whether the bloc is closed.
no setterinherited
- networkRequired ↔ bool
-
getter/setter pairinherited
-
probeOnceForTest
← Future<
bool> Function() -
Test-only seam (BEH-12, additive): inject the single-probe function so
tests can drive the startup retry loop / confirmation without a real
checker. A leading-underscore field is library-private and unsettable from
an external test library;
@visibleForTestingon a private member raisesinvalid_visibility_annotation, so a public setter is required (mirrors the existing handleVersionUpdateForTest / emitStartupStatusForTest seams).no getterinherited - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- state → AppState
-
The current state.
no setterinherited
-
stream
→ Stream<
AppState> -
The current stream of states.
no setterinherited
Methods
-
addError(
Object error, [StackTrace? stackTrace]) → void -
Reports an
errorwhich triggersonErrorwith an optional StackTrace.inherited -
buildCheckOptionsForTest(
String primaryUrl) → List< InternetCheckOption> -
Test-only seam (BEH-12): build the check-option list so the
responseStatusFntable (BEH-7) can be asserted directly.inherited -
checkForAppUpdates(
) → Future< void> -
inherited
-
checkNetworkWithTimeoutForTest(
) → Future< bool> -
Test-only seam (BEH-12): run the budget-bounded startup retry loop in
isolation. Call computeEffectiveNetworkConfigForTest first so
_effectiveProbeTimeoutMsis populated as in production.inherited -
clearUnreadNotificationCount(
) → void -
Clears the unread notification count (sets to 0).
inherited
-
close(
) → Future< void> -
Closes the instance.
This method should be called when the instance is no longer needed.
Once close is called, the instance can no longer be used.
override
-
computeEffectiveNetworkConfigForTest(
) → ({int confirmCount, int connectedMs, int offlineMs, int probeTimeoutMs}) -
Test-only seam (BEH-12): recompute the cross-validated effective config and
return the resolved values so NET-022 clamping can be asserted.
inherited
-
dismissVersionUpdateBanner(
) → void -
inherited
-
emit(
AppState state) → void -
Updates the
stateto the providedstate.emitdoes nothing if thestatebeing emitted is equal to the currentstate.inherited -
emitSafe(
AppState state) → void -
inherited
-
emitStartupStatusForTest(
AppState newState) → void -
Test-only seam: emit a startup-path status through the sticky-
updateRequiredguarded setter (Issues 88/91), modelling the cold-start sequence where the version microtask setsupdateRequiredbefore a startup downgrade runs.inherited -
enterStartupNetworkErrorSelfHealForTest(
) → Future< void> -
Test-only seam (BEH-12, additive): drive the shared startup self-heal
helper (
_enterStartupNetworkErrorSelfHeal) directly so the exception-path self-heal (NET-021) — otherwise only reachable via a genuine init exception inside_initializeNetworkChecking— can be exercised in isolation.inherited -
getInitialData(
) → Future< void> -
override
-
handleAppResumedForTest(
) → Future< void> -
Test-only seam (BEH-12, additive): drive the guarded resume re-probe
(
_handleAppResumedNetworkReprobe) directly. The production wiring in_initializeLifecycleServiceruns only after getInitialData (Firebase- coupled); this seam exercises the hook's guards (loading gate, kill-switch, epoch/close fencing, resume-recovery resync) in isolation.inherited -
handleInternetStatusForTest(
InternetStatus status) → Future< void> -
Test-only seam (BEH-12, additive): drive the confirm-before-flip handler
directly (mirrors handleVersionUpdateForTest). Returns the handler's
future so the confirmation pass can be awaited to completion.
inherited
-
handleVersionUpdateForTest(
VersionUpdateInfo updateInfo) → void -
Test-only seam: deliver a VersionUpdateInfo to the version-update handler
without driving the real (platform-coupled) AppVersionUpdateService.
inherited
-
incrementUnreadNotificationCount(
) → void -
Increments the unread notification count by 1.
inherited
-
initializeNotificationSync(
) → Future< void> -
Initializes notification state sync with NotificationService.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onChange(
Change< AppState> change) → void -
Called whenever a
changeoccurs with the givenchange. Achangeoccurs when a newstateis emitted.onChangeis called before thestateof thecubitis updated.onChangeis a great spot to add logging/analytics for a specificcubit.inherited -
onError(
Object error, StackTrace stackTrace) → void -
Called whenever an
erroroccurs and notifiesBlocObserver.onError.inherited -
inherited
-
overlayFullScreenFinish(
) → void -
inherited
-
overlayFullScreenSetChild(
Widget child()) → void -
inherited
-
overlayFullScreenSetChildAndStart(
Widget child()?) → void -
inherited
-
overlayFullScreenStart(
) → void -
inherited
-
overlayLoadingFinish(
) → void -
inherited
-
overlayLoadingStart(
) → void -
inherited
-
overlayProgressingFinish(
) → void -
inherited
-
overlayProgressingStart(
{String? headerText}) → void -
inherited
-
overlayProgressingUpdate(
double progress) → void -
inherited
-
refreshNotificationPermissionStatus(
) → Future< void> -
Refreshes the notification permission status from the system.
inherited
-
requestNotificationPermissions(
{bool provisional = false}) → Future< NotificationPermissionStatus> -
Requests notification permissions and syncs the result to state.
inherited
-
retryNetworkConnection(
) → Future< void> -
inherited
-
setAppStatus(
AppStatus status) → void - Update app status for testing
-
setAuthStatus(
AppAuthStatus status) → void - Update auth status for testing
-
setColorThemeIndex(
int index) → Future< void> -
inherited
-
setNetworkStatus(
NetworkStatus status) → void - Update network status for testing different scenarios
-
toString(
) → String -
A string representation of this object.
inherited
-
updateNotificationPermissionStatus(
NotificationPermissionStatus status) → void -
Updates the notification permission status.
inherited
-
updateUnreadNotificationCount(
int count) → void -
Updates the unread notification count.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited