Skip to content

Commit

Permalink
NAVAND-2991 - Optimized TextToSpeech usage
Browse files Browse the repository at this point in the history
Unit-test fix
  • Loading branch information
tomaszrybakiewicz committed Jun 20, 2024
1 parent 9d94f8d commit 1901e79
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,19 @@ import android.speech.tts.TextToSpeech.LANG_AVAILABLE
import android.speech.tts.TextToSpeech.LANG_NOT_SUPPORTED
import android.speech.tts.TextToSpeech.OnInitListener
import com.mapbox.navigation.testing.LoggingFrontendTestRule
import com.mapbox.navigation.testing.MainCoroutineRule
import com.mapbox.navigation.ui.voice.model.SpeechAnnouncement
import com.mapbox.navigation.ui.voice.model.SpeechVolume
import com.mapbox.navigation.ui.voice.options.VoiceInstructionsPlayerOptions
import com.mapbox.navigation.utils.internal.InternalJobControlFactory
import com.mapbox.navigation.utils.internal.JobControl
import io.mockk.clearMocks
import io.mockk.every
import io.mockk.mockk
import io.mockk.mockkObject
import io.mockk.unmockkObject
import io.mockk.verify
import kotlinx.coroutines.job
import org.junit.After
import org.junit.Assert.assertEquals
import org.junit.Before
Expand All @@ -25,6 +29,9 @@ import java.util.Locale

class VoiceInstructionsTextPlayerTest {

@get:Rule
var coroutineRule = MainCoroutineRule()

@get:Rule
val loggerRule = LoggingFrontendTestRule()

Expand All @@ -33,6 +40,13 @@ class VoiceInstructionsTextPlayerTest {

@Before
fun setUp() {
mockkObject(InternalJobControlFactory)
every {
InternalJobControlFactory.createDefaultScopeJobControl()
} answers {
val defaultScope = coroutineRule.createTestScope()
JobControl(defaultScope.coroutineContext.job, defaultScope)
}
mockkObject(BundleProvider)
mockkObject(TextToSpeechProvider)
every { BundleProvider.retrieveBundle() } returns mockedBundle
Expand All @@ -41,6 +55,7 @@ class VoiceInstructionsTextPlayerTest {

@After
fun tearDown() {
unmockkObject(InternalJobControlFactory)
unmockkObject(BundleProvider)
unmockkObject(TextToSpeechProvider)
}
Expand Down

0 comments on commit 1901e79

Please sign in to comment.