FakeModelDownloader class final
A downloader the test drives: it records every call and sends the updates the test emits. start reports the download queued, pause paused, resume running and cancel canceled (unless echoCancel is false), as a background downloader does; finish writes the file and reports it complete. Like a downloader that keeps the partial data of a failed download, canResume is true after a failed update of an id until it is started, resumed, discarded, canceled or finished; canResumeResult fixes the answer instead.
- Implemented types
Constructors
- FakeModelDownloader({bool? canResumeResult, bool echoCancel = true})
Properties
-
calls
→ List<
String> -
Every call in order:
start <id> wifiOnly=<bool>,pause <id>,resume <id>,canResume <id>,discard <id>,cancel <id>,restore.final -
canceled
→ List<
String> -
The ids of the pause, resume, cancel and discard calls, in order.
final
- canResumeResult ↔ bool?
-
What canResume answers; null: whether the id's download failed and its data is still kept (see the class).
getter/setter pair
-
discarded
→ List<
String> -
The ids of the pause, resume, cancel and discard calls, in order.
final
- echoCancel ↔ bool
-
Whether cancel reports the download canceled.
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
-
kept
→ Set<
String> -
The ids whose partial data a real downloader would still keep: their last update was a failure.
final
-
paused
→ List<
String> -
The ids of the pause, resume, cancel and discard calls, in order.
final
-
restored
→ List<
ModelDownloadUpdate> -
The updates restore sends, as downloads found running at launch would.
final
-
restoredTargets
↔ List<
DownloadTarget> -
The targets the last restore was given.
getter/setter pair
-
resumed
→ List<
String> -
The ids of the pause, resume, cancel and discard calls, in order.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
started
→ List<
FakeDownloadStart> -
The start calls, in order.
final
-
updates
→ Stream<
ModelDownloadUpdate> -
Every change of every download (a broadcast stream).
no setteroverride
Methods
-
cancel(
String id) → Future< void> -
Stops the download of
idand deletes its part file; updates then reports it canceled.override -
canResume(
String id) → Future< bool> -
Whether the partial data of
idcan still be resumed, also after a relaunch: a failed download whose data the downloader kept, or a part file an earlier process left (restore).override -
discard(
String id) → Future< void> -
Deletes the partial data of
id, also what an earlier process left.override -
emit(
ModelDownloadUpdate update) → void -
Sends
updateto the listeners of updates. -
finish(
String id, List< int> bytes) → void -
Writes
byteswhere the last start ofidput its part file, then reports the download complete. -
lastStart(
String id) → FakeDownloadStart? -
The last start of
id, or null. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
pause(
String id) → Future< void> -
Pauses the download of
id, keeping what it received.override -
restore(
{Iterable< DownloadTarget> targets = const []}) → Future<void> -
Reattaches to downloads that ran while the app was suspended or closed, and reports their state.
targetsname where the manager's models would be written: a downloader that keeps no records of its own (the foregroundHttpModelDownloader) reports a part file an earlier process left there as a paused download, which it can then resume or discard; one that keeps its records ignores them.override -
resume(
String id) → Future< void> -
Resumes a paused download, or a failed one whose partial data canResume reports, with the network rule it was
started with; starts it again when it cannot resume. A resume that fails later on, because the kept data turned
out unusable, fails with DownloadErrorCode.cannotResume.
override
-
start(
ModelEntry entry, {required String directory, required String partFileName, required bool wifiOnly}) → Future< void> -
Starts downloading
entryinto the absolute folderdirectoryaspartFileName, from the first byte.wifiOnlyasks for Wi-Fi (a downloader that cannot tell networks apart ignores it).override -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited