mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-22 12:03:09 -04:00
#716 Merge library tabs "Device" & "Downloading" - amend tests for new flow
This commit is contained in:
parent
44c1952604
commit
96321bc5e6
@ -63,20 +63,13 @@ class ZimManageActivityTest : BaseActivityTest<ZimManageActivity>() {
|
||||
forceResponse("012345678901234567890123456789012345678901234567890123456789012345678")
|
||||
attempt(10) {
|
||||
clickOn(book)
|
||||
waitForEmptyView()
|
||||
clickStop()
|
||||
clickNegativeDialogButton()
|
||||
clickStop()
|
||||
clickPositiveDialogButton()
|
||||
}
|
||||
}
|
||||
clickOnDownloading {
|
||||
clickStop()
|
||||
clickNegativeDialogButton()
|
||||
clickStop()
|
||||
clickPositiveDialogButton()
|
||||
}
|
||||
clickOnOnline {
|
||||
forceResponse("01234")
|
||||
clickOn(book)
|
||||
}
|
||||
clickOnDownloading {
|
||||
waitForEmptyView()
|
||||
}
|
||||
clickOnDevice {
|
||||
@ -90,8 +83,9 @@ class ZimManageActivityTest : BaseActivityTest<ZimManageActivity>() {
|
||||
clickPositiveDialogButton()
|
||||
waitForEmptyView()
|
||||
}
|
||||
clickOnOnline { }
|
||||
} clickOnLanguageIcon { }
|
||||
clickOnOnline {
|
||||
} clickOnLanguageIcon { }
|
||||
}
|
||||
}
|
||||
|
||||
private fun forceResponse(body: String) {
|
||||
|
@ -42,22 +42,11 @@ class ZimManageRobot : BaseRobot() {
|
||||
return library(func)
|
||||
}
|
||||
|
||||
fun clickOnDownloading(func: DownloadRobot.() -> Unit): DownloadRobot {
|
||||
clickOnTab(R.string.zim_downloads)
|
||||
return download(func)
|
||||
}
|
||||
|
||||
fun clickOnDevice(func: DeviceRobot.() -> Unit): DeviceRobot {
|
||||
clickOnTab(R.string.local_zims)
|
||||
return device(func)
|
||||
}
|
||||
|
||||
infix fun clickOnLanguageIcon(function: LanguageRobot.() -> Unit): LanguageRobot {
|
||||
TextId(R.string.remote_zims)
|
||||
clickOn(ViewId(R.id.select_language))
|
||||
return language(function)
|
||||
}
|
||||
|
||||
private fun library(func: LibraryRobot.() -> Unit) = LibraryRobot().apply(func)
|
||||
inner class LibraryRobot : BaseRobot() {
|
||||
init {
|
||||
@ -79,20 +68,15 @@ class ZimManageRobot : BaseRobot() {
|
||||
fun waitForEmptyView() {
|
||||
isVisible(ViewId(R.id.libraryErrorText), VERY_LONG_WAIT)
|
||||
}
|
||||
}
|
||||
|
||||
private fun download(func: DownloadRobot.() -> Unit) = DownloadRobot().apply(func)
|
||||
inner class DownloadRobot : BaseRobot() {
|
||||
init {
|
||||
isVisible(ViewId(R.id.zim_download_root))
|
||||
}
|
||||
|
||||
fun clickStop() {
|
||||
clickOn(ViewId(R.id.stop), LONG_WAIT)
|
||||
}
|
||||
|
||||
fun waitForEmptyView() {
|
||||
isVisible(ViewId(R.id.download_management_no_downloads), 11000L)
|
||||
infix fun clickOnLanguageIcon(function: LanguageRobot.() -> Unit): LanguageRobot {
|
||||
TextId(R.string.remote_zims)
|
||||
clickOn(ViewId(R.id.select_language))
|
||||
return language(function)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,6 @@ import org.kiwix.kiwixmobile.zim_manager.library_view.adapter.LibraryListItem
|
||||
import org.kiwix.sharedFunctions.InstantExecutorExtension
|
||||
import org.kiwix.sharedFunctions.book
|
||||
import org.kiwix.sharedFunctions.bookOnDisk
|
||||
import org.kiwix.sharedFunctions.downloadItem
|
||||
import org.kiwix.sharedFunctions.downloadModel
|
||||
import org.kiwix.sharedFunctions.language
|
||||
import org.kiwix.sharedFunctions.libraryNetworkEntity
|
||||
@ -64,7 +63,6 @@ import org.kiwix.sharedFunctions.resetSchedulers
|
||||
import org.kiwix.sharedFunctions.setScheduler
|
||||
import java.util.Locale
|
||||
import java.util.concurrent.TimeUnit.MILLISECONDS
|
||||
import java.util.concurrent.TimeUnit.SECONDS
|
||||
|
||||
@ExtendWith(InstantExecutorExtension::class)
|
||||
class ZimManageViewModelTest {
|
||||
@ -149,29 +147,6 @@ class ZimManageViewModelTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
inner class Downloads {
|
||||
@Test
|
||||
fun `on emission from database render downloads`() {
|
||||
expectDownloads()
|
||||
viewModel.downloadItems
|
||||
.test()
|
||||
.assertValue(listOf(downloadItem()))
|
||||
}
|
||||
|
||||
private fun expectDownloads(
|
||||
expectedDownloads: List<DownloadModel> = listOf(
|
||||
downloadModel()
|
||||
)
|
||||
) {
|
||||
every { application.getString(any()) } returns ""
|
||||
downloads.offer(expectedDownloads)
|
||||
testScheduler.triggerActions()
|
||||
testScheduler.advanceTimeBy(1, SECONDS)
|
||||
testScheduler.triggerActions()
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
inner class Books {
|
||||
@Test
|
||||
@ -344,7 +319,7 @@ class ZimManageViewModelTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `library update removes from sources`() {
|
||||
fun `library update removes from sources and maps to list items`() {
|
||||
every { application.getString(R.string.your_languages) } returns "1"
|
||||
every { application.getString(R.string.other_languages) } returns "2"
|
||||
val bookAlreadyOnDisk = book(
|
||||
@ -394,7 +369,7 @@ class ZimManageViewModelTest {
|
||||
LibraryListItem.DividerItem(Long.MAX_VALUE, "1"),
|
||||
LibraryListItem.BookItem(bookWithActiveLanguage, CanWrite4GbFile),
|
||||
LibraryListItem.DividerItem(Long.MIN_VALUE, "2"),
|
||||
LibraryListItem.BookItem(bookWithInactiveLanguage, CanWrite4GbFile)
|
||||
LibraryListItem.LibraryDownloadItem(downloadModel(book = bookDownloading))
|
||||
)
|
||||
)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user