Skip to content

Commit

Permalink
Close mozilla-mobile#20797: Fix intermittent test failures in Shortcu…
Browse files Browse the repository at this point in the history
…tsSuggestionProviderTest
  • Loading branch information
jonalmeida committed Aug 12, 2021
1 parent d3e2036 commit d038864
Showing 1 changed file with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import io.mockk.every
import io.mockk.mockk
import io.mockk.mockkStatic
import io.mockk.unmockkStatic
import io.mockk.verifySequence
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.runBlockingTest
import mozilla.components.browser.state.search.SearchEngine
Expand All @@ -19,6 +18,7 @@ import mozilla.components.browser.state.state.SearchState
import mozilla.components.browser.state.store.BrowserStore
import org.junit.After
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.Before
import org.junit.Ignore
import org.junit.Test
Expand Down Expand Up @@ -63,9 +63,10 @@ class ShortcutsSuggestionProviderTest {
)
)
)
val provider = ShortcutsSuggestionProvider(store, context, mockk(), mockk())
val provider = ShortcutsSuggestionProvider(store, context, {}, {})

val suggestions = provider.onInputChanged("")

assertEquals(3, suggestions.size)

assertEquals(provider, suggestions[0].provider)
Expand Down Expand Up @@ -95,13 +96,13 @@ class ShortcutsSuggestionProviderTest {
)
)

val selectShortcutEngine = mockk<(SearchEngine) -> Unit>(relaxed = true)
val selectShortcutEngineSettings = mockk<() -> Unit>(relaxed = true)
var selectEngine: SearchEngine? = null
var selectShortcutEngineSettingsChanged = false
val provider = ShortcutsSuggestionProvider(
store,
context,
selectShortcutEngine,
selectShortcutEngineSettings
{ selectEngine = it },
{ selectShortcutEngineSettingsChanged = true }
)

val suggestions = provider.onInputChanged("")
Expand All @@ -110,9 +111,7 @@ class ShortcutsSuggestionProviderTest {
suggestions[0].onSuggestionClicked?.invoke()
suggestions[1].onSuggestionClicked?.invoke()

verifySequence {
selectShortcutEngine(engineOne)
selectShortcutEngineSettings()
}
assertEquals(engineOne, selectEngine)
assertTrue(selectShortcutEngineSettingsChanged)
}
}

0 comments on commit d038864

Please sign in to comment.