mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-21 22:05:59 +00:00
Stores: progress per stage, and the install stage reports its own
A 13 GB Epic install spent three minutes assembling behind a still bar. The entry now carries the active stage's own count - an amount and, when it counts files, the files - and which stages are already behind it. Epic reports its verify pass and its assembly (native and the fallback loop), GOG its chunk-cache removal. The Downloads row draws one segment per stage, passed ones full and the active one filling, and reads e.g. Installing 42% · 120/515 files; speed and ETA show only while downloading, and leaving Download clears the measured speed. Cards and the game page follow the active stage's percent.
This commit is contained in:
1 parent
236eeddeec
commit
a5f608b9d7
11 files changed
+182
-31
No files matched your search
@@ -43,15 +43,31 @@ data class DownloadEntry(
|
||||
val startedAt: Long = 0L,
|
||||
/** Where it is going: the install target's name ("Internal storage", the card's name). */
|
||||
val location: String = "",
|
||||
/**
|
||||
* The active stage's own progress outside Download (which runs on [bytesDone]/[bytesTotal]):
|
||||
* an amount ([stageDone] of [stageTotal], bytes or items) and, when it counts files, [stageItems]
|
||||
* of [stageItemsTotal]. Reset when the stage changes.
|
||||
*/
|
||||
val stageDone: Long = 0L,
|
||||
val stageTotal: Long = 0L,
|
||||
val stageItems: Int = 0,
|
||||
val stageItemsTotal: Int = 0,
|
||||
/** Stages already passed, one bit per [DownloadStage] ordinal; stages can come back (Epic checks files before it fetches). */
|
||||
val stagesPassed: Int = 0,
|
||||
) {
|
||||
fun passed(s: DownloadStage): Boolean = state == DownloadState.INSTALLED || (stagesPassed and (1 shl s.ordinal)) != 0
|
||||
|
||||
val key: String get() = "${store.id}:$id"
|
||||
val isActive: Boolean get() = state == DownloadState.QUEUED || state == DownloadState.RUNNING || state == DownloadState.PAUSED
|
||||
/** 0..1 for the bar: the byte fraction while downloading, full once past it. */
|
||||
val fraction: Float get() = when {
|
||||
state == DownloadState.INSTALLED -> 1f
|
||||
stage == DownloadStage.VERIFY || stage == DownloadStage.INSTALL || stage == DownloadStage.DONE -> 1f
|
||||
bytesTotal > 0L -> (bytesDone.toDouble() / bytesTotal).toFloat().coerceIn(0f, 1f)
|
||||
else -> 0f
|
||||
/** The active stage's progress, 0..1, or -1 while it has nothing to count yet. */
|
||||
val stageFraction: Float get() = when {
|
||||
state == DownloadState.INSTALLED || stage == DownloadStage.DONE -> 1f
|
||||
stage == DownloadStage.DOWNLOAD -> if (bytesTotal > 0L) (bytesDone.toDouble() / bytesTotal).toFloat().coerceIn(0f, 1f) else -1f
|
||||
stageTotal > 0L -> (stageDone.toDouble() / stageTotal).toFloat().coerceIn(0f, 1f)
|
||||
stageItemsTotal > 0 -> (stageItems.toFloat() / stageItemsTotal).coerceIn(0f, 1f)
|
||||
else -> -1f
|
||||
}
|
||||
/** 0..1 for a single bar (a card, the game page): the active stage's progress. */
|
||||
val fraction: Float get() = stageFraction.coerceAtLeast(0f)
|
||||
val percent: Int get() = (fraction * 100).toInt()
|
||||
}
|
||||
@@ -33,7 +33,12 @@ object DownloadQueue {
|
||||
/** What a running job reports with. */
|
||||
class JobHandle internal constructor(val key: String, internal val cancelled: AtomicBoolean) {
|
||||
val isCancelled: Boolean get() = cancelled.get()
|
||||
fun stage(stage: DownloadStage, detail: String = "") = update(key) { it.copy(stage = stage, detail = stripSpeed(detail).ifEmpty { it.detail }, state = DownloadState.RUNNING) }
|
||||
/** Enters [stage] (a repeat of the current one only updates the line); a new stage starts its own count from zero. */
|
||||
fun stage(stage: DownloadStage, detail: String = "") = enter(key, stage, stripSpeed(detail))
|
||||
/** The active stage's own count outside Download: an amount (bytes or items) and, when it counts files, the files. */
|
||||
fun stageProgress(done: Long, total: Long, items: Int = 0, itemsTotal: Int = 0) = update(key) {
|
||||
it.copy(stageDone = done, stageTotal = total, stageItems = items, stageItemsTotal = itemsTotal)
|
||||
}
|
||||
/**
|
||||
* Bytes so far (negative = unchanged), the total (<= 0 = unchanged), a line. [speedBps] is the
|
||||
* engine's own figure: a burst rate at the network side, which jumps while the write side
|
||||
@@ -47,12 +52,37 @@ object DownloadQueue {
|
||||
/** "Downloading: data.pak 12.3 MB/s" → "Downloading: data.pak": the engine's burst rate is not shown twice. */
|
||||
private fun stripSpeed(s: String): String = s.replace(Regex("\\s+\\S+ [KMG]B/s\\s*$"), "").trimEnd()
|
||||
|
||||
private fun enter(key: String, stage: DownloadStage, detail: String) {
|
||||
synchronized(lock) {
|
||||
val item = items[key] ?: return
|
||||
transitionLocked(item, stage)
|
||||
item.entry = item.entry.copy(detail = detail.ifEmpty { item.entry.detail }, state = DownloadState.RUNNING)
|
||||
publishLocked()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves an item to [stage] when it is elsewhere: the old stage is marked passed, the new one
|
||||
* counts from zero, and the measured speed is cleared - the next stage writes or checks, it
|
||||
* does not fetch, and a stale rate there would read as a download. Caller holds [lock].
|
||||
*/
|
||||
private fun transitionLocked(item: Item, stage: DownloadStage) {
|
||||
val e = item.entry
|
||||
if (e.stage == stage) return
|
||||
item.speedAt = 0L; item.speedBytes = 0L; item.speedEwma = 0.0
|
||||
item.entry = e.copy(
|
||||
stage = stage, stagesPassed = e.stagesPassed or (1 shl e.stage.ordinal), speedBps = 0, etaSeconds = -1,
|
||||
stageDone = 0, stageTotal = 0, stageItems = 0, stageItemsTotal = 0,
|
||||
)
|
||||
}
|
||||
|
||||
/** How far back the shown speed looks: a few seconds, so the figure settles instead of following each file. */
|
||||
private const val SPEED_WINDOW_MS = 3000.0
|
||||
|
||||
private fun measure(key: String, bytesDone: Long, bytesTotal: Long, detail: String?) {
|
||||
synchronized(lock) {
|
||||
val item = items[key] ?: return
|
||||
transitionLocked(item, DownloadStage.DOWNLOAD)
|
||||
val e = item.entry
|
||||
val done = if (bytesDone >= 0) bytesDone else e.bytesDone
|
||||
val total = if (bytesTotal > 0) bytesTotal else e.bytesTotal
|
||||
|
||||
@@ -57,7 +57,8 @@ class StoreDownloadService : Service() {
|
||||
val title = if (active.size > 1) getString(R.string.stores_notification_many, active.size) else getString(R.string.stores_notification_one)
|
||||
val text = when {
|
||||
first == null -> getString(R.string.stores_notification_waiting)
|
||||
first.bytesTotal > 0 -> "${first.name} · ${first.percent}% (${formatBytes(first.bytesDone)} / ${formatBytes(first.bytesTotal)})"
|
||||
first.stage == com.droiddeck.launcher.stores.download.DownloadStage.DOWNLOAD && first.bytesTotal > 0 -> "${first.name} · ${first.percent}% (${formatBytes(first.bytesDone)} / ${formatBytes(first.bytesTotal)})"
|
||||
first.stageFraction >= 0f -> "${first.name} · ${first.percent}%"
|
||||
else -> first.name
|
||||
}
|
||||
val tap = PendingIntent.getActivity(this, 0, Intent(this, MainActivity::class.java), PendingIntent.FLAG_IMMUTABLE)
|
||||
|
||||
@@ -127,6 +127,10 @@ object EpicBackend : StoreBackend, EpicLaunchSupport {
|
||||
}
|
||||
override fun onBytes(done: Long, total: Long, speedBps: Long) { handle.progress(done, total, null, speedBps) }
|
||||
override fun onLog(line: String) { handle.log(line) }
|
||||
override fun onStage(stage: String, done: Long, total: Long, items: Int, itemsTotal: Int) {
|
||||
handle.stage(if (stage == "verify") DownloadStage.VERIFY else DownloadStage.INSTALL)
|
||||
handle.stageProgress(done, total, items, itemsTotal)
|
||||
}
|
||||
}) ?: return null
|
||||
if (cancelled.get()) return null
|
||||
handle.stage(DownloadStage.INSTALL, "Registering with Steam…")
|
||||
|
||||
@@ -56,6 +56,12 @@ public final class EpicDownloadManager {
|
||||
void onProgress(String message, int pct);
|
||||
default void onBytes(long done, long total, long speedBps) {}
|
||||
default void onLog(String line) {}
|
||||
/**
|
||||
* The active stage's own count: {@code stage} is "verify" or "install", {@code done} of
|
||||
* {@code total} an amount (bytes, or items when there are no bytes), {@code items} of
|
||||
* {@code itemsTotal} the files, when it counts files.
|
||||
*/
|
||||
default void onStage(String stage, long done, long total, int items, int itemsTotal) {}
|
||||
}
|
||||
|
||||
private EpicDownloadManager() {}
|
||||
@@ -154,11 +160,15 @@ public final class EpicDownloadManager {
|
||||
cb.onProgress("Verifying existing files…", 0);
|
||||
List<FileInfo> pending = new ArrayList<>(selected.size());
|
||||
int checked = 0, good = 0;
|
||||
long checkedBytes = 0;
|
||||
cb.onStage("verify", 0, installBytes, 0, selected.size());
|
||||
for (FileInfo f : selected) {
|
||||
if (cancel.get()) return null;
|
||||
File out = new File(installDir, f.filename.replace("\\", "/"));
|
||||
if (fileExistsWithCorrectHash(out, f.fileSize(), f.sha1)) good++; else pending.add(f);
|
||||
checked++;
|
||||
checkedBytes += f.fileSize();
|
||||
if ((checked & 15) == 0 || checked == selected.size()) cb.onStage("verify", checkedBytes, installBytes, checked, selected.size());
|
||||
if ((checked & 63) == 0) cb.onProgress("Verifying existing files… (" + checked + "/" + selected.size() + ")", 0);
|
||||
}
|
||||
cb.onLog("epic: delta " + good + " up to date, " + pending.size() + " to download");
|
||||
@@ -256,6 +266,8 @@ public final class EpicDownloadManager {
|
||||
cb.onLog("epic: assembler not started (" + r.error + "); writing the files here");
|
||||
}
|
||||
int totalFiles = pending.size(), doneFiles = 0;
|
||||
long writtenBytes = 0, writeTotal = 0;
|
||||
for (FileInfo f : pending) writeTotal += f.fileSize();
|
||||
for (FileInfo file : pending) {
|
||||
if (cancel.get()) return null;
|
||||
String relPath = file.filename.replace("\\", "/");
|
||||
@@ -272,6 +284,8 @@ public final class EpicDownloadManager {
|
||||
}
|
||||
}
|
||||
doneFiles++;
|
||||
writtenBytes += file.fileSize();
|
||||
cb.onStage("install", writtenBytes, writeTotal, doneFiles, totalFiles);
|
||||
}
|
||||
deleteDir(chunkCacheDir);
|
||||
cb.onProgress("Complete", 100);
|
||||
@@ -341,6 +355,7 @@ public final class EpicDownloadManager {
|
||||
EpicNative.Result res = EpicNative.assemble(manifestBytes, installDirPath, cachePath, pendingIdx, cancel, new EpicNative.Listener() {
|
||||
@Override public void onPlan(int chunksTotal, long bytesTotal, String chunkDir) {}
|
||||
@Override public void onProgress(long bytesDone, long bytesTotal, int done, int total) {
|
||||
cb.onStage("install", bytesDone, bytesTotal, done, Math.max(total, totalFiles));
|
||||
cb.onProgress("Writing files (" + done + "/" + Math.max(total, totalFiles) + ")", 80 + (int) (done * 20L / Math.max(1, Math.max(total, totalFiles))));
|
||||
}
|
||||
@Override public void onLog(String line) { cb.onLog(line); }
|
||||
|
||||
@@ -95,6 +95,10 @@ object GogBackend : StoreBackend {
|
||||
}
|
||||
override fun onBytes(done: Long, total: Long, speedBps: Long) { handle.progress(done, total, null, speedBps) }
|
||||
override fun onLog(line: String) { handle.log(line) }
|
||||
override fun onStage(stage: String, done: Long, total: Long, items: Int, itemsTotal: Int) {
|
||||
handle.stage(if (stage == "verify") DownloadStage.VERIFY else DownloadStage.INSTALL)
|
||||
handle.stageProgress(done, total, items, itemsTotal)
|
||||
}
|
||||
}, cancelled) ?: return null
|
||||
if (cancelled.get()) return null
|
||||
handle.stage(DownloadStage.INSTALL, "Registering with Steam…")
|
||||
|
||||
@@ -62,6 +62,13 @@ public final class GogDownloadManager {
|
||||
default void onBytes(long done, long total, long speedBps) {}
|
||||
/** A diagnostic line for the engine log. */
|
||||
default void onLog(String line) {}
|
||||
/**
|
||||
* The active stage's own count: {@code stage} is "verify" or "install", {@code done} of
|
||||
* {@code total} an amount (bytes, or items when there are no bytes), {@code items} of
|
||||
* {@code itemsTotal} the files, when it counts files.
|
||||
*/
|
||||
default void onStage(String stage, long done, long total, int items, int itemsTotal) {}
|
||||
|
||||
}
|
||||
|
||||
/** What an install leaves behind for the sidecar. */
|
||||
@@ -245,7 +252,7 @@ public final class GogDownloadManager {
|
||||
|
||||
cb.onProgress("Finishing…", 96);
|
||||
writeFile(new File(installPath, MARKER), ("{\"gameId\":\"" + game.gameId + "\",\"buildId\":\"" + gm.buildId + "\"}").getBytes("UTF-8"));
|
||||
deleteDir(new File(installPath, ".gog_chunks"));
|
||||
deleteCounted(new File(installPath, ".gog_chunks"), cb);
|
||||
String clientId = manifest.optString("clientId", null);
|
||||
if (clientId != null && !clientId.isEmpty()) GogPrefs.get(ctx).edit().putString("client_id_" + game.gameId, clientId).apply();
|
||||
out.result = new Result(pickExe(installPath, tempExe, game.title), gm.buildId, planned);
|
||||
@@ -888,6 +895,19 @@ public final class GogDownloadManager {
|
||||
try (FileOutputStream fos = new FileOutputStream(f)) { fos.write(data); }
|
||||
}
|
||||
|
||||
/** Removes the chunk cache, counting its files as the Install stage's progress (a large cache takes a while). */
|
||||
private static void deleteCounted(File dir, Callback cb) {
|
||||
File[] files = dir.listFiles();
|
||||
if (files == null) { dir.delete(); return; }
|
||||
int total = files.length, done = 0;
|
||||
for (File f : files) {
|
||||
deleteDir(f);
|
||||
done++;
|
||||
if ((done & 31) == 0 || done == total) cb.onStage("install", done, total, done, total);
|
||||
}
|
||||
dir.delete();
|
||||
}
|
||||
|
||||
static void deleteDir(File dir) {
|
||||
if (dir == null || !dir.exists()) return;
|
||||
File[] children = dir.listFiles();
|
||||
|
||||
@@ -100,11 +100,7 @@ private fun DownloadCard(d: DownloadEntry, s: FrontEndState, a: FrontEndActions)
|
||||
SourceChip(d.store.id, small = true)
|
||||
if (d.location.isNotBlank()) Text(d.location, fontSize = 11.sp, color = dim, maxLines = 1, overflow = TextOverflow.Ellipsis)
|
||||
}
|
||||
if (!narrow) Stages(d)
|
||||
ProgressBarThin(
|
||||
if (d.state == DownloadState.INSTALLED) 1f else d.fraction, paused = d.state == DownloadState.PAUSED,
|
||||
verify = d.stage == DownloadStage.VERIFY, height = 6.dp, done = d.state == DownloadState.INSTALLED,
|
||||
)
|
||||
StageBar(d)
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(14.dp)) {
|
||||
val meta = when (d.state) {
|
||||
DownloadState.INSTALLED -> stringResource(R.string.stores_installed_chip)
|
||||
@@ -112,13 +108,17 @@ private fun DownloadCard(d: DownloadEntry, s: FrontEndState, a: FrontEndActions)
|
||||
DownloadState.FAILED -> d.error?.let { stringResource(R.string.stores_dl_failed_reason, it) } ?: stringResource(R.string.stores_dl_failed)
|
||||
DownloadState.PAUSED -> stringResource(R.string.stores_dl_paused)
|
||||
DownloadState.QUEUED -> if (d.queuePosition > 0) stringResource(R.string.stores_dl_queued_at, d.queuePosition) else stringResource(R.string.stores_dl_queued)
|
||||
DownloadState.RUNNING -> when {
|
||||
d.stage == DownloadStage.DOWNLOAD && d.bytesTotal > 0 -> stringResource(R.string.stores_dl_bytes, formatBytes(d.bytesDone), formatBytes(d.bytesTotal), d.percent)
|
||||
else -> stageLabel(d.stage)
|
||||
DownloadState.RUNNING -> {
|
||||
val head = if (d.stageFraction >= 0f) stringResource(R.string.stores_dl_active_percent, activeStageLabel(d.stage), d.percent) else activeStageLabel(d.stage)
|
||||
when {
|
||||
d.stage == DownloadStage.DOWNLOAD && d.bytesTotal > 0 -> stringResource(R.string.stores_dl_with, head, stringResource(R.string.stores_dl_amount, formatBytes(d.bytesDone), formatBytes(d.bytesTotal)))
|
||||
d.stageItemsTotal > 0 -> stringResource(R.string.stores_dl_with, head, stringResource(R.string.stores_dl_items, d.stageItems, d.stageItemsTotal))
|
||||
else -> head
|
||||
}
|
||||
}
|
||||
}
|
||||
Text(meta, fontSize = 12.sp, color = dim, maxLines = 2, overflow = TextOverflow.Ellipsis, modifier = Modifier.weight(1f, fill = false))
|
||||
if (d.state == DownloadState.RUNNING && d.speedBps > 0) {
|
||||
if (d.state == DownloadState.RUNNING && d.stage == DownloadStage.DOWNLOAD && d.speedBps > 0) {
|
||||
Text(formatSpeed(d.speedBps), fontSize = 12.sp, color = dim, maxLines = 1)
|
||||
if (d.etaSeconds >= 0) Text(eta(d.etaSeconds), fontSize = 12.sp, color = dim, maxLines = 1)
|
||||
}
|
||||
@@ -150,24 +150,40 @@ private fun DownloadCard(d: DownloadEntry, s: FrontEndState, a: FrontEndActions)
|
||||
}
|
||||
}
|
||||
|
||||
/** Manifest → Download → Verify → Install → Done, the one under way lit, the ones behind it green. */
|
||||
/**
|
||||
* One segment per stage - Manifest, Download, Verify, Install - equal widths: a passed stage full, the
|
||||
* active one filling with its own progress (a sliver while it has nothing to count), the rest empty.
|
||||
*/
|
||||
@Composable
|
||||
private fun Stages(d: DownloadEntry) {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val pal = LocalPalette.current
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(4.dp)) {
|
||||
for (stage in DownloadStage.entries) {
|
||||
val passed = d.state == DownloadState.INSTALLED || stage.ordinal < d.stage.ordinal
|
||||
val on = d.state == DownloadState.RUNNING && stage == d.stage
|
||||
Text(
|
||||
stageLabel(stage), fontSize = 10.sp, fontWeight = FontWeight.SemiBold, maxLines = 1,
|
||||
color = when { on -> pal.signal; passed -> pal.good; else -> colors.onSurfaceVariant },
|
||||
modifier = Modifier.clip(RoundedCornerShape(6.dp)).background(if (on) pal.signal.copy(alpha = 0.18f) else colors.surfaceVariant).padding(horizontal = 6.dp, vertical = 2.dp),
|
||||
)
|
||||
private fun StageBar(d: DownloadEntry) {
|
||||
val stages = listOf(DownloadStage.MANIFEST, DownloadStage.DOWNLOAD, DownloadStage.VERIFY, DownloadStage.INSTALL)
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(3.dp), modifier = Modifier.fillMaxWidth()) {
|
||||
for (st in stages) {
|
||||
val active = d.state != DownloadState.INSTALLED && d.stage == st
|
||||
val fill = when {
|
||||
active -> d.stageFraction.let { if (it < 0f) 0.04f else it }
|
||||
d.passed(st) || d.stage == DownloadStage.DONE -> 1f
|
||||
else -> 0f
|
||||
}
|
||||
Box(Modifier.weight(1f)) {
|
||||
ProgressBarThin(
|
||||
fill, paused = active && d.state == DownloadState.PAUSED, verify = active && st == DownloadStage.VERIFY,
|
||||
height = 6.dp, done = !active && fill >= 1f,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun activeStageLabel(stage: DownloadStage): String = when (stage) {
|
||||
DownloadStage.MANIFEST -> stringResource(R.string.stores_stage_manifest)
|
||||
DownloadStage.DOWNLOAD -> stringResource(R.string.stores_stage_downloading)
|
||||
DownloadStage.VERIFY -> stringResource(R.string.stores_stage_verifying)
|
||||
DownloadStage.INSTALL -> stringResource(R.string.stores_stage_installing)
|
||||
DownloadStage.DONE -> stringResource(R.string.stores_stage_done)
|
||||
}
|
||||
|
||||
private fun eta(seconds: Long): String = when {
|
||||
seconds < 60 -> "<1 min"
|
||||
seconds < 3600 -> "~${seconds / 60} min"
|
||||
|
||||
@@ -2062,6 +2062,13 @@
|
||||
<string name="stores_stage_verify">Verify</string>
|
||||
<string name="stores_stage_install">Install</string>
|
||||
<string name="stores_stage_done">Done</string>
|
||||
<string name="stores_stage_downloading">Downloading</string>
|
||||
<string name="stores_stage_verifying">Verifying</string>
|
||||
<string name="stores_stage_installing">Installing</string>
|
||||
<string name="stores_dl_active_percent">%1$s %2$d%%</string>
|
||||
<string name="stores_dl_with">%1$s · %2$s</string>
|
||||
<string name="stores_dl_amount">%1$s / %2$s</string>
|
||||
<string name="stores_dl_items">%1$d/%2$d files</string>
|
||||
<string name="stores_download_manager">Download manager</string>
|
||||
<string name="stores_parallel">Downloads at a time</string>
|
||||
<string name="stores_install_where">Install to</string>
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.droiddeck.launcher.stores.download
|
||||
|
||||
import com.droiddeck.launcher.stores.Store
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
|
||||
/** The Downloads row reads the active stage's own progress, and which stages are behind it. */
|
||||
class DownloadEntryTest {
|
||||
private val base = DownloadEntry(Store.EPIC, "doomblade", "DOOMBLADE", state = DownloadState.RUNNING)
|
||||
|
||||
@Test fun downloadRunsOnBytesAndInstallOnItsOwnCount() {
|
||||
val dl = base.copy(stage = DownloadStage.DOWNLOAD, bytesDone = 50, bytesTotal = 200)
|
||||
assertEquals(0.25f, dl.stageFraction, 0.001f)
|
||||
// Past Download the bytes no longer drive the bar; the stage's own count does.
|
||||
val inst = dl.copy(stage = DownloadStage.INSTALL, stageDone = 30, stageTotal = 40, stageItems = 3, stageItemsTotal = 4)
|
||||
assertEquals(0.75f, inst.stageFraction, 0.001f)
|
||||
assertEquals(75, inst.percent)
|
||||
// Nothing counted yet: unknown, not empty and not full.
|
||||
assertEquals(-1f, base.copy(stage = DownloadStage.INSTALL).stageFraction, 0f)
|
||||
}
|
||||
|
||||
@Test fun passedStagesComeFromTheBitsNotTheOrder() {
|
||||
// Epic checks files before it fetches: Verify is behind Download there.
|
||||
val e = base.copy(stage = DownloadStage.DOWNLOAD, stagesPassed = (1 shl DownloadStage.MANIFEST.ordinal) or (1 shl DownloadStage.VERIFY.ordinal))
|
||||
assertTrue(e.passed(DownloadStage.VERIFY))
|
||||
assertFalse(e.passed(DownloadStage.INSTALL))
|
||||
assertTrue(e.copy(state = DownloadState.INSTALLED).passed(DownloadStage.INSTALL))
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user