mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-09 15:27:55 -04:00
Refactored the GetContentShortcutTest
test according to compose UI.
This commit is contained in:
parent
12e17e4d87
commit
7764a6a207
@ -38,6 +38,7 @@ import org.kiwix.kiwixmobile.Findable.StringId.TextId
|
|||||||
import org.kiwix.kiwixmobile.Findable.ViewId
|
import org.kiwix.kiwixmobile.Findable.ViewId
|
||||||
import org.kiwix.kiwixmobile.R
|
import org.kiwix.kiwixmobile.R
|
||||||
import org.kiwix.kiwixmobile.core.R.string
|
import org.kiwix.kiwixmobile.core.R.string
|
||||||
|
import org.kiwix.kiwixmobile.core.page.SEARCH_ICON_TESTING_TAG
|
||||||
import org.kiwix.kiwixmobile.language.composables.LANGUAGE_ITEM_CHECKBOX_TESTING_TAG
|
import org.kiwix.kiwixmobile.language.composables.LANGUAGE_ITEM_CHECKBOX_TESTING_TAG
|
||||||
import org.kiwix.kiwixmobile.testutils.TestUtils
|
import org.kiwix.kiwixmobile.testutils.TestUtils
|
||||||
|
|
||||||
|
@ -18,23 +18,35 @@
|
|||||||
|
|
||||||
package org.kiwix.kiwixmobile.page.history
|
package org.kiwix.kiwixmobile.page.history
|
||||||
|
|
||||||
|
import androidx.compose.ui.test.assertTextEquals
|
||||||
|
import androidx.compose.ui.test.junit4.ComposeTestRule
|
||||||
|
import androidx.compose.ui.test.onNodeWithTag
|
||||||
|
import androidx.compose.ui.test.performClick
|
||||||
import applyWithViewHierarchyPrinting
|
import applyWithViewHierarchyPrinting
|
||||||
import com.adevinta.android.barista.assertion.BaristaVisibilityAssertions.assertDisplayed
|
|
||||||
import org.kiwix.kiwixmobile.BaseRobot
|
import org.kiwix.kiwixmobile.BaseRobot
|
||||||
import org.kiwix.kiwixmobile.Findable.StringId.ContentDesc
|
|
||||||
import org.kiwix.kiwixmobile.Findable.StringId.TextId
|
import org.kiwix.kiwixmobile.Findable.StringId.TextId
|
||||||
import org.kiwix.kiwixmobile.core.R
|
import org.kiwix.kiwixmobile.core.R
|
||||||
|
import org.kiwix.kiwixmobile.core.page.DELETE_MENU_ICON_TESTING_TAG
|
||||||
|
import org.kiwix.kiwixmobile.core.page.SWITCH_TEXT_TESTING_TAG
|
||||||
import org.kiwix.kiwixmobile.testutils.TestUtils.testFlakyView
|
import org.kiwix.kiwixmobile.testutils.TestUtils.testFlakyView
|
||||||
|
|
||||||
fun history(func: HistoryRobot.() -> Unit) = HistoryRobot().applyWithViewHierarchyPrinting(func)
|
fun history(func: HistoryRobot.() -> Unit) = HistoryRobot().applyWithViewHierarchyPrinting(func)
|
||||||
|
|
||||||
class HistoryRobot : BaseRobot() {
|
class HistoryRobot : BaseRobot() {
|
||||||
fun assertHistoryDisplayed() {
|
fun assertHistoryDisplayed(composeTestRule: ComposeTestRule) {
|
||||||
assertDisplayed(R.string.history_from_current_book)
|
composeTestRule.apply {
|
||||||
|
waitForIdle()
|
||||||
|
onNodeWithTag(SWITCH_TEXT_TESTING_TAG)
|
||||||
|
.assertTextEquals(context.getString(R.string.history_from_current_book))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun clickOnTrashIcon() {
|
fun clickOnTrashIcon(composeTestRule: ComposeTestRule) {
|
||||||
clickOn(ContentDesc(R.string.pref_clear_all_history_title))
|
composeTestRule.apply {
|
||||||
|
waitForIdle()
|
||||||
|
onNodeWithTag(DELETE_MENU_ICON_TESTING_TAG)
|
||||||
|
.performClick()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun assertDeleteHistoryDialogDisplayed() {
|
fun assertDeleteHistoryDialogDisplayed() {
|
||||||
|
@ -123,13 +123,13 @@ class GetContentShortcutTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
clickBookmarksOnNavDrawer {
|
clickBookmarksOnNavDrawer {
|
||||||
assertBookMarksDisplayed()
|
assertBookMarksDisplayed(composeTestRule)
|
||||||
clickOnTrashIcon()
|
clickOnTrashIcon(composeTestRule)
|
||||||
assertDeleteBookmarksDialogDisplayed()
|
assertDeleteBookmarksDialogDisplayed()
|
||||||
}
|
}
|
||||||
clickHistoryOnSideNav {
|
clickHistoryOnSideNav {
|
||||||
assertHistoryDisplayed()
|
assertHistoryDisplayed(composeTestRule)
|
||||||
clickOnTrashIcon()
|
clickOnTrashIcon(composeTestRule)
|
||||||
assertDeleteHistoryDialogDisplayed()
|
assertDeleteHistoryDialogDisplayed()
|
||||||
}
|
}
|
||||||
clickHostBooksOnSideNav(ZimHostRobot::assertMenuWifiHotspotDiplayed)
|
clickHostBooksOnSideNav(ZimHostRobot::assertMenuWifiHotspotDiplayed)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user