diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderColorFilterSheet.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderColorFilterSheet.kt index 287b21f44..abae0789e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderColorFilterSheet.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderColorFilterSheet.kt @@ -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 diff --git a/app/src/test/java/eu/kanade/tachiyomi/data/backup/BackupTest.kt b/app/src/test/java/eu/kanade/tachiyomi/data/backup/BackupTest.kt index a74b6e502..babbd2406 100644 --- a/app/src/test/java/eu/kanade/tachiyomi/data/backup/BackupTest.kt +++ b/app/src/test/java/eu/kanade/tachiyomi/data/backup/BackupTest.kt @@ -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() - 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, List>>() - 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) + } } /** diff --git a/app/src/test/java/eu/kanade/tachiyomi/data/library/LibraryUpdateServiceTest.kt b/app/src/test/java/eu/kanade/tachiyomi/data/library/LibraryUpdateServiceTest.kt index 044a57013..20483c073 100644 --- a/app/src/test/java/eu/kanade/tachiyomi/data/library/LibraryUpdateServiceTest.kt +++ b/app/src/test/java/eu/kanade/tachiyomi/data/library/LibraryUpdateServiceTest.kt @@ -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>(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 {