Settings: "Test the wake word" -- ten seconds of live state and "Heard it"
CI / check (push) Canceled after 0s
CI / check (push) Canceled after 0s
A heard phrase during the test is counted instead of opening the assistant. The test is a deadline in WakeStatus, not a switch, so one that nobody ends cannot leave the wake word deaf. Screenshot tests: the wake word's rows (listening, failed with its reason, tested) and the greeting, name and sensitivity sheets. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
18 files changed
+250
-2
No files matched your search
@@ -7,6 +7,7 @@ import eu.llembas.android.wake.WakeFailure
|
||||
import eu.llembas.android.wake.WakePause
|
||||
import eu.llembas.android.wake.WakePhrases
|
||||
import eu.llembas.android.wake.WakeSensitivity
|
||||
import eu.llembas.android.wake.WakeStatus
|
||||
import eu.llembas.android.wake.WakeWords
|
||||
import eu.llembas.android.wake.checkKeywords
|
||||
import eu.llembas.android.wake.unpackWakeModel
|
||||
@@ -127,6 +128,22 @@ class WakeTest {
|
||||
assertEquals("hey_assistant", Prefs().wakePhrase)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun aTestTakesTheWordForTenSecondsAndNoLonger() {
|
||||
WakeStatus.startTrial(now = 1_000)
|
||||
assertEquals(0, WakeStatus.trial.value.heard)
|
||||
// Heard during the test: counted, and the assistant stays shut.
|
||||
assertTrue(WakeStatus.heardInTrial(now = 4_000))
|
||||
assertTrue(WakeStatus.heardInTrial(now = 10_999))
|
||||
assertEquals(2, WakeStatus.trial.value.heard)
|
||||
// The test is over by itself, whether or not anybody ended it: the word opens the assistant again.
|
||||
assertFalse(WakeStatus.heardInTrial(now = 11_000))
|
||||
assertEquals(2, WakeStatus.trial.value.heard)
|
||||
// A new test starts its count again.
|
||||
WakeStatus.startTrial(now = 20_000)
|
||||
assertEquals(0, WakeStatus.trial.value.heard)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun retriesBackOff() {
|
||||
assertEquals(listOf(2_000L, 5_000L, 15_000L, 60_000L, 300_000L, 300_000L), (0..5).map(::wakeBackoff))
|
||||
|
||||
@@ -56,6 +56,9 @@ import eu.llembas.android.ui.scheduled.RunState
|
||||
import eu.llembas.android.ui.scheduled.ScheduleState
|
||||
import eu.llembas.android.ui.scheduled.ScheduledState
|
||||
import eu.llembas.android.ui.settings.SettingsState
|
||||
import eu.llembas.android.ui.settings.WakeTestShown
|
||||
import eu.llembas.android.wake.WakeFailure
|
||||
import eu.llembas.android.wake.WakeState
|
||||
import kotlinx.serialization.json.jsonObject
|
||||
import java.time.LocalDate
|
||||
|
||||
@@ -357,15 +360,24 @@ object Fakes {
|
||||
val settings = SettingsState(
|
||||
instances = listOf(home, work),
|
||||
active = home,
|
||||
prefs = Prefs(theme = "", assistantTemporary = true, accountLanguage = "en", notificationSummaries = true),
|
||||
prefs = Prefs(theme = "", assistantTemporary = true, accountLanguage = "en", notificationSummaries = true, wakeWord = true, wakePhrase = "ok_google"),
|
||||
hasDistributor = true,
|
||||
version = "1.0.0-beta.3",
|
||||
selfUpdate = true,
|
||||
phoneRecognizer = true,
|
||||
wakeAvailable = true,
|
||||
wakeState = WakeState.Listening("OK Google"),
|
||||
navApps = listOf("google", "osmand"),
|
||||
)
|
||||
|
||||
/** The wake word in trouble, and its test having heard the phrase: what the rows say then. */
|
||||
val settingsWakeFailed = settings.copy(
|
||||
prefs = settings.prefs.copy(wakePhrase = "hey_christopher", wakeSensitivity = "high"),
|
||||
wakeState = WakeState.Failed(WakeFailure.Microphone, "IllegalStateException: recording did not start; another app may have the microphone"),
|
||||
wakeTest = WakeTestShown(done = true),
|
||||
)
|
||||
val settingsWakeTested = settings.copy(wakeTest = WakeTestShown(running = true, heard = 2))
|
||||
|
||||
// The assistant's sheet, as it opens and as it answers.
|
||||
private val assistBase = AssistUiState(
|
||||
instanceName = "Home",
|
||||
|
||||
@@ -62,6 +62,8 @@ import eu.llembas.android.ui.scheduled.SchedulingModelsContent
|
||||
import eu.llembas.android.ui.settings.LanguageChoices
|
||||
import eu.llembas.android.ui.settings.SettingsActions
|
||||
import eu.llembas.android.ui.settings.SettingsContent
|
||||
import eu.llembas.android.ui.settings.WakeChoice
|
||||
import eu.llembas.android.ui.settings.WakeChoices
|
||||
import eu.llembas.android.ui.theme.LocalPalette
|
||||
import eu.llembas.android.ui.viewer.FileBody
|
||||
import org.junit.Test
|
||||
@@ -188,6 +190,19 @@ class ScreenShots {
|
||||
shoot("08-settings", Phone.Small) { SettingsContent(Fakes.settings, NoSettingsActions) }
|
||||
// The whole page: Language, the assistant's switches and Voice input.
|
||||
shoot("08-settings", Phone.Scroll) { SettingsContent(Fakes.settings, NoSettingsActions) }
|
||||
// The wake word's rows: failed with its reason and a test that heard nothing; a test that heard it twice.
|
||||
shoot("08-settings-wake-failed", Phone.Scroll) { SettingsContent(Fakes.settingsWakeFailed, NoSettingsActions) }
|
||||
shoot("08-settings-wake-failed", Phone.SmallScroll, fontScale = 1.5f) { SettingsContent(Fakes.settingsWakeFailed, NoSettingsActions) }
|
||||
shoot("08-settings-wake-tested", Phone.Scroll) { SettingsContent(Fakes.settingsWakeTested, NoSettingsActions) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun wakeChoices() {
|
||||
shoot("08-wake-name", Phone.Scroll) { SheetOver { WakeChoices(WakeChoice.Name, Fakes.settings.prefs, onPick = {}) } }
|
||||
shoot("08-wake-name", Phone.Small, fontScale = 1.5f) { SheetOver { WakeChoices(WakeChoice.Name, Fakes.settings.prefs, onPick = {}) } }
|
||||
shoot("08-wake-greeting") { SheetOver { WakeChoices(WakeChoice.Greeting, Fakes.settings.prefs, onPick = {}) } }
|
||||
shoot("08-wake-sensitivity") { SheetOver { WakeChoices(WakeChoice.Sensitivity, Fakes.settings.prefs, onPick = {}) } }
|
||||
shoot("08-wake-sensitivity", Phone.Small, fontScale = 1.5f) { SheetOver { WakeChoices(WakeChoice.Sensitivity, Fakes.settings.prefs, onPick = {}) } }
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in new issue
Block a user