mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-24 05:04:50 -04:00
Refactored the OpenSearchItemTest unit test.
* Fixed: ZimHostFragmentTest UI test.
This commit is contained in:
parent
7b03c5da3e
commit
8b446a5200
@ -162,7 +162,7 @@ class ZimHostFragmentTest {
|
|||||||
zimHost {
|
zimHost {
|
||||||
refreshLibraryList(composeTestRule)
|
refreshLibraryList(composeTestRule)
|
||||||
assertZimFilesLoaded(composeTestRule)
|
assertZimFilesLoaded(composeTestRule)
|
||||||
openZimHostFragment(kiwixMainActivity as CoreMainActivity)
|
openZimHostFragment(kiwixMainActivity as CoreMainActivity, composeTestRule)
|
||||||
|
|
||||||
// Check if server is already started
|
// Check if server is already started
|
||||||
stopServerIfAlreadyStarted(composeTestRule)
|
stopServerIfAlreadyStarted(composeTestRule)
|
||||||
|
@ -31,9 +31,9 @@ import applyWithViewHierarchyPrinting
|
|||||||
import com.adevinta.android.barista.interaction.BaristaSleepInteractions
|
import com.adevinta.android.barista.interaction.BaristaSleepInteractions
|
||||||
import junit.framework.AssertionFailedError
|
import junit.framework.AssertionFailedError
|
||||||
import org.kiwix.kiwixmobile.BaseRobot
|
import org.kiwix.kiwixmobile.BaseRobot
|
||||||
import org.kiwix.kiwixmobile.Findable.StringId.TextId
|
|
||||||
import org.kiwix.kiwixmobile.core.R
|
import org.kiwix.kiwixmobile.core.R
|
||||||
import org.kiwix.kiwixmobile.core.main.CoreMainActivity
|
import org.kiwix.kiwixmobile.core.main.CoreMainActivity
|
||||||
|
import org.kiwix.kiwixmobile.core.main.LEFT_DRAWER_ZIM_HOST_ITEM_TESTING_TAG
|
||||||
import org.kiwix.kiwixmobile.core.ui.components.TOOLBAR_TITLE_TESTING_TAG
|
import org.kiwix.kiwixmobile.core.ui.components.TOOLBAR_TITLE_TESTING_TAG
|
||||||
import org.kiwix.kiwixmobile.core.utils.dialog.ALERT_DIALOG_NATURAL_BUTTON_TESTING_TAG
|
import org.kiwix.kiwixmobile.core.utils.dialog.ALERT_DIALOG_NATURAL_BUTTON_TESTING_TAG
|
||||||
import org.kiwix.kiwixmobile.core.utils.dialog.ALERT_DIALOG_TITLE_TEXT_TESTING_TAG
|
import org.kiwix.kiwixmobile.core.utils.dialog.ALERT_DIALOG_TITLE_TEXT_TESTING_TAG
|
||||||
@ -69,9 +69,17 @@ class ZimHostRobot : BaseRobot() {
|
|||||||
zimFileNodes.assertCountEquals(2)
|
zimFileNodes.assertCountEquals(2)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun openZimHostFragment(coreMainActivity: CoreMainActivity) {
|
fun openZimHostFragment(
|
||||||
|
coreMainActivity: CoreMainActivity,
|
||||||
|
composeTestRule: ComposeContentTestRule
|
||||||
|
) {
|
||||||
openDrawer(coreMainActivity)
|
openDrawer(coreMainActivity)
|
||||||
clickOn(TextId(R.string.menu_wifi_hotspot))
|
testFlakyView({
|
||||||
|
composeTestRule.apply {
|
||||||
|
waitForIdle()
|
||||||
|
onNodeWithTag(LEFT_DRAWER_ZIM_HOST_ITEM_TESTING_TAG).performClick()
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fun clickOnTestZim(composeTestRule: ComposeContentTestRule) {
|
fun clickOnTestZim(composeTestRule: ComposeContentTestRule) {
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
package org.kiwix.kiwixmobile.core.search.viewmodel.effects
|
package org.kiwix.kiwixmobile.core.search.viewmodel.effects
|
||||||
|
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import androidx.navigation.NavOptions
|
||||||
import io.mockk.every
|
import io.mockk.every
|
||||||
import io.mockk.mockk
|
import io.mockk.mockk
|
||||||
import io.mockk.mockkConstructor
|
import io.mockk.mockkConstructor
|
||||||
@ -45,7 +45,10 @@ internal class OpenSearchItemTest {
|
|||||||
} returns intent
|
} returns intent
|
||||||
OpenSearchItem(searchListItem, false).invokeWith(activity)
|
OpenSearchItem(searchListItem, false).invokeWith(activity)
|
||||||
verify {
|
verify {
|
||||||
activity.navigate(activity.readerFragmentResId, any<Bundle>())
|
activity.navigate(
|
||||||
|
"${activity.readerFragmentRoute}?searchItemTitle=searchItemTitle",
|
||||||
|
any<NavOptions>()
|
||||||
|
)
|
||||||
activity.setNavigationResultOnCurrent(
|
activity.setNavigationResultOnCurrent(
|
||||||
SearchItemToOpen(searchListItem.value, false, ZimFileReader.CONTENT_PREFIX),
|
SearchItemToOpen(searchListItem.value, false, ZimFileReader.CONTENT_PREFIX),
|
||||||
TAG_FILE_SEARCHED
|
TAG_FILE_SEARCHED
|
||||||
@ -65,7 +68,10 @@ internal class OpenSearchItemTest {
|
|||||||
} returns intent
|
} returns intent
|
||||||
OpenSearchItem(searchListItem, true).invokeWith(activity)
|
OpenSearchItem(searchListItem, true).invokeWith(activity)
|
||||||
verify {
|
verify {
|
||||||
activity.navigate(activity.readerFragmentResId, any<Bundle>())
|
activity.navigate(
|
||||||
|
"${activity.readerFragmentRoute}?searchItemTitle=searchItemTitle",
|
||||||
|
any<NavOptions>()
|
||||||
|
)
|
||||||
activity.setNavigationResultOnCurrent(
|
activity.setNavigationResultOnCurrent(
|
||||||
SearchItemToOpen(searchListItem.value, true, ZimFileReader.CONTENT_PREFIX),
|
SearchItemToOpen(searchListItem.value, true, ZimFileReader.CONTENT_PREFIX),
|
||||||
TAG_FILE_SEARCHED
|
TAG_FILE_SEARCHED
|
||||||
|
Loading…
x
Reference in New Issue
Block a user