mirror of
https://github.com/austinried/subtracks.git
synced 2026-11-10 23:21:59 +01:00
downloads: base album/artist progress on completed tracks
The aggregate summed bytes over only the currently active songs, so it reset each time a track finished and the next one started. Count completed tracks (plus the fraction of each running track) over the node's full track count instead, so it climbs one track at a time.
This commit is contained in:
@@ -3,6 +3,7 @@ package com.subtracks.ui.downloads
|
||||
import com.subtracks.data.model.DownloadStatus
|
||||
import com.subtracks.data.model.DownloadedSong
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Test
|
||||
|
||||
class DownloadTreeTest {
|
||||
@@ -44,6 +45,19 @@ class DownloadTreeTest {
|
||||
assertEquals("Unknown album", artist.albums.single().name)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun nodeProgressCountsCompletedTracksRatherThanBytes() {
|
||||
val songs =
|
||||
listOf(
|
||||
song("s1", "One", "ar1", "Artist", "al1", "Album", size = 100),
|
||||
song("s2", "Two", "ar1", "Artist", "al1", "Album", size = 50)
|
||||
.copy(status = DownloadStatus.Running, bytes = 50, total = 100),
|
||||
)
|
||||
|
||||
assertEquals(0.75f, nodeProgress(songs)!!, 0.0001f)
|
||||
assertNull(nodeProgress(listOf(song("s3", "Three", "ar1", "Artist", "al1", "Album", size = 1))))
|
||||
}
|
||||
|
||||
private fun song(
|
||||
id: String,
|
||||
title: String,
|
||||
|
||||
Reference in New Issue
Block a user