Skip to content

Commit

Permalink
We improved the DeppLinksTest to test this functionality, so that we …
Browse files Browse the repository at this point in the history
…can avoid this type of error in the future.
  • Loading branch information
MohitMaliDeveloper committed Sep 20, 2024
1 parent 4e86558 commit 7078aad
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -76,6 +82,7 @@ class DeepLinksTest : BaseActivityTest() {
loadZimFileInApplicationAndReturnSchemeTypeUri("file")?.let {
// Launch the activity to test the deep link
ActivityScenario.launch<KiwixMainActivity>(createDeepLinkIntent(it)).onActivity {}
clickOnCopy()
navigationHistory {
checkZimFileLoadedSuccessful(R.id.readerFragment)
assertZimFileLoaded() // check if the zim file successfully loaded
Expand All @@ -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<KiwixMainActivity>(createDeepLinkIntent(it)).onActivity {}
clickOnCopy()
navigationHistory {
checkZimFileLoadedSuccessful(R.id.readerFragment)
assertZimFileLoaded() // check if the zim file successfully loaded
Expand Down

0 comments on commit 7078aad

Please sign in to comment.