From a9364d5881747076463a86bdf010999019b765a6 Mon Sep 17 00:00:00 2001 From: MohitMaliFtechiz Date: Fri, 31 Jan 2025 15:23:35 +0530 Subject: [PATCH] Fixed: The `SearchFragmentTestForCustomApp` was failing sometimes. --- .../custom/search/SearchFragmentTestForCustomApp.kt | 4 ++-- .../java/org/kiwix/kiwixmobile/custom/search/SearchRobot.kt | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/custom/src/androidTest/java/org/kiwix/kiwixmobile/custom/search/SearchFragmentTestForCustomApp.kt b/custom/src/androidTest/java/org/kiwix/kiwixmobile/custom/search/SearchFragmentTestForCustomApp.kt index 8393a86d1..c0307a1ce 100644 --- a/custom/src/androidTest/java/org/kiwix/kiwixmobile/custom/search/SearchFragmentTestForCustomApp.kt +++ b/custom/src/androidTest/java/org/kiwix/kiwixmobile/custom/search/SearchFragmentTestForCustomApp.kt @@ -131,7 +131,7 @@ class SearchFragmentTestForCustomApp { customMainActivity = it } // test with a large ZIM file to properly test the scenario - downloadingZimFile = getDownloadingZimFile() + downloadingZimFile = getDownloadingZimFileFromDataFolder() getOkkHttpClientForTesting().newCall(downloadRequest()).execute().use { response -> if (response.isSuccessful) { response.body?.let { responseBody -> @@ -147,7 +147,7 @@ class SearchFragmentTestForCustomApp { UiThreadStatement.runOnUiThread { customMainActivity.navigate(customMainActivity.readerFragmentResId) } - openZimFileInReaderWithAssetFileDescriptor(downloadingZimFile) + openZimFileInReader(zimFile = downloadingZimFile) openSearchWithQuery() val searchTerm = "gard" val searchedItem = "Gardanta Spirito" diff --git a/custom/src/androidTest/java/org/kiwix/kiwixmobile/custom/search/SearchRobot.kt b/custom/src/androidTest/java/org/kiwix/kiwixmobile/custom/search/SearchRobot.kt index 5b55c26dd..a266d0d07 100644 --- a/custom/src/androidTest/java/org/kiwix/kiwixmobile/custom/search/SearchRobot.kt +++ b/custom/src/androidTest/java/org/kiwix/kiwixmobile/custom/search/SearchRobot.kt @@ -100,14 +100,16 @@ class SearchRobot { } fun searchAndClickOnArticle(searchString: String) { - // wait a bit to properly load the ZIM file in the reader + // Wait a bit to properly load the ZIM file in the reader. BaristaSleepInteractions.sleep(TestUtils.TEST_PAUSE_MS_FOR_SEARCH_TEST.toLong()) openSearchScreen() + // Wait a bit to properly visible the search screen. + BaristaSleepInteractions.sleep(TestUtils.TEST_PAUSE_MS_FOR_SEARCH_TEST.toLong()) searchWithFrequentlyTypedWords(searchString) clickOnSearchItemInSearchList() } - fun clickOnSearchItemInSearchList() { + private fun clickOnSearchItemInSearchList() { testFlakyView({ BaristaSleepInteractions.sleep(TestUtils.TEST_PAUSE_MS_FOR_SEARCH_TEST.toLong()) Espresso.onView(ViewMatchers.withId(R.id.search_list)).perform(