Fixed sometimes CI fails in LanguageFragmentTest

This commit is contained in:
MohitMali 2022-12-19 12:46:12 +05:30 committed by Kelson
parent d9f49fe8bf
commit 9a74f2abf2
2 changed files with 5 additions and 7 deletions

View File

@ -25,7 +25,6 @@ import androidx.preference.PreferenceManager
import androidx.test.ext.junit.rules.ActivityScenarioRule import androidx.test.ext.junit.rules.ActivityScenarioRule
import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.LargeTest import androidx.test.filters.LargeTest
import androidx.test.internal.runner.junit4.statement.UiThreadStatement
import androidx.test.platform.app.InstrumentationRegistry import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.rule.GrantPermissionRule import androidx.test.rule.GrantPermissionRule
import androidx.test.uiautomator.UiDevice import androidx.test.uiautomator.UiDevice
@ -33,7 +32,6 @@ import org.junit.Before
import org.junit.Rule import org.junit.Rule
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith import org.junit.runner.RunWith
import org.kiwix.kiwixmobile.R
import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil
import org.kiwix.kiwixmobile.main.KiwixMainActivity import org.kiwix.kiwixmobile.main.KiwixMainActivity
@ -69,13 +67,9 @@ class LanguageFragmentTest {
@Test @Test
fun testLanguageFragment() { fun testLanguageFragment() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) {
UiThreadStatement.runOnUiThread {
activityScenarioRule.scenario.onActivity {
it.navigate(R.id.downloadsFragment)
}
}
language { language {
clickDownloadOnBottomNav()
waitForDataToLoad() waitForDataToLoad()
// search and de-select if german language already selected // search and de-select if german language already selected

View File

@ -38,6 +38,10 @@ class LanguageRobot : BaseRobot() {
private var retryCountForDataToLoad = 5 private var retryCountForDataToLoad = 5
fun clickDownloadOnBottomNav() {
clickOn(ViewId(R.id.downloadsFragment))
}
fun waitForDataToLoad() { fun waitForDataToLoad() {
try { try {
isVisible(Findable.Text("Off the Grid")) isVisible(Findable.Text("Off the Grid"))