mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-08-03 10:46:53 -04:00
Improved SearchFragmentTest which sometimes failing on API level 34.
* Improved the SearchStateTest which sometimes failing.
This commit is contained in:
parent
07cca85c95
commit
0fe6dd4dbc
@ -226,7 +226,19 @@ class SearchFragmentTest : BaseActivityTest() {
|
||||
kiwixMainActivity = it
|
||||
kiwixMainActivity.navigate(R.id.libraryFragment)
|
||||
}
|
||||
downloadingZimFile = getDownloadingZimFile(false)
|
||||
downloadingZimFile = getDownloadingZimFile()
|
||||
OkHttpClient().newCall(downloadRequest()).execute().use { response ->
|
||||
if (response.isSuccessful) {
|
||||
response.body?.let { responseBody ->
|
||||
writeZimFileData(responseBody, downloadingZimFile)
|
||||
}
|
||||
} else {
|
||||
throw RuntimeException(
|
||||
"Download Failed. Error: ${response.message}\n" +
|
||||
" Status Code: ${response.code}"
|
||||
)
|
||||
}
|
||||
}
|
||||
openKiwixReaderFragmentWithFile(downloadingZimFile)
|
||||
search { checkZimFileSearchSuccessful(R.id.readerFragment) }
|
||||
openSearchWithQuery(searchTerms[0], downloadingZimFile)
|
||||
@ -328,12 +340,10 @@ class SearchFragmentTest : BaseActivityTest() {
|
||||
return zimFile
|
||||
}
|
||||
|
||||
private fun getDownloadingZimFile(isDeletePreviousZimFile: Boolean = true): File {
|
||||
private fun getDownloadingZimFile(): File {
|
||||
val zimFile = File(context.cacheDir, "ray_charles.zim")
|
||||
if (isDeletePreviousZimFile) {
|
||||
if (zimFile.exists()) zimFile.delete()
|
||||
zimFile.createNewFile()
|
||||
}
|
||||
if (zimFile.exists()) zimFile.delete()
|
||||
zimFile.createNewFile()
|
||||
return zimFile
|
||||
}
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ internal class SearchStateTest {
|
||||
val searchIteratorWrapper: SuggestionIteratorWrapper = mockk()
|
||||
val entryWrapper: SuggestionItemWrapper = mockk()
|
||||
|
||||
every { suggestionSearchWrapper.estimatedMatches } returns 100
|
||||
every { suggestionSearchWrapper.estimatedMatches } returns 500
|
||||
every { searchIteratorWrapper.hasNext() } returnsMany listOf(true, false)
|
||||
every { searchIteratorWrapper.next() } returns entryWrapper
|
||||
every { entryWrapper.title } returns "Result"
|
||||
|
Loading…
x
Reference in New Issue
Block a user