mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-23 12:42:56 -04:00
Improved the NavigationHistoryTest
, DeepLinksTest
, NoteFragmentTest
, and ZimFileReaderWithSplittedZimFileTest
test cases.
This commit is contained in:
parent
8b446a5200
commit
4f1a442854
@ -112,8 +112,8 @@ class DeepLinksTest : BaseActivityTest() {
|
|||||||
clickOnCopy(composeTestRule)
|
clickOnCopy(composeTestRule)
|
||||||
navigationHistory {
|
navigationHistory {
|
||||||
checkZimFileLoadedSuccessful(composeTestRule)
|
checkZimFileLoadedSuccessful(composeTestRule)
|
||||||
assertZimFileLoaded() // check if the zim file successfully loaded
|
assertZimFileLoaded(composeTestRule) // check if the zim file successfully loaded
|
||||||
clickOnAndroidArticle()
|
clickOnAndroidArticle(composeTestRule)
|
||||||
}
|
}
|
||||||
} ?: kotlin.run {
|
} ?: kotlin.run {
|
||||||
// error in getting the zim file Uri
|
// error in getting the zim file Uri
|
||||||
@ -142,8 +142,8 @@ class DeepLinksTest : BaseActivityTest() {
|
|||||||
clickOnCopy(composeTestRule)
|
clickOnCopy(composeTestRule)
|
||||||
navigationHistory {
|
navigationHistory {
|
||||||
checkZimFileLoadedSuccessful(composeTestRule)
|
checkZimFileLoadedSuccessful(composeTestRule)
|
||||||
assertZimFileLoaded() // check if the zim file successfully loaded
|
assertZimFileLoaded(composeTestRule) // check if the zim file successfully loaded
|
||||||
clickOnAndroidArticle()
|
clickOnAndroidArticle(composeTestRule)
|
||||||
}
|
}
|
||||||
} ?: kotlin.run {
|
} ?: kotlin.run {
|
||||||
// error in getting the zim file Uri
|
// error in getting the zim file Uri
|
||||||
|
@ -168,7 +168,6 @@ class NoteFragmentTest : BaseActivityTest() {
|
|||||||
clickOnSavedNote(composeTestRule)
|
clickOnSavedNote(composeTestRule)
|
||||||
clickOnOpenNote(composeTestRule)
|
clickOnOpenNote(composeTestRule)
|
||||||
assertNoteSaved(composeTestRule)
|
assertNoteSaved(composeTestRule)
|
||||||
pressBack()
|
|
||||||
}
|
}
|
||||||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.N_MR1) {
|
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.N_MR1) {
|
||||||
// temporary disabled on Android 25
|
// temporary disabled on Android 25
|
||||||
|
@ -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.DriverAtoms.webClick
|
||||||
import androidx.test.espresso.web.webdriver.Locator
|
import androidx.test.espresso.web.webdriver.Locator
|
||||||
import applyWithViewHierarchyPrinting
|
import applyWithViewHierarchyPrinting
|
||||||
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.core.R
|
import org.kiwix.kiwixmobile.core.R
|
||||||
@ -76,8 +75,9 @@ class NavigationHistoryRobot : BaseRobot() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun clickOnAndroidArticle() {
|
fun clickOnAndroidArticle(composeTestRule: ComposeContentTestRule) {
|
||||||
pauseForBetterTestPerformance()
|
composeTestRule.waitForIdle()
|
||||||
|
pauseForBetterTestPerformance(composeTestRule)
|
||||||
onWebView()
|
onWebView()
|
||||||
.withElement(
|
.withElement(
|
||||||
findElement(
|
findElement(
|
||||||
@ -88,8 +88,9 @@ class NavigationHistoryRobot : BaseRobot() {
|
|||||||
.perform(webClick())
|
.perform(webClick())
|
||||||
}
|
}
|
||||||
|
|
||||||
fun assertZimFileLoaded() {
|
fun assertZimFileLoaded(composeTestRule: ComposeContentTestRule) {
|
||||||
pauseForBetterTestPerformance()
|
composeTestRule.waitForIdle()
|
||||||
|
pauseForBetterTestPerformance(composeTestRule)
|
||||||
onWebView()
|
onWebView()
|
||||||
.withElement(
|
.withElement(
|
||||||
findElement(
|
findElement(
|
||||||
@ -127,7 +128,7 @@ class NavigationHistoryRobot : BaseRobot() {
|
|||||||
.assertTextEquals(context.getString(R.string.backward_history))
|
.assertTextEquals(context.getString(R.string.backward_history))
|
||||||
}
|
}
|
||||||
} catch (_: AssertionError) {
|
} catch (_: AssertionError) {
|
||||||
pauseForBetterTestPerformance()
|
pauseForBetterTestPerformance(composeTestRule)
|
||||||
if (retryCountForBackwardNavigationHistory > 0) {
|
if (retryCountForBackwardNavigationHistory > 0) {
|
||||||
retryCountForBackwardNavigationHistory--
|
retryCountForBackwardNavigationHistory--
|
||||||
assertBackwardNavigationHistoryDialogDisplayed(composeTestRule)
|
assertBackwardNavigationHistoryDialogDisplayed(composeTestRule)
|
||||||
@ -151,7 +152,7 @@ class NavigationHistoryRobot : BaseRobot() {
|
|||||||
.assertTextEquals(context.getString(R.string.forward_history))
|
.assertTextEquals(context.getString(R.string.forward_history))
|
||||||
}
|
}
|
||||||
} catch (_: AssertionError) {
|
} catch (_: AssertionError) {
|
||||||
pauseForBetterTestPerformance()
|
pauseForBetterTestPerformance(composeTestRule)
|
||||||
if (retryCountForForwardNavigationHistory > 0) {
|
if (retryCountForForwardNavigationHistory > 0) {
|
||||||
retryCountForForwardNavigationHistory--
|
retryCountForForwardNavigationHistory--
|
||||||
assertForwardNavigationHistoryDialogDisplayed(composeTestRule)
|
assertForwardNavigationHistoryDialogDisplayed(composeTestRule)
|
||||||
@ -160,7 +161,7 @@ class NavigationHistoryRobot : BaseRobot() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun clickOnDeleteHistory(composeTestRule: ComposeContentTestRule) {
|
fun clickOnDeleteHistory(composeTestRule: ComposeContentTestRule) {
|
||||||
pauseForBetterTestPerformance()
|
pauseForBetterTestPerformance(composeTestRule)
|
||||||
testFlakyView({
|
testFlakyView({
|
||||||
composeTestRule.apply {
|
composeTestRule.apply {
|
||||||
waitForIdle()
|
waitForIdle()
|
||||||
@ -177,7 +178,7 @@ class NavigationHistoryRobot : BaseRobot() {
|
|||||||
.assertTextEquals(context.getString(R.string.clear_all_history_dialog_title))
|
.assertTextEquals(context.getString(R.string.clear_all_history_dialog_title))
|
||||||
}
|
}
|
||||||
} catch (ignore: AssertionFailedError) {
|
} catch (ignore: AssertionFailedError) {
|
||||||
pauseForBetterTestPerformance()
|
pauseForBetterTestPerformance(composeTestRule)
|
||||||
if (retryCountForClearNavigationHistory > 0) {
|
if (retryCountForClearNavigationHistory > 0) {
|
||||||
retryCountForClearNavigationHistory--
|
retryCountForClearNavigationHistory--
|
||||||
assertDeleteDialogDisplayed(composeTestRule)
|
assertDeleteDialogDisplayed(composeTestRule)
|
||||||
@ -187,8 +188,8 @@ class NavigationHistoryRobot : BaseRobot() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun pauseForBetterTestPerformance() {
|
private fun pauseForBetterTestPerformance(composeTestRule: ComposeContentTestRule) {
|
||||||
BaristaSleepInteractions.sleep(TestUtils.TEST_PAUSE_MS_FOR_SEARCH_TEST.toLong())
|
composeTestRule.waitUntilTimeout(TestUtils.TEST_PAUSE_MS_FOR_SEARCH_TEST.toLong())
|
||||||
}
|
}
|
||||||
|
|
||||||
fun clickOnReaderFragment(composeTestRule: ComposeContentTestRule) {
|
fun clickOnReaderFragment(composeTestRule: ComposeContentTestRule) {
|
||||||
|
@ -153,7 +153,7 @@ class NavigationHistoryTest : BaseActivityTest() {
|
|||||||
navigationHistory {
|
navigationHistory {
|
||||||
closeTabSwitcherIfVisible(composeTestRule)
|
closeTabSwitcherIfVisible(composeTestRule)
|
||||||
checkZimFileLoadedSuccessful(composeTestRule)
|
checkZimFileLoadedSuccessful(composeTestRule)
|
||||||
clickOnAndroidArticle()
|
clickOnAndroidArticle(composeTestRule)
|
||||||
longClickOnBackwardButton(composeTestRule)
|
longClickOnBackwardButton(composeTestRule)
|
||||||
assertBackwardNavigationHistoryDialogDisplayed(composeTestRule)
|
assertBackwardNavigationHistoryDialogDisplayed(composeTestRule)
|
||||||
pressBack()
|
pressBack()
|
||||||
@ -163,7 +163,6 @@ class NavigationHistoryTest : BaseActivityTest() {
|
|||||||
clickOnDeleteHistory(composeTestRule)
|
clickOnDeleteHistory(composeTestRule)
|
||||||
assertDeleteDialogDisplayed(composeTestRule)
|
assertDeleteDialogDisplayed(composeTestRule)
|
||||||
clickOnCancelButton(composeTestRule)
|
clickOnCancelButton(composeTestRule)
|
||||||
pressBack()
|
|
||||||
}
|
}
|
||||||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.N_MR1 &&
|
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.N_MR1 &&
|
||||||
Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU
|
Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU
|
||||||
|
@ -134,8 +134,8 @@ class ZimFileReaderWithSplittedZimFileTest : BaseActivityTest() {
|
|||||||
navigationHistory {
|
navigationHistory {
|
||||||
checkZimFileLoadedSuccessful(composeTestRule)
|
checkZimFileLoadedSuccessful(composeTestRule)
|
||||||
clickOnReaderFragment(composeTestRule) // activate the accessibility check to check the issues.
|
clickOnReaderFragment(composeTestRule) // activate the accessibility check to check the issues.
|
||||||
assertZimFileLoaded() // check if the zim file successfully loaded
|
assertZimFileLoaded(composeTestRule) // check if the zim file successfully loaded
|
||||||
clickOnAndroidArticle()
|
clickOnAndroidArticle(composeTestRule)
|
||||||
}
|
}
|
||||||
} ?: kotlin.run {
|
} ?: kotlin.run {
|
||||||
// error in creating the zim file chunk
|
// error in creating the zim file chunk
|
||||||
|
Loading…
x
Reference in New Issue
Block a user