diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/deeplinks/DeepLinksTest.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/deeplinks/DeepLinksTest.kt index 84becb299..eaa3d80ac 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/deeplinks/DeepLinksTest.kt +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/deeplinks/DeepLinksTest.kt @@ -20,9 +20,13 @@ package org.kiwix.kiwixmobile.deeplinks import android.content.Intent import android.net.Uri +import android.os.Build import androidx.core.content.FileProvider import androidx.test.core.app.ActivityScenario +import androidx.test.espresso.Espresso.onView import androidx.test.espresso.accessibility.AccessibilityChecks +import androidx.test.espresso.action.ViewActions.click +import androidx.test.espresso.matcher.ViewMatchers.withText import androidx.test.platform.app.InstrumentationRegistry import androidx.test.uiautomator.UiDevice import org.junit.Before @@ -31,11 +35,13 @@ import org.junit.Test import org.junit.jupiter.api.fail import org.kiwix.kiwixmobile.BaseActivityTest import org.kiwix.kiwixmobile.R +import org.kiwix.kiwixmobile.core.R.string import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil import org.kiwix.kiwixmobile.main.KiwixMainActivity import org.kiwix.kiwixmobile.page.history.navigationHistory import org.kiwix.kiwixmobile.testutils.RetryRule import org.kiwix.kiwixmobile.testutils.TestUtils +import org.kiwix.kiwixmobile.testutils.TestUtils.testFlakyView import java.io.File import java.io.FileOutputStream import java.io.OutputStream @@ -76,6 +82,7 @@ class DeepLinksTest : BaseActivityTest() { loadZimFileInApplicationAndReturnSchemeTypeUri("file")?.let { // Launch the activity to test the deep link ActivityScenario.launch(createDeepLinkIntent(it)).onActivity {} + clickOnCopy() navigationHistory { checkZimFileLoadedSuccessful(R.id.readerFragment) assertZimFileLoaded() // check if the zim file successfully loaded @@ -87,11 +94,20 @@ class DeepLinksTest : BaseActivityTest() { } } + private fun clickOnCopy() { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { + testFlakyView({ + onView(withText(string.action_copy)).perform(click()) + }) + } + } + @Test fun contentTypeDeepLinkTest() { loadZimFileInApplicationAndReturnSchemeTypeUri("content")?.let { // Launch the activity to test the deep link ActivityScenario.launch(createDeepLinkIntent(it)).onActivity {} + clickOnCopy() navigationHistory { checkZimFileLoadedSuccessful(R.id.readerFragment) assertZimFileLoaded() // check if the zim file successfully loaded