From b572d02e6cc773f90625a7da2da49b79a540f54a Mon Sep 17 00:00:00 2001 From: MohitMaliFtechiz Date: Tue, 12 Dec 2023 22:06:36 +0530 Subject: [PATCH] Fixed HelpFragmentTest and PlayStoreRestrictionTest on api level 24 --- .../kiwixmobile/help/HelpFragmentTest.kt | 41 ++++++++++--------- .../PlayStoreRestrictionDialogTest.kt | 38 +++++++++-------- 2 files changed, 43 insertions(+), 36 deletions(-) diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/help/HelpFragmentTest.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/help/HelpFragmentTest.kt index e58c8d74a..f3c514096 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/help/HelpFragmentTest.kt +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/help/HelpFragmentTest.kt @@ -17,6 +17,7 @@ */ package org.kiwix.kiwixmobile.help +import android.os.Build import androidx.core.content.edit import androidx.lifecycle.Lifecycle import androidx.preference.PreferenceManager @@ -83,26 +84,28 @@ class HelpFragmentTest : BaseActivityTest() { @Test fun verifyHelpActivityWithPlayStoreRestriction() { - setShowPlayStoreRestriction(true) - activityScenario.onActivity { - it.navigate(R.id.helpFragment) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { + setShowPlayStoreRestriction(true) + activityScenario.onActivity { + it.navigate(R.id.helpFragment) + } + help { + clickOnWhatDoesKiwixDo() + assertWhatDoesKiwixDoIsExpanded() + clickOnWhatDoesKiwixDo() + clickOnWhereIsContent() + assertWhereIsContentIsExpanded() + clickOnWhereIsContent() + clickOnHowToUpdateContent() + assertHowToUpdateContentIsExpanded() + clickOnHowToUpdateContent() + clickOnZimFileNotShowing() + assertZimFileNotShowingIsExpanded() + clickOnZimFileNotShowing() + clickOnSendFeedback() + } + LeakAssertions.assertNoLeaks() } - help { - clickOnWhatDoesKiwixDo() - assertWhatDoesKiwixDoIsExpanded() - clickOnWhatDoesKiwixDo() - clickOnWhereIsContent() - assertWhereIsContentIsExpanded() - clickOnWhereIsContent() - clickOnHowToUpdateContent() - assertHowToUpdateContentIsExpanded() - clickOnHowToUpdateContent() - clickOnZimFileNotShowing() - assertZimFileNotShowingIsExpanded() - clickOnZimFileNotShowing() - clickOnSendFeedback() - } - LeakAssertions.assertNoLeaks() } private fun setShowPlayStoreRestriction(showRestriction: Boolean) { diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/nav/destination/PlayStoreRestrictionDialogTest.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/nav/destination/PlayStoreRestrictionDialogTest.kt index b9e651a51..495a4a26b 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/nav/destination/PlayStoreRestrictionDialogTest.kt +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/nav/destination/PlayStoreRestrictionDialogTest.kt @@ -78,29 +78,33 @@ class PlayStoreRestrictionDialogTest { @Test fun showPlayStoreRestrictionDialog() { - setShowPlayStoreRestrictionDialog(true) - activityScenario = ActivityScenario.launch(KiwixMainActivity::class.java).apply { - moveToState(Lifecycle.State.RESUMED) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { + setShowPlayStoreRestrictionDialog(true) + activityScenario = ActivityScenario.launch(KiwixMainActivity::class.java).apply { + moveToState(Lifecycle.State.RESUMED) + } + playStoreRestriction { + clickLibraryOnBottomNav() + assertPlayStoreRestrictionDialogDisplayed() + clickOnUnderstood() + } + LeakAssertions.assertNoLeaks() } - playStoreRestriction { - clickLibraryOnBottomNav() - assertPlayStoreRestrictionDialogDisplayed() - clickOnUnderstood() - } - LeakAssertions.assertNoLeaks() } @Test fun testPlayStoreDialogShowOnlyOnce() { - setShowPlayStoreRestrictionDialog(false) - activityScenario = ActivityScenario.launch(KiwixMainActivity::class.java).apply { - moveToState(Lifecycle.State.RESUMED) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { + setShowPlayStoreRestrictionDialog(false) + activityScenario = ActivityScenario.launch(KiwixMainActivity::class.java).apply { + moveToState(Lifecycle.State.RESUMED) + } + playStoreRestriction { + clickLibraryOnBottomNav() + assetPlayStoreRestrictionDialogNotDisplayed() + } + LeakAssertions.assertNoLeaks() } - playStoreRestriction { - clickLibraryOnBottomNav() - assetPlayStoreRestrictionDialogNotDisplayed() - } - LeakAssertions.assertNoLeaks() } private fun setShowPlayStoreRestrictionDialog(showDialog: Boolean) {