This commit is contained in:
Mitchell Syer
2022-10-22 08:08:14 -04:00
committed by GitHub
parent 3bef07eeab
commit a3c366c360
54 changed files with 159 additions and 109 deletions
@@ -60,9 +60,13 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
}
private fun internalMove(row: Int) {
if (cursor < 0) cursor = 0
else if (cursor > resultSetLength + 1) cursor = resultSetLength + 1
else cursor = row
if (cursor < 0) {
cursor = 0
} else if (cursor > resultSetLength + 1) {
cursor = resultSetLength + 1
} else {
cursor = row
}
}
private fun obj(column: Int): Any? {
@@ -293,10 +297,11 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
}
override fun <T : Any?> unwrap(iface: Class<T>?): T {
if (thisIsWrapperFor(iface))
if (thisIsWrapperFor(iface)) {
return this as T
else
} else {
return parent.unwrap(iface)
}
}
override fun next(): Boolean {
@@ -531,10 +536,15 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
}
private fun castToLong(obj: Any?): Long {
if (obj == null) return 0
else if (obj is Long) return obj
else if (obj is Number) return obj.toLong()
else throw IllegalStateException("Object is not a long!")
if (obj == null) {
return 0
} else if (obj is Long) {
return obj
} else if (obj is Number) {
return obj.toLong()
} else {
throw IllegalStateException("Object is not a long!")
}
}
override fun getLong(columnIndex: Int): Long {
@@ -74,10 +74,11 @@ class PackageController {
fun findPackage(packageName: String): InstalledPackage? {
val file = File(androidFiles.packagesDir, packageName)
return if (file.exists())
return if (file.exists()) {
InstalledPackage(file)
else
} else {
null
}
}
fun findJarFromApk(apkFile: File): File? {
@@ -29,7 +29,6 @@ import uy.kohesive.injekt.api.get
class AppModule(val app: Application) : InjektModule {
override fun InjektRegistrar.registerInjectables() {
addSingleton(app)
// addSingletonFactory { PreferencesHelper(app) }
@@ -23,13 +23,13 @@ import java.util.concurrent.TimeUnit
fun OkHttpClient.Builder.rateLimit(
permits: Int,
period: Long = 1,
unit: TimeUnit = TimeUnit.SECONDS,
unit: TimeUnit = TimeUnit.SECONDS
) = addInterceptor(RateLimitInterceptor(permits, period, unit))
private class RateLimitInterceptor(
private val permits: Int,
period: Long,
unit: TimeUnit,
unit: TimeUnit
) : Interceptor {
private val requestQueue = ArrayList<Long>(permits)
@@ -26,14 +26,14 @@ fun OkHttpClient.Builder.rateLimitHost(
httpUrl: HttpUrl,
permits: Int,
period: Long = 1,
unit: TimeUnit = TimeUnit.SECONDS,
unit: TimeUnit = TimeUnit.SECONDS
) = addInterceptor(SpecificHostRateLimitInterceptor(httpUrl, permits, period, unit))
class SpecificHostRateLimitInterceptor(
httpUrl: HttpUrl,
private val permits: Int,
period: Long,
unit: TimeUnit,
unit: TimeUnit
) : Interceptor {
private val requestQueue = ArrayList<Long>(permits)
@@ -327,8 +327,9 @@ class LocalSource : CatalogueSource {
fun getFormat(chapter: SChapter): Format {
val chapFile = File(applicationDirs.localMangaRoot, chapter.url)
if (chapFile.exists())
if (chapFile.exists()) {
return getFormat(chapFile)
}
throw Exception("Chapter not found")
}
@@ -16,7 +16,7 @@ data class AboutDataClass(
val buildType: String,
val buildTime: Long,
val github: String,
val discord: String,
val discord: String
)
object About {
@@ -28,7 +28,7 @@ object About {
BuildConfig.BUILD_TYPE,
BuildConfig.BUILD_TIME,
BuildConfig.GITHUB,
BuildConfig.DISCORD,
BuildConfig.DISCORD
)
}
}
@@ -46,13 +46,13 @@ object AppUpdate {
UpdateDataClass(
"Stable",
stableJson["tag_name"]!!.jsonPrimitive.content,
stableJson["html_url"]!!.jsonPrimitive.content,
stableJson["html_url"]!!.jsonPrimitive.content
),
UpdateDataClass(
"Preview",
previewJson["tag_name"]!!.jsonPrimitive.content,
previewJson["html_url"]!!.jsonPrimitive.content,
),
previewJson["html_url"]!!.jsonPrimitive.content
)
)
}
}
@@ -84,7 +84,7 @@ object BackupController {
includeCategories = true,
includeChapters = true,
includeTracking = true,
includeHistory = true,
includeHistory = true
)
)
}
@@ -116,7 +116,7 @@ object BackupController {
includeCategories = true,
includeChapters = true,
includeTracking = true,
includeHistory = true,
includeHistory = true
)
)
}
@@ -41,7 +41,9 @@ object Category {
normalizeCategories()
newCategoryId
} else -1
} else {
-1
}
}
}
@@ -86,13 +86,14 @@ object CategoryManga {
dataClass
}
if (categoryId == DEFAULT_CATEGORY_ID)
if (categoryId == DEFAULT_CATEGORY_ID) {
return transaction {
MangaTable
.slice(selectedColumns)
.select { (MangaTable.inLibrary eq true) and (MangaTable.defaultCategory eq true) }
.map(transform)
}
}
return transaction {
CategoryMangaTable.innerJoin(MangaTable)
@@ -45,10 +45,11 @@ import java.io.InputStream
object Manga {
private fun truncate(text: String?, maxLength: Int): String? {
return if (text?.length ?: 0 > maxLength)
return if (text?.length ?: 0 > maxLength) {
text?.take(maxLength - 3) + "..."
else
} else {
text
}
}
suspend fun getManga(mangaId: Int, onlineFetch: Boolean = false): MangaDataClass {
@@ -68,12 +69,12 @@ object Manga {
transaction {
MangaTable.update({ MangaTable.id eq mangaId }) {
if (sManga.title != mangaEntry[MangaTable.title]) {
val canUpdateTitle = updateMangaDownloadDir(mangaId, sManga.title)
if (canUpdateTitle)
if (canUpdateTitle) {
it[MangaTable.title] = sManga.title
}
}
it[MangaTable.initialized] = true
@@ -82,8 +83,9 @@ object Manga {
it[MangaTable.description] = truncate(sManga.description, 4096)
it[MangaTable.genre] = sManga.genre
it[MangaTable.status] = sManga.status
if (sManga.thumbnail_url != null && sManga.thumbnail_url.orEmpty().isNotEmpty())
if (sManga.thumbnail_url != null && sManga.thumbnail_url.orEmpty().isNotEmpty()) {
it[MangaTable.thumbnail_url] = sManga.thumbnail_url
}
it[MangaTable.realUrl] = runCatching {
(source as? HttpSource)?.mangaDetailsRequest(sManga)?.url?.toString()
@@ -78,7 +78,7 @@ object Search {
data class FilterObject(
val type: String,
val filter: Filter<*>,
val filter: Filter<*>
)
fun setFilter(sourceId: Long, changes: List<FilterChange>) {
@@ -48,7 +48,7 @@ object Source {
catalogueSource.supportsLatest,
catalogueSource is ConfigurableSource,
it[SourceTable.isNsfw],
catalogueSource.toString(),
catalogueSource.toString()
)
}
}
@@ -12,5 +12,5 @@ data class BackupFlags(
val includeCategories: Boolean,
val includeChapters: Boolean,
val includeTracking: Boolean,
val includeHistory: Boolean,
val includeHistory: Boolean
)
@@ -69,7 +69,7 @@ object ProtoBackupExport : ProtoBackupBase() {
MangaStatus.valueOf(mangaRow[MangaTable.status]).value,
mangaRow[MangaTable.thumbnail_url],
TimeUnit.SECONDS.toMillis(mangaRow[MangaTable.inLibraryAt]),
0, // not supported in Tachidesk
0 // not supported in Tachidesk
)
val mangaId = mangaRow[MangaTable.id].value
@@ -94,7 +94,7 @@ object ProtoBackupExport : ProtoBackupBase() {
TimeUnit.SECONDS.toMillis(it.fetchedAt),
it.uploadDate,
it.chapterNumber,
chapters.size - it.index,
chapters.size - it.index
)
}
}
@@ -122,7 +122,7 @@ object ProtoBackupExport : ProtoBackupBase() {
BackupCategory(
it.name,
it.order,
0, // not supported in Tachidesk
0 // not supported in Tachidesk
)
}
}
@@ -9,7 +9,7 @@ data class Backup(
@ProtoNumber(2) var backupCategories: List<BackupCategory> = emptyList(),
// Bump by 100 to specify this is a 0.x value
@ProtoNumber(100) var brokenBackupSources: List<BrokenBackupSource> = emptyList(),
@ProtoNumber(101) var backupSources: List<BackupSource> = emptyList(),
@ProtoNumber(101) var backupSources: List<BackupSource> = emptyList()
) {
fun getSourceMap(): Map<Long, String> {
return (brokenBackupSources.map { BackupSource(it.name, it.sourceId) } + backupSources)
@@ -11,7 +11,7 @@ class BackupCategory(
@ProtoNumber(2) var order: Int = 0,
// @ProtoNumber(3) val updateInterval: Int = 0, 1.x value not used in 0.x
// Bump by 100 to specify this is a 0.x value
@ProtoNumber(100) var flags: Int = 0,
@ProtoNumber(100) var flags: Int = 0
) {
fun getCategoryImpl(): CategoryImpl {
return CategoryImpl().apply {
@@ -20,7 +20,7 @@ data class BackupChapter(
@ProtoNumber(8) var dateUpload: Long = 0,
// chapterNumber is called number is 1.x
@ProtoNumber(9) var chapterNumber: Float = 0F,
@ProtoNumber(10) var sourceOrder: Int = 0,
@ProtoNumber(10) var sourceOrder: Int = 0
) {
fun toChapterImpl(): ChapterImpl {
return ChapterImpl().apply {
@@ -35,7 +35,7 @@ data class BackupManga(
@ProtoNumber(101) var chapterFlags: Int = 0,
@ProtoNumber(102) var brokenHistory: List<BrokenBackupHistory> = emptyList(),
@ProtoNumber(103) var viewer_flags: Int? = null,
@ProtoNumber(104) var history: List<BackupHistory> = emptyList(),
@ProtoNumber(104) var history: List<BackupHistory> = emptyList()
) {
fun getMangaImpl(): MangaImpl {
return MangaImpl().apply {
@@ -24,7 +24,7 @@ data class BackupTracking(
// startedReadingDate is called startReadTime in 1.x
@ProtoNumber(10) var startedReadingDate: Long = 0,
// finishedReadingDate is called endReadTime in 1.x
@ProtoNumber(11) var finishedReadingDate: Long = 0,
@ProtoNumber(11) var finishedReadingDate: Long = 0
) {
fun getTrackingImpl(): TrackImpl {
return TrackImpl().apply {
@@ -37,7 +37,6 @@ private class ChapterForDownload(
private val mangaId: Int
) {
suspend fun asDownloadReady(): ChapterDataClass {
if (isNotCompletelyDownloaded()) {
markAsNotDownloaded()
@@ -49,7 +49,8 @@ object DownloadManager {
|Supported commands are:
| - STATUS
| sends the current download status
|""".trimMargin()
|
""".trimMargin()
)
}
}
@@ -65,7 +66,11 @@ object DownloadManager {
return DownloadStatus(
if (downloader == null ||
downloadQueue.none { it.state == Downloading }
) "Stopped" else "Started",
) {
"Stopped"
} else {
"Started"
},
downloadQueue
)
}
@@ -96,8 +101,10 @@ object DownloadManager {
}
fun start() {
if (downloader != null && !downloader?.isAlive!!) // doesn't exist or is dead
if (downloader != null && !downloader?.isAlive!!) {
// doesn't exist or is dead
downloader = null
}
if (downloader == null) {
downloader = Downloader(downloadQueue) { notifyAllClients() }
@@ -127,5 +134,5 @@ object DownloadManager {
enum class DownloaderState(val state: Int) {
Stopped(0),
Running(1),
Paused(2),
Paused(2)
}
@@ -18,5 +18,5 @@ class DownloadChapter(
var manga: MangaDataClass,
var state: DownloadState = Queued,
var progress: Float = 0f,
var tries: Int = 0,
var tries: Int = 0
)
@@ -11,5 +11,5 @@ enum class DownloadState(val state: Int) {
Queued(0),
Downloading(1),
Finished(2),
Error(3),
Error(3)
}
@@ -9,5 +9,5 @@ package suwayomi.tachidesk.manga.impl.download.model
data class DownloadStatus(
val status: String,
val queue: List<DownloadChapter>,
val queue: List<DownloadChapter>
)
@@ -225,12 +225,13 @@ object Extension {
SourceTable.deleteWhere { SourceTable.extension eq extensionId }
if (extensionRecord[ExtensionTable.isObsolete])
if (extensionRecord[ExtensionTable.isObsolete]) {
ExtensionTable.deleteWhere { ExtensionTable.pkgName eq pkgName }
else
} else {
ExtensionTable.update({ ExtensionTable.pkgName eq pkgName }) {
it[isInstalled] = false
}
}
sources
}
@@ -265,8 +266,11 @@ object Extension {
}
suspend fun getExtensionIcon(apkName: String, useCache: Boolean): Pair<InputStream, String> {
val iconUrl = if (apkName == "localSource") ""
else transaction { ExtensionTable.select { ExtensionTable.apkName eq apkName }.first() }[ExtensionTable.iconUrl]
val iconUrl = if (apkName == "localSource") {
""
} else {
transaction { ExtensionTable.select { ExtensionTable.apkName eq apkName }.first() }[ExtensionTable.iconUrl]
}
val saveDir = "${applicationDirs.extensionsRoot}/icon"
@@ -59,7 +59,7 @@ object ExtensionsList {
it[ExtensionTable.isNsfw],
it[ExtensionTable.isInstalled],
it[ExtensionTable.hasUpdate],
it[ExtensionTable.isObsolete],
it[ExtensionTable.isObsolete]
)
}
}
@@ -31,7 +31,7 @@ object ExtensionGithubApi {
val nsfw: Int,
val hasReadme: Int = 0,
val hasChangelog: Int = 0,
val sources: List<ExtensionSourceJsonObject>?,
val sources: List<ExtensionSourceJsonObject>?
)
@Serializable
@@ -32,7 +32,8 @@ object UpdaterSocket : Websocket<UpdateStatus>() {
|Supported commands are:
| - STATUS
| sends the current update status
|""".trimMargin()
|
""".trimMargin()
)
}
}
@@ -67,7 +67,9 @@ object BytecodeEditor {
}
path to bytes
} else null
} else {
null
}
} catch (e: Exception) {
logger.error(e) { "Error loading class from Path: $path" }
null
@@ -172,7 +174,11 @@ object BytecodeEditor {
): MethodVisitor {
logger.trace { "Processing method $name: ${desc.replaceIndirectly()}: $signature" }
val mv: MethodVisitor? = super.visitMethod(
access, name, desc.replaceIndirectly(), signature, exceptions
access,
name,
desc.replaceIndirectly(),
signature,
exceptions
)
return object : MethodVisitor(Opcodes.ASM5, mv) {
override fun visitLdcInsn(cst: Any?) {
@@ -60,7 +60,9 @@ fun updateMangaDownloadDir(mangaId: Int, newTitle: String): Boolean {
val oldDirFile = File(oldDir)
val newDirFile = File(newDir)
return if (oldDirFile.exists())
return if (oldDirFile.exists()) {
oldDirFile.renameTo(newDirFile)
else true
} else {
true
}
}
@@ -37,11 +37,13 @@ private suspend fun <T> Observable<T>.awaitOne(): T = suspendCancellableCoroutin
}
override fun onCompleted() {
if (cont.isActive) cont.resumeWithException(
IllegalStateException(
"Should have invoked onNext"
if (cont.isActive) {
cont.resumeWithException(
IllegalStateException(
"Should have invoked onNext"
)
)
)
}
}
override fun onError(e: Throwable) {
@@ -21,8 +21,9 @@ object ImageResponse {
fun findFileNameStartingWith(directoryPath: String, fileName: String): String? {
val target = "$fileName."
File(directoryPath).listFiles().orEmpty().forEach { file ->
if (file.name.startsWith(target))
if (file.name.startsWith(target)) {
return "$directoryPath/${file.name}"
}
}
return null
}
@@ -44,5 +44,5 @@ data class ChapterDataClass(
val chapterCount: Int? = null,
/** used to store client specific values */
val meta: Map<String, String> = emptyMap(),
val meta: Map<String, String> = emptyMap()
)
@@ -20,5 +20,5 @@ data class ExtensionDataClass(
val installed: Boolean,
val hasUpdate: Boolean,
val obsolete: Boolean,
val obsolete: Boolean
)
@@ -9,5 +9,5 @@ package suwayomi.tachidesk.manga.model.dataclass
data class MangaChapterDataClass(
val manga: MangaDataClass,
val chapter: ChapterDataClass,
val chapter: ChapterDataClass
)
@@ -9,5 +9,5 @@ package suwayomi.tachidesk.manga.model.dataclass
data class PageDataClass(
val index: Int,
var imageUrl: String,
var imageUrl: String
)
@@ -11,7 +11,7 @@ import kotlin.math.min
open class PaginatedList<T>(
val page: List<T>,
val hasNextPage: Boolean,
val hasNextPage: Boolean
)
const val PaginationFactor = 50
@@ -25,5 +25,5 @@ data class SourceDataClass(
val isNsfw: Boolean,
/** A nicer version of [name] */
val displayName: String,
val displayName: String
)
@@ -21,5 +21,5 @@ fun CategoryTable.toDataClass(categoryEntry: ResultRow) = CategoryDataClass(
categoryEntry[this.id].value,
categoryEntry[order],
categoryEntry[name],
categoryEntry[isDefault],
categoryEntry[isDefault]
)
@@ -53,5 +53,5 @@ fun ChapterTable.toDataClass(chapterEntry: ResultRow) =
chapterEntry[isDownloaded],
chapterEntry[pageCount],
transaction { ChapterTable.select { manga eq chapterEntry[manga].value }.count().toInt() },
getChapterMetaMap(chapterEntry[id]),
getChapterMetaMap(chapterEntry[id])
)
@@ -59,7 +59,7 @@ fun MangaTable.toDataClass(mangaEntry: ResultRow) =
mangaEntry[inLibrary],
mangaEntry[inLibraryAt],
meta = getMangaMetaMap(mangaEntry[id].value),
realUrl = mangaEntry[realUrl],
realUrl = mangaEntry[realUrl]
)
enum class MangaStatus(val value: Int) {
@@ -85,7 +85,7 @@ fun applicationSetup() {
applicationDirs.extensionsRoot + "/icon",
applicationDirs.thumbnailsRoot,
applicationDirs.mangaDownloadsRoot,
applicationDirs.localMangaRoot,
applicationDirs.localMangaRoot
).forEach {
File(it).mkdirs()
}
@@ -13,8 +13,8 @@ import org.jetbrains.exposed.dao.id.IdTable
import org.jetbrains.exposed.dao.id.IntIdTable
import org.jetbrains.exposed.sql.Table
@Suppress("ClassName", "unused")
/** initial migration, create all tables */
@Suppress("ClassName", "unused")
class M0001_Initial : AddTableMigration() {
private class ExtensionTable : IntIdTable() {
init {
@@ -128,7 +128,7 @@ class M0001_Initial : AddTableMigration() {
chapterTable,
pageTable,
categoryTable,
categoryMangaTable,
categoryMangaTable
)
}
}
@@ -12,5 +12,5 @@ import de.neonew.exposed.migrations.helpers.DropColumnMigration
@Suppress("ClassName", "unused")
class M0011_SourceDropPartOfFactorySource : DropColumnMigration(
"Source",
"part_of_factory_source",
"part_of_factory_source"
)
@@ -242,7 +242,7 @@ inline fun <reified P1, reified P2, reified P3> handler(
it,
getParam(it, param1),
getParam(it, param2),
getParam(it, param3),
getParam(it, param3)
)
}
)
@@ -265,7 +265,7 @@ inline fun <reified P1, reified P2, reified P3, reified P4> handler(
getParam(it, param1),
getParam(it, param2),
getParam(it, param3),
getParam(it, param4),
getParam(it, param4)
)
}
)
@@ -290,7 +290,7 @@ inline fun <reified P1, reified P2, reified P3, reified P4, reified P5> handler(
getParam(it, param2),
getParam(it, param3),
getParam(it, param4),
getParam(it, param5),
getParam(it, param5)
)
}
)
@@ -317,7 +317,7 @@ inline fun <reified P1, reified P2, reified P3, reified P4, reified P5, reified
getParam(it, param3),
getParam(it, param4),
getParam(it, param5),
getParam(it, param6),
getParam(it, param6)
)
}
)
@@ -346,7 +346,7 @@ inline fun <reified P1, reified P2, reified P3, reified P4, reified P5, reified
getParam(it, param4),
getParam(it, param5),
getParam(it, param6),
getParam(it, param7),
getParam(it, param7)
)
}
)
@@ -377,7 +377,7 @@ inline fun <reified P1, reified P2, reified P3, reified P4, reified P5, reified
getParam(it, param5),
getParam(it, param6),
getParam(it, param7),
getParam(it, param8),
getParam(it, param8)
)
}
)
@@ -410,7 +410,7 @@ inline fun <reified P1, reified P2, reified P3, reified P4, reified P5, reified
getParam(it, param6),
getParam(it, param7),
getParam(it, param8),
getParam(it, param9),
getParam(it, param9)
)
}
)
@@ -445,7 +445,7 @@ inline fun <reified P1, reified P2, reified P3, reified P4, reified P5, reified
getParam(it, param7),
getParam(it, param8),
getParam(it, param9),
getParam(it, param10),
getParam(it, param10)
)
}
)
@@ -103,8 +103,9 @@ fun setupWebUI() {
while (true) {
val count = inp.read(data, 0, 1024)
if (count == -1)
if (count == -1) {
break
}
totalCount += count
val percentage = (totalCount.toFloat() / contentLength * 100).toInt().toString().padStart(2, '0')
@@ -31,12 +31,14 @@ class CategoryMangaTest : ApplicationTest() {
createChapters(mangaId, 10, true)
assertEquals(1, CategoryManga.getCategoryMangaList(DEFAULT_CATEGORY_ID).size, "Default category should have one member")
assertEquals(
0, CategoryManga.getCategoryMangaList(DEFAULT_CATEGORY_ID)[0].unreadCount,
0,
CategoryManga.getCategoryMangaList(DEFAULT_CATEGORY_ID)[0].unreadCount,
"Manga should not have any unread chapters"
)
createChapters(mangaId, 10, false)
assertEquals(
10, CategoryManga.getCategoryMangaList(DEFAULT_CATEGORY_ID)[0].unreadCount,
10,
CategoryManga.getCategoryMangaList(DEFAULT_CATEGORY_ID)[0].unreadCount,
"Manga should have unread chapters"
)
@@ -48,15 +50,18 @@ class CategoryMangaTest : ApplicationTest() {
)
CategoryManga.addMangaToCategory(mangaId, categoryId)
assertEquals(
1, CategoryManga.getCategoryMangaList(categoryId).size,
1,
CategoryManga.getCategoryMangaList(categoryId).size,
"Manga should been moved"
)
assertEquals(
10, CategoryManga.getCategoryMangaList(categoryId)[0].unreadCount,
10,
CategoryManga.getCategoryMangaList(categoryId)[0].unreadCount,
"Manga should keep it's unread count in moved category"
)
assertEquals(
0, CategoryManga.getCategoryMangaList(DEFAULT_CATEGORY_ID).size,
0,
CategoryManga.getCategoryMangaList(DEFAULT_CATEGORY_ID).size,
"Manga shouldn't be member of default category after moving"
)
}
@@ -36,17 +36,20 @@ class MangaTest : ApplicationTest() {
"Manga meta should still only have one pair"
)
assertEquals(
"newValue", Manga.getMangaMetaMap(metaManga)["test"],
"newValue",
Manga.getMangaMetaMap(metaManga)["test"],
"Manga meta with key 'test' should use the value `newValue`"
)
Manga.modifyMangaMeta(metaManga, "test2", "value2")
assertEquals(
2, Manga.getMangaMetaMap(metaManga).size,
2,
Manga.getMangaMetaMap(metaManga).size,
"Manga Meta should have an additional pair"
)
assertEquals(
"value2", Manga.getMangaMetaMap(metaManga)["test2"],
"value2",
Manga.getMangaMetaMap(metaManga)["test2"],
"Manga Meta for key 'test2' should be 'value2'"
)
}
@@ -87,7 +87,8 @@ class FilterListTest : ApplicationTest() {
val filterList = getFilterList(source.id, false)
assertEquals(
0, filterList.size
0,
filterList.size
)
}
@@ -111,7 +112,7 @@ class FilterListTest : ApplicationTest() {
listOf(
TestCheckBox("Write Tests"),
TestCheckBox("Write More Tests"),
TestCheckBox("Write Even More Tests"),
TestCheckBox("Write Even More Tests")
)
),
Sort(
@@ -160,7 +161,7 @@ class FilterListTest : ApplicationTest() {
listOf(
FilterObject("CheckBox", (source.mFilterList[6].state as List<Filter<*>>)[0]),
FilterObject("CheckBox", (source.mFilterList[6].state as List<Filter<*>>)[1]),
FilterObject("CheckBox", (source.mFilterList[6].state as List<Filter<*>>)[2]),
FilterObject("CheckBox", (source.mFilterList[6].state as List<Filter<*>>)[2])
)
)
)
@@ -31,7 +31,7 @@ class PaginatedListTest : ApplicationTest() {
assertEquals(
PaginatedList(listIndicesOf(0, PaginationFactor - 1), false),
paginated,
paginated
)
}
@@ -43,14 +43,14 @@ class PaginatedListTest : ApplicationTest() {
assertEquals(
PaginatedList(listIndicesOf(0, PaginationFactor), true),
firstPage,
firstPage
)
val secondPage = paginatedFrom(1, lister = masterLister)
assertEquals(
PaginatedList(listIndicesOf(PaginationFactor, PaginationFactor * 2 - 1), false),
secondPage,
secondPage
)
}
@@ -62,14 +62,14 @@ class PaginatedListTest : ApplicationTest() {
assertEquals(
PaginatedList(listIndicesOf(0, PaginationFactor), true),
firstPage,
firstPage
)
val secondPage = paginatedFrom(1, lister = masterLister)
assertEquals(
PaginatedList(listIndicesOf(PaginationFactor, PaginationFactor * 2), false),
secondPage,
secondPage
)
}
@@ -81,21 +81,21 @@ class PaginatedListTest : ApplicationTest() {
assertEquals(
PaginatedList(listIndicesOf(0, PaginationFactor), true),
firstPage,
firstPage
)
val secondPage = paginatedFrom(1, lister = masterLister)
assertEquals(
PaginatedList(listIndicesOf(PaginationFactor, PaginationFactor * 2), true),
secondPage,
secondPage
)
val thirdPage = paginatedFrom(2, lister = masterLister)
assertEquals(
PaginatedList(listIndicesOf(PaginationFactor * 2, PaginationFactor * 2 + 1), false),
thirdPage,
thirdPage
)
}
@@ -76,7 +76,7 @@ open class ApplicationTest {
applicationDirs.extensionsRoot + "/icon",
applicationDirs.thumbnailsRoot,
applicationDirs.mangaDownloadsRoot,
applicationDirs.localMangaRoot,
applicationDirs.localMangaRoot
).forEach {
File(it).mkdirs()
}
@@ -23,7 +23,9 @@ fun setLoggingEnabled(enabled: Boolean = true) {
val logger = (KotlinLogging.logger(Logger.ROOT_LOGGER_NAME).underlyingLogger as ch.qos.logback.classic.Logger)
logger.level = if (enabled) {
Level.DEBUG
} else Level.ERROR
} else {
Level.ERROR
}
}
const val BASE_PATH = "build/tmp/TestDesk"