Skip to content

Commit ed5aa32

Browse files
committed
[CleanUp]:remove runBlocking warning in cardBrowser.kt by converting searchCards to suspend function
1 parent 62a0aa9 commit ed5aa32

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

AnkiDroid/src/test/java/com/ichi2/anki/CardBrowserTest.kt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,9 @@ class CardBrowserTest : RobolectricTest() {
878878
viewModel.changeCardOrder(SortType.EASE) // reverse the list
879879

880880
viewModel.setCardsOrNotes(NOTES)
881-
searchCards()
881+
runTest{
882+
searchCards()
883+
}
882884

883885
assertThat(
884886
"Card Browser has the new noteSortType field",
@@ -1011,7 +1013,9 @@ class CardBrowserTest : RobolectricTest() {
10111013
val cardBrowser = getBrowserWithNotes(3, true)
10121014

10131015
cardBrowser.viewModel.setCardsOrNotes(CARDS)
1014-
cardBrowser.searchCards()
1016+
runTest {
1017+
cardBrowser.searchCards()
1018+
}
10151019

10161020
advanceRobolectricLooper()
10171021
// check if we get both cards of each note
@@ -1681,13 +1685,14 @@ val CardBrowser.columnHeadings
16811685
get() =
16821686
columnHeadingViews.map { it.text.toString() }
16831687

1684-
fun CardBrowser.searchCards(search: String? = null) {
1688+
suspend fun CardBrowser.searchCards(search: String? = null) {
16851689
if (search != null) {
16861690
viewModel.launchSearchForCards(search)
16871691
} else {
16881692
viewModel.launchSearchForCards()
16891693
}
1690-
runBlocking { viewModel.searchJob?.join() }
1694+
viewModel.searchJob?.join()
16911695
}
16921696

1697+
16931698
fun CardBrowser.showFindAndReplaceDialog() = cardBrowserFragment.showFindAndReplaceDialog()

0 commit comments

Comments
 (0)