mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-22 12:51:49 +01:00
Address unit test compilation errors
They don't actually run since they broke a long time ago (AndroidX + Roboelectric issues?), but it addresses the annoying red squigglies in Android Studio at least.
This commit is contained in:
parent
5f7e34b6a1
commit
0ecfef3f70
@ -3,7 +3,10 @@ package eu.kanade.tachiyomi.ui.reader
|
||||
import android.view.ViewGroup
|
||||
import android.widget.SeekBar
|
||||
import androidx.annotation.ColorInt
|
||||
import androidx.core.graphics.*
|
||||
import androidx.core.graphics.alpha
|
||||
import androidx.core.graphics.blue
|
||||
import androidx.core.graphics.green
|
||||
import androidx.core.graphics.red
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog
|
||||
|
@ -20,6 +20,7 @@ import eu.kanade.tachiyomi.data.database.models.MangaImpl
|
||||
import eu.kanade.tachiyomi.data.database.models.TrackImpl
|
||||
import eu.kanade.tachiyomi.source.SourceManager
|
||||
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
@ -31,7 +32,6 @@ import org.mockito.Mockito.mock
|
||||
import org.robolectric.RuntimeEnvironment
|
||||
import org.robolectric.annotation.Config
|
||||
import rx.Observable
|
||||
import rx.observers.TestSubscriber
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.InjektModule
|
||||
import uy.kohesive.injekt.api.InjektRegistrar
|
||||
@ -211,17 +211,15 @@ class BackupTest {
|
||||
networkManga.description = "This is a description"
|
||||
`when`(source.fetchMangaDetails(jsonManga)).thenReturn(Observable.just(networkManga))
|
||||
|
||||
val obs = legacyBackupManager.fetchManga(source, jsonManga)
|
||||
val testSubscriber = TestSubscriber<Manga>()
|
||||
obs.subscribe(testSubscriber)
|
||||
runBlocking {
|
||||
legacyBackupManager.fetchManga(source, jsonManga)
|
||||
|
||||
testSubscriber.assertNoErrors()
|
||||
|
||||
// Check if restore successful
|
||||
val dbCats = legacyBackupManager.databaseHelper.getFavoriteMangas().executeAsBlocking()
|
||||
assertThat(dbCats).hasSize(1)
|
||||
assertThat(dbCats[0].viewer).isEqualTo(3)
|
||||
assertThat(dbCats[0].description).isEqualTo("This is a description")
|
||||
// Check if restore successful
|
||||
val dbCats = legacyBackupManager.databaseHelper.getFavoriteMangas().executeAsBlocking()
|
||||
assertThat(dbCats).hasSize(1)
|
||||
assertThat(dbCats[0].viewer).isEqualTo(3)
|
||||
assertThat(dbCats[0].description).isEqualTo("This is a description")
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -254,16 +252,13 @@ class BackupTest {
|
||||
(1..10).mapTo(chaptersRemote) { getSingleChapter("Chapter $it") }
|
||||
`when`(source.fetchChapterList(manga)).thenReturn(Observable.just(chaptersRemote))
|
||||
|
||||
// Call restoreChapterFetchObservable
|
||||
val obs = legacyBackupManager.restoreChapters(source, manga, restoredChapters)
|
||||
val testSubscriber = TestSubscriber<Pair<List<Chapter>, List<Chapter>>>()
|
||||
obs.subscribe(testSubscriber)
|
||||
runBlocking {
|
||||
legacyBackupManager.restoreChapters(source, manga, restoredChapters)
|
||||
|
||||
testSubscriber.assertNoErrors()
|
||||
|
||||
val dbCats = legacyBackupManager.databaseHelper.getChapters(manga).executeAsBlocking()
|
||||
assertThat(dbCats).hasSize(10)
|
||||
assertThat(dbCats[0].read).isEqualTo(true)
|
||||
val dbCats = legacyBackupManager.databaseHelper.getChapters(manga).executeAsBlocking()
|
||||
assertThat(dbCats).hasSize(10)
|
||||
assertThat(dbCats[0].read).isEqualTo(true)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -9,8 +9,8 @@ import eu.kanade.tachiyomi.CustomRobolectricGradleTestRunner
|
||||
import eu.kanade.tachiyomi.data.database.models.Chapter
|
||||
import eu.kanade.tachiyomi.data.database.models.LibraryManga
|
||||
import eu.kanade.tachiyomi.source.SourceManager
|
||||
import eu.kanade.tachiyomi.source.model.SChapter
|
||||
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
@ -76,9 +76,11 @@ class LibraryUpdateServiceTest {
|
||||
|
||||
`when`(source.fetchChapterList(manga)).thenReturn(Observable.just(sourceChapters))
|
||||
|
||||
service.updateManga(manga).subscribe()
|
||||
runBlocking {
|
||||
service.updateManga(manga)
|
||||
|
||||
assertThat(service.db.getChapters(manga).executeAsBlocking()).hasSize(2)
|
||||
assertThat(service.db.getChapters(manga).executeAsBlocking()).hasSize(2)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -92,17 +94,19 @@ class LibraryUpdateServiceTest {
|
||||
|
||||
// One of the updates will fail
|
||||
`when`(source.fetchChapterList(favManga[0])).thenReturn(Observable.just(chapters))
|
||||
`when`(source.fetchChapterList(favManga[1])).thenReturn(Observable.error<List<SChapter>>(Exception()))
|
||||
`when`(source.fetchChapterList(favManga[1])).thenReturn(Observable.error(Exception()))
|
||||
`when`(source.fetchChapterList(favManga[2])).thenReturn(Observable.just(chapters3))
|
||||
|
||||
val intent = Intent()
|
||||
val target = LibraryUpdateService.Target.CHAPTERS
|
||||
service.updateChapterList(service.getMangaToUpdate(intent, target)).subscribe()
|
||||
runBlocking {
|
||||
service.updateChapterList(service.getMangaToUpdate(intent, target))
|
||||
|
||||
// There are 3 network attempts and 2 insertions (1 request failed)
|
||||
assertThat(service.db.getChapters(favManga[0]).executeAsBlocking()).hasSize(2)
|
||||
assertThat(service.db.getChapters(favManga[1]).executeAsBlocking()).hasSize(0)
|
||||
assertThat(service.db.getChapters(favManga[2]).executeAsBlocking()).hasSize(2)
|
||||
// There are 3 network attempts and 2 insertions (1 request failed)
|
||||
assertThat(service.db.getChapters(favManga[0]).executeAsBlocking()).hasSize(2)
|
||||
assertThat(service.db.getChapters(favManga[1]).executeAsBlocking()).hasSize(0)
|
||||
assertThat(service.db.getChapters(favManga[2]).executeAsBlocking()).hasSize(2)
|
||||
}
|
||||
}
|
||||
|
||||
private fun createChapters(vararg urls: String): List<Chapter> {
|
||||
|
Loading…
Reference in New Issue
Block a user