FakeXScreenSourcesBackend class

In-memory backend for screen-picker tests. Swap in via XScreenSourcesBackend.instance = FakeXScreenSourcesBackend(...) before any picker code runs; restore with XScreenSourcesBackend.instance = MethodChannelXScreenSourcesBackend() in tearDown.

Records every call and returns scripted answers: mutate sources, permission and the …Error fields between assertions to drive the picker's success, denial and failure paths.

Implemented types

Constructors

FakeXScreenSourcesBackend({List<XScreenSource> sources = const [], XScreenCaptureMode? captureMode = XScreenCaptureMode.pickerDriven, bool supported = true, bool availableResult = true, bool permission = false, bool requestPermissionResult = true})
Creates a fake that starts out picker-driven, supported, available, and not yet granted.

Properties

availableCalls ↔ int
Number of available calls.
getter/setter pair
availableError ↔ XScreenSourcesException?
If non-null, thrown by available.
getter/setter pair
availableResult ↔ bool
Result of available.
getter/setter pair
captureMode ↔ XScreenCaptureMode?
How this platform family shares a screen, or null where it shares none at all. Independent of supported: a family names its mode even where no capture ships for it.
getter/setter pairoverride-getter
hashCode → int
The hash code for this object.
no setterinherited
hasPermissionCalls ↔ int
Number of hasPermission calls.
getter/setter pair
hasPermissionError ↔ XScreenSourcesException?
If non-null, thrown by hasPermission.
getter/setter pair
listCalls → List<({Set<String> allowedDisplayIds, Set<String> allowedWindowIds, int thumbnailHeight, int thumbnailWidth})>
Every list call, in order, with the arguments it was given.
final
listError ↔ XScreenSourcesException?
If non-null, thrown by list instead of returning sources.
getter/setter pair
permission ↔ bool
Result of hasPermission, and what requestPermission grants.
getter/setter pair
requestPermissionCalls ↔ int
Number of requestPermission calls.
getter/setter pair
requestPermissionError ↔ XScreenSourcesException?
If non-null, thrown by requestPermission.
getter/setter pair
requestPermissionResult ↔ bool
Result of requestPermission; a true also sets permission.
getter/setter pair
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
sources ↔ List<XScreenSource>
Snapshot returned by list.
getter/setter pair
startShareCalls → List<({String? notificationText, String notificationTitle})>
Every startShare call, in order, with the notification it was given.
final
startShareError ↔ XScreenSourcesException?
If non-null, thrown by startShare instead of taking the hold.
getter/setter pair
stopShareCalls ↔ int
Number of stopShare calls.
getter/setter pair
stopShareError ↔ XScreenSourcesException?
If non-null, thrown by stopShare.
getter/setter pair
supported ↔ bool
Whether this platform family serves these calls. Elsewhere every method throws XScreenSourcesException with code unsupported, before it looks at its arguments — and so does every call the family's captureMode has no role for: list and the permission pair off XScreenCaptureMode.pickerDriven, startShare and stopShare off XScreenCaptureMode.consentDriven.
getter/setter pairoverride-getter

Methods

available() → Future<bool>
Whether this host can serve its captureMode — the platform family and the OS version, plus whatever else the platform makes a capture depend on: on iOS this is ReplayKit's own answer, false while the app is not in front, a mirrored display is attached, or another recorder holds the screen, and on Android it is false unless the app's pubspec sets ux: enable_media_projection: true.
override
hasPermission() → Future<bool>
Whether screen recording is granted. Never prompts.
override
list({required Set<String> allowedDisplayIds, required Set<String> allowedWindowIds, int thumbnailWidth = 320, int thumbnailHeight = 180}) → Future<List<XScreenSource>>
The allowed sources present right now, each with a thumbnailWidth × thumbnailHeight aspect-fit PNG.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
requestPermission() → Future<bool>
Asks for screen-recording access, returning the state the call leaves behind.
override
startShare({required String notificationTitle, String? notificationText}) → Future<void>
Takes the hold a consent-driven capture runs inside, showing an ongoing notification titled notificationTitle with notificationText under it.
override
stopShare() → Future<void>
Drops the hold startShare took. Dropping one nobody holds succeeds.
override
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited