Improved the NavigationHistoryTest, DeepLinksTest, NoteFragmentTest, and ZimFileReaderWithSplittedZimFileTest test cases.

This commit is contained in:
MohitMaliFtechiz 2025-08-06 23:03:44 +05:30
parent 8b446a5200
commit 4f1a442854
5 changed files with 19 additions and 20 deletions

View File

@ -112,8 +112,8 @@ class DeepLinksTest : BaseActivityTest() {
clickOnCopy(composeTestRule)
navigationHistory {
checkZimFileLoadedSuccessful(composeTestRule)
assertZimFileLoaded() // check if the zim file successfully loaded
clickOnAndroidArticle()
assertZimFileLoaded(composeTestRule) // check if the zim file successfully loaded
clickOnAndroidArticle(composeTestRule)
}
} ?: kotlin.run {
// error in getting the zim file Uri
@ -142,8 +142,8 @@ class DeepLinksTest : BaseActivityTest() {
clickOnCopy(composeTestRule)
navigationHistory {
checkZimFileLoadedSuccessful(composeTestRule)
assertZimFileLoaded() // check if the zim file successfully loaded
clickOnAndroidArticle()
assertZimFileLoaded(composeTestRule) // check if the zim file successfully loaded
clickOnAndroidArticle(composeTestRule)
}
} ?: kotlin.run {
// error in getting the zim file Uri

View File

@ -168,7 +168,6 @@ class NoteFragmentTest : BaseActivityTest() {
clickOnSavedNote(composeTestRule)
clickOnOpenNote(composeTestRule)
assertNoteSaved(composeTestRule)
pressBack()
}
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.N_MR1) {
// temporary disabled on Android 25

View File

@ -29,7 +29,6 @@ import androidx.test.espresso.web.webdriver.DriverAtoms.findElement
import androidx.test.espresso.web.webdriver.DriverAtoms.webClick
import androidx.test.espresso.web.webdriver.Locator
import applyWithViewHierarchyPrinting
import com.adevinta.android.barista.interaction.BaristaSleepInteractions
import junit.framework.AssertionFailedError
import org.kiwix.kiwixmobile.BaseRobot
import org.kiwix.kiwixmobile.core.R
@ -76,8 +75,9 @@ class NavigationHistoryRobot : BaseRobot() {
}
}
fun clickOnAndroidArticle() {
pauseForBetterTestPerformance()
fun clickOnAndroidArticle(composeTestRule: ComposeContentTestRule) {
composeTestRule.waitForIdle()
pauseForBetterTestPerformance(composeTestRule)
onWebView()
.withElement(
findElement(
@ -88,8 +88,9 @@ class NavigationHistoryRobot : BaseRobot() {
.perform(webClick())
}
fun assertZimFileLoaded() {
pauseForBetterTestPerformance()
fun assertZimFileLoaded(composeTestRule: ComposeContentTestRule) {
composeTestRule.waitForIdle()
pauseForBetterTestPerformance(composeTestRule)
onWebView()
.withElement(
findElement(
@ -127,7 +128,7 @@ class NavigationHistoryRobot : BaseRobot() {
.assertTextEquals(context.getString(R.string.backward_history))
}
} catch (_: AssertionError) {
pauseForBetterTestPerformance()
pauseForBetterTestPerformance(composeTestRule)
if (retryCountForBackwardNavigationHistory > 0) {
retryCountForBackwardNavigationHistory--
assertBackwardNavigationHistoryDialogDisplayed(composeTestRule)
@ -151,7 +152,7 @@ class NavigationHistoryRobot : BaseRobot() {
.assertTextEquals(context.getString(R.string.forward_history))
}
} catch (_: AssertionError) {
pauseForBetterTestPerformance()
pauseForBetterTestPerformance(composeTestRule)
if (retryCountForForwardNavigationHistory > 0) {
retryCountForForwardNavigationHistory--
assertForwardNavigationHistoryDialogDisplayed(composeTestRule)
@ -160,7 +161,7 @@ class NavigationHistoryRobot : BaseRobot() {
}
fun clickOnDeleteHistory(composeTestRule: ComposeContentTestRule) {
pauseForBetterTestPerformance()
pauseForBetterTestPerformance(composeTestRule)
testFlakyView({
composeTestRule.apply {
waitForIdle()
@ -177,7 +178,7 @@ class NavigationHistoryRobot : BaseRobot() {
.assertTextEquals(context.getString(R.string.clear_all_history_dialog_title))
}
} catch (ignore: AssertionFailedError) {
pauseForBetterTestPerformance()
pauseForBetterTestPerformance(composeTestRule)
if (retryCountForClearNavigationHistory > 0) {
retryCountForClearNavigationHistory--
assertDeleteDialogDisplayed(composeTestRule)
@ -187,8 +188,8 @@ class NavigationHistoryRobot : BaseRobot() {
}
}
private fun pauseForBetterTestPerformance() {
BaristaSleepInteractions.sleep(TestUtils.TEST_PAUSE_MS_FOR_SEARCH_TEST.toLong())
private fun pauseForBetterTestPerformance(composeTestRule: ComposeContentTestRule) {
composeTestRule.waitUntilTimeout(TestUtils.TEST_PAUSE_MS_FOR_SEARCH_TEST.toLong())
}
fun clickOnReaderFragment(composeTestRule: ComposeContentTestRule) {

View File

@ -153,7 +153,7 @@ class NavigationHistoryTest : BaseActivityTest() {
navigationHistory {
closeTabSwitcherIfVisible(composeTestRule)
checkZimFileLoadedSuccessful(composeTestRule)
clickOnAndroidArticle()
clickOnAndroidArticle(composeTestRule)
longClickOnBackwardButton(composeTestRule)
assertBackwardNavigationHistoryDialogDisplayed(composeTestRule)
pressBack()
@ -163,7 +163,6 @@ class NavigationHistoryTest : BaseActivityTest() {
clickOnDeleteHistory(composeTestRule)
assertDeleteDialogDisplayed(composeTestRule)
clickOnCancelButton(composeTestRule)
pressBack()
}
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.N_MR1 &&
Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU

View File

@ -134,8 +134,8 @@ class ZimFileReaderWithSplittedZimFileTest : BaseActivityTest() {
navigationHistory {
checkZimFileLoadedSuccessful(composeTestRule)
clickOnReaderFragment(composeTestRule) // activate the accessibility check to check the issues.
assertZimFileLoaded() // check if the zim file successfully loaded
clickOnAndroidArticle()
assertZimFileLoaded(composeTestRule) // check if the zim file successfully loaded
clickOnAndroidArticle(composeTestRule)
}
} ?: kotlin.run {
// error in creating the zim file chunk