mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-23 04:33:54 -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")
|
forceResponse("012345678901234567890123456789012345678901234567890123456789012345678")
|
||||||
attempt(10) {
|
attempt(10) {
|
||||||
clickOn(book)
|
clickOn(book)
|
||||||
waitForEmptyView()
|
clickStop()
|
||||||
|
clickNegativeDialogButton()
|
||||||
|
clickStop()
|
||||||
|
clickPositiveDialogButton()
|
||||||
}
|
}
|
||||||
}
|
|
||||||
clickOnDownloading {
|
|
||||||
clickStop()
|
|
||||||
clickNegativeDialogButton()
|
|
||||||
clickStop()
|
|
||||||
clickPositiveDialogButton()
|
|
||||||
}
|
|
||||||
clickOnOnline {
|
|
||||||
forceResponse("01234")
|
forceResponse("01234")
|
||||||
clickOn(book)
|
clickOn(book)
|
||||||
}
|
|
||||||
clickOnDownloading {
|
|
||||||
waitForEmptyView()
|
waitForEmptyView()
|
||||||
}
|
}
|
||||||
clickOnDevice {
|
clickOnDevice {
|
||||||
@ -90,8 +83,9 @@ class ZimManageActivityTest : BaseActivityTest<ZimManageActivity>() {
|
|||||||
clickPositiveDialogButton()
|
clickPositiveDialogButton()
|
||||||
waitForEmptyView()
|
waitForEmptyView()
|
||||||
}
|
}
|
||||||
clickOnOnline { }
|
clickOnOnline {
|
||||||
} clickOnLanguageIcon { }
|
} clickOnLanguageIcon { }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun forceResponse(body: String) {
|
private fun forceResponse(body: String) {
|
||||||
|
@ -42,22 +42,11 @@ class ZimManageRobot : BaseRobot() {
|
|||||||
return library(func)
|
return library(func)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun clickOnDownloading(func: DownloadRobot.() -> Unit): DownloadRobot {
|
|
||||||
clickOnTab(R.string.zim_downloads)
|
|
||||||
return download(func)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun clickOnDevice(func: DeviceRobot.() -> Unit): DeviceRobot {
|
fun clickOnDevice(func: DeviceRobot.() -> Unit): DeviceRobot {
|
||||||
clickOnTab(R.string.local_zims)
|
clickOnTab(R.string.local_zims)
|
||||||
return device(func)
|
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)
|
private fun library(func: LibraryRobot.() -> Unit) = LibraryRobot().apply(func)
|
||||||
inner class LibraryRobot : BaseRobot() {
|
inner class LibraryRobot : BaseRobot() {
|
||||||
init {
|
init {
|
||||||
@ -79,20 +68,15 @@ class ZimManageRobot : BaseRobot() {
|
|||||||
fun waitForEmptyView() {
|
fun waitForEmptyView() {
|
||||||
isVisible(ViewId(R.id.libraryErrorText), VERY_LONG_WAIT)
|
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() {
|
fun clickStop() {
|
||||||
clickOn(ViewId(R.id.stop), LONG_WAIT)
|
clickOn(ViewId(R.id.stop), LONG_WAIT)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun waitForEmptyView() {
|
infix fun clickOnLanguageIcon(function: LanguageRobot.() -> Unit): LanguageRobot {
|
||||||
isVisible(ViewId(R.id.download_management_no_downloads), 11000L)
|
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.InstantExecutorExtension
|
||||||
import org.kiwix.sharedFunctions.book
|
import org.kiwix.sharedFunctions.book
|
||||||
import org.kiwix.sharedFunctions.bookOnDisk
|
import org.kiwix.sharedFunctions.bookOnDisk
|
||||||
import org.kiwix.sharedFunctions.downloadItem
|
|
||||||
import org.kiwix.sharedFunctions.downloadModel
|
import org.kiwix.sharedFunctions.downloadModel
|
||||||
import org.kiwix.sharedFunctions.language
|
import org.kiwix.sharedFunctions.language
|
||||||
import org.kiwix.sharedFunctions.libraryNetworkEntity
|
import org.kiwix.sharedFunctions.libraryNetworkEntity
|
||||||
@ -64,7 +63,6 @@ import org.kiwix.sharedFunctions.resetSchedulers
|
|||||||
import org.kiwix.sharedFunctions.setScheduler
|
import org.kiwix.sharedFunctions.setScheduler
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
import java.util.concurrent.TimeUnit.MILLISECONDS
|
import java.util.concurrent.TimeUnit.MILLISECONDS
|
||||||
import java.util.concurrent.TimeUnit.SECONDS
|
|
||||||
|
|
||||||
@ExtendWith(InstantExecutorExtension::class)
|
@ExtendWith(InstantExecutorExtension::class)
|
||||||
class ZimManageViewModelTest {
|
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
|
@Nested
|
||||||
inner class Books {
|
inner class Books {
|
||||||
@Test
|
@Test
|
||||||
@ -344,7 +319,7 @@ class ZimManageViewModelTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@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.your_languages) } returns "1"
|
||||||
every { application.getString(R.string.other_languages) } returns "2"
|
every { application.getString(R.string.other_languages) } returns "2"
|
||||||
val bookAlreadyOnDisk = book(
|
val bookAlreadyOnDisk = book(
|
||||||
@ -394,7 +369,7 @@ class ZimManageViewModelTest {
|
|||||||
LibraryListItem.DividerItem(Long.MAX_VALUE, "1"),
|
LibraryListItem.DividerItem(Long.MAX_VALUE, "1"),
|
||||||
LibraryListItem.BookItem(bookWithActiveLanguage, CanWrite4GbFile),
|
LibraryListItem.BookItem(bookWithActiveLanguage, CanWrite4GbFile),
|
||||||
LibraryListItem.DividerItem(Long.MIN_VALUE, "2"),
|
LibraryListItem.DividerItem(Long.MIN_VALUE, "2"),
|
||||||
LibraryListItem.BookItem(bookWithInactiveLanguage, CanWrite4GbFile)
|
LibraryListItem.LibraryDownloadItem(downloadModel(book = bookDownloading))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user