feat: implement AI navigation, voice assistant service, and unit tests
Gitea Actions CI/CD Pipeline / build-and-test (push) Failing after 3m53s

This commit is contained in:
2026-08-10 12:04:16 +00:00
parent 905db0da56
commit e4d9cabd76
16 changed files with 474 additions and 21 deletions
@@ -1,6 +1,7 @@
package com.example.voiceapp.domain
import com.example.voiceapp.domain.executor.GetTimeDateExecutor
import com.example.voiceapp.domain.executor.NavigateAiExecutor
import com.example.voiceapp.domain.executor.SetAlarmTimerExecutor
import com.example.voiceapp.domain.model.CommandId
import org.junit.Assert.assertEquals
@@ -13,12 +14,19 @@ class CommandParserTest {
@Before
fun setUp() {
val definitions = listOf(
CommandDefinition(CommandId.NAVIGATE_AI, listOf(Regex(".*(ナビ|行きたい|向かう|セット).*")), NavigateAiExecutor(org.mockito.Mockito.mock(android.content.Context::class.java))),
CommandDefinition(CommandId.GET_TIME_DATE, listOf(Regex(".*(今何時|何時ですか|日付|今日).*")), GetTimeDateExecutor()),
CommandDefinition(CommandId.SET_ALARM_TIMER, listOf(Regex(".*(\\d+)\\s*(分|秒|時間)の?タイマー.*"), Regex(".*(\\d+)\\s*時にアラーム.*")), SetAlarmTimerExecutor())
)
parser = CommandParser(definitions)
}
@Test
fun parse_navigateAi_returnsNavigateAiCommand() {
val result = parser.parse("仕事で行く東京駅に向かう")
assertEquals(CommandId.NAVIGATE_AI, result.commandId)
}
@Test
fun parse_getTime_returnsGetTimeDateCommand() {
val result = parser.parse("今何時?")
@@ -1,5 +1,6 @@
package com.example.voiceapp.domain
import com.example.voiceapp.domain.converter.KanjiToNumberConverter
import com.example.voiceapp.domain.executor.GetTimeDateExecutor
import com.example.voiceapp.domain.model.CommandId
import kotlinx.coroutines.test.runTest
@@ -17,7 +18,8 @@ class ExecuteCommandUseCaseTest {
CommandDefinition(CommandId.GET_TIME_DATE, listOf(Regex(".*(今何時|何時ですか|日付|今日).*")), GetTimeDateExecutor())
)
val parser = CommandParser(definitions)
useCase = ExecuteCommandUseCase(parser)
val kanjiConverter = KanjiToNumberConverter
useCase = ExecuteCommandUseCase(kanjiConverter, parser)
}
@Test
@@ -15,11 +15,13 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.test.StandardTestDispatcher
import kotlinx.coroutines.test.advanceTimeBy
import kotlinx.coroutines.test.resetMain
import kotlinx.coroutines.test.runTest
import kotlinx.coroutines.test.setMain
import org.junit.After
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.Before
import org.junit.Test
@@ -65,4 +67,17 @@ class MainViewModelTest {
assertEquals("現在は10時00分です。", history[1].text)
}
}
@Test
fun errorState_autoResetsToIdleAfter3000ms() = runTest {
recognizerState.value = VoiceRecognitionState.Error(1, "Speech error")
testDispatcher.scheduler.runCurrent()
assertTrue(viewModel.uiState.value is VoiceAppState.Error)
testDispatcher.scheduler.advanceTimeBy(3001)
testDispatcher.scheduler.runCurrent()
assertEquals(VoiceAppState.Idle, viewModel.uiState.value)
}
}