Add tests for MissingChapters function

This commit is contained in:
arkon
2023-04-15 09:51:52 -04:00
parent 4bcd623829
commit 8ab7e63293
8 changed files with 51 additions and 25 deletions

View File

@@ -251,7 +251,7 @@ dependencies {
implementation(libs.bundles.shizuku)
// Tests
testImplementation(libs.junit)
testImplementation(libs.bundles.test)
// For detecting memory leaks; see https://square.github.io/leakcanary/
// debugImplementation(libs.leakcanary.android)

View File

@@ -65,7 +65,7 @@ import eu.kanade.tachiyomi.ui.manga.chapterDecimalFormat
import eu.kanade.tachiyomi.util.lang.toRelativeString
import eu.kanade.tachiyomi.util.system.copyToClipboard
import tachiyomi.domain.chapter.model.Chapter
import tachiyomi.domain.chapter.service.countMissingChapters
import tachiyomi.domain.chapter.service.missingChaptersCount
import tachiyomi.domain.manga.model.Manga
import tachiyomi.domain.source.model.StubSource
import tachiyomi.presentation.core.components.LazyColumn
@@ -394,7 +394,7 @@ private fun MangaScreenSmallImpl(
ChapterHeader(
enabled = chapters.fastAll { !it.selected },
chapterCount = chapters.size,
missingChapterCount = countMissingChapters(chapters.map { it.chapter.chapterNumber }),
missingChapterCount = chapters.map { it.chapter.chapterNumber }.missingChaptersCount(),
onClick = onFilterClicked,
)
}
@@ -606,7 +606,7 @@ fun MangaScreenLargeImpl(
ChapterHeader(
enabled = chapters.fastAll { !it.selected },
chapterCount = chapters.size,
missingChapterCount = countMissingChapters(chapters.map { it.chapter.chapterNumber }),
missingChapterCount = chapters.map { it.chapter.chapterNumber }.missingChaptersCount(),
onClick = onFilterButtonClicked,
)
}

View File

@@ -14,13 +14,13 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import eu.kanade.tachiyomi.R
import tachiyomi.presentation.core.util.secondaryItemAlpha
import tachiyomi.presentation.core.components.material.SecondaryItemAlpha
@Composable
fun ChapterHeader(
enabled: Boolean,
chapterCount: Int?,
missingChapterCount: Int?,
missingChapterCount: Int,
onClick: () -> Unit,
) {
Column(
@@ -48,19 +48,16 @@ fun ChapterHeader(
}
@Composable
private fun MissingChaptersWarning(count: Int?) {
val text = when {
count == null -> stringResource(R.string.missing_chapters_unknown)
count > 0 -> pluralStringResource(id = R.plurals.missing_chapters, count = count, count)
else -> return
private fun MissingChaptersWarning(count: Int) {
if (count == 0) {
return
}
Text(
modifier = Modifier.secondaryItemAlpha(),
text = text,
text = pluralStringResource(id = R.plurals.missing_chapters, count = count, count),
maxLines = 1,
overflow = TextOverflow.Ellipsis,
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.error,
color = MaterialTheme.colorScheme.error.copy(alpha = SecondaryItemAlpha),
)
}