FakeDownloadsChannel class
In-memory DownloadsChannel with no platform-channel dependency — for
unit-testing RecordingController.startRecordingToDownloads/
startIqRecordingToDownloads/shareRecording without an Android device.
Hands out incrementing fake fds starting at firstFd and tracks every call so a test can assert on the filenames/mime types/subdirectories used and what got shared.
Constructors
- FakeDownloadsChannel({int firstFd = 1000})
Properties
- failNextOpen ↔ bool
-
Set to make the next openDownloadsFd call fail — simulates the
legacy-Android (pre-API 29) fallback path, where there's no
MediaStore.Downloadscollection to insert into.getter/setter pair -
finishedFds
→ List<
int> -
final
- firstFd → int
-
final
- hashCode → int
-
The hash code for this object.
no setterinherited
-
openCalls
→ List<
({String fileName, String mimeType, String subdirectory})> -
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
final
Methods
-
finishDownloadsFd(
int fd) → Future< String?> -
Finalizes a recording opened via openDownloadsFd — clears
IS_PENDINGso it becomes visible to other apps — and returns itscontent://URI (for a later shareFile call), or null iffdwasn't tracked (only call this for recordings that actually used openDownloadsFd). -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
openDownloadsFd(
{required String fileName, required String mimeType, String subdirectory = 'Recordings'}) → Future< int> -
Opens a writable file descriptor for
Downloads/$subdirectory/$fileNamevia MediaStore, returning the raw fd — pass it straight intoNativeBindings.shimStartRecordingFd/shimStartIqRecordingFd. The entry stays hidden from other apps (IS_PENDING) until finishDownloadsFd is called. -
Shares a recording via Android's native chooser. Pass
uri(acontent://URI, from a MediaStore/Downloads recording) if you have one; otherwise passpath(a plain file — the legacy fallback or a developer's own chosen directory), which gets resolved to a shareable URI via a bundledFileProviderfirst. Exactly one ofuri/pathmust be given. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited