mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-07 22:31:17 -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 = it
|
||||||
kiwixMainActivity.navigate(R.id.libraryFragment)
|
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)
|
openKiwixReaderFragmentWithFile(downloadingZimFile)
|
||||||
search { checkZimFileSearchSuccessful(R.id.readerFragment) }
|
search { checkZimFileSearchSuccessful(R.id.readerFragment) }
|
||||||
openSearchWithQuery(searchTerms[0], downloadingZimFile)
|
openSearchWithQuery(searchTerms[0], downloadingZimFile)
|
||||||
@ -328,12 +340,10 @@ class SearchFragmentTest : BaseActivityTest() {
|
|||||||
return zimFile
|
return zimFile
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getDownloadingZimFile(isDeletePreviousZimFile: Boolean = true): File {
|
private fun getDownloadingZimFile(): File {
|
||||||
val zimFile = File(context.cacheDir, "ray_charles.zim")
|
val zimFile = File(context.cacheDir, "ray_charles.zim")
|
||||||
if (isDeletePreviousZimFile) {
|
if (zimFile.exists()) zimFile.delete()
|
||||||
if (zimFile.exists()) zimFile.delete()
|
zimFile.createNewFile()
|
||||||
zimFile.createNewFile()
|
|
||||||
}
|
|
||||||
return zimFile
|
return zimFile
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -109,7 +109,7 @@ internal class SearchStateTest {
|
|||||||
val searchIteratorWrapper: SuggestionIteratorWrapper = mockk()
|
val searchIteratorWrapper: SuggestionIteratorWrapper = mockk()
|
||||||
val entryWrapper: SuggestionItemWrapper = mockk()
|
val entryWrapper: SuggestionItemWrapper = mockk()
|
||||||
|
|
||||||
every { suggestionSearchWrapper.estimatedMatches } returns 100
|
every { suggestionSearchWrapper.estimatedMatches } returns 500
|
||||||
every { searchIteratorWrapper.hasNext() } returnsMany listOf(true, false)
|
every { searchIteratorWrapper.hasNext() } returnsMany listOf(true, false)
|
||||||
every { searchIteratorWrapper.next() } returns entryWrapper
|
every { searchIteratorWrapper.next() } returns entryWrapper
|
||||||
every { entryWrapper.title } returns "Result"
|
every { entryWrapper.title } returns "Result"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user