Skip to content

armgit / andee

Public Imported from GitHub
0

Andee lives on your phone or Mac and uses any app like you do—no integrations, no root, any model; memory and passwords never leave your device | Andee 住进你的手机或 Mac,像你一样操作任何 App——无需集成、无需 Root、支持任意模型,记忆和密码绝不离开设备。

Add unit tests for VoiceExitCommand functionality

李融93845bcd3750
diff --git a/app/src/test/java/net/kuafuai/andee/asr/VoiceExitCommandTest.kt b/app/src/test/java/net/kuafuai/andee/asr/VoiceExitCommandTest.kt
new file mode 100644
index 0000000..4a29ee8
--- /dev/null
+++ b/app/src/test/java/net/kuafuai/andee/asr/VoiceExitCommandTest.kt
@@ -0,0 +1,61 @@
+package net.kuafuai.andee.asr
+
+import java.util.Locale
+import org.junit.Assert.assertFalse
+import org.junit.Assert.assertTrue
+import org.junit.Test
+
+class VoiceExitCommandTest {
+ @Test
+ fun `recognizes the requested English exit phrases`() {
+ assertTrue(VoiceExitCommand.matches("Exit Andee"))
+ assertTrue(VoiceExitCommand.matches("Take a break"))
+ assertTrue(VoiceExitCommand.matches("Andee, take a break."))
+ }
+
+ @Test
+ fun `recognizes Chinese and mixed-language speech`() {
+ assertTrue(VoiceExitCommand.matches("退出安迪。"))
+ assertTrue(VoiceExitCommand.matches("关闭 Andee!"))
+ assertTrue(VoiceExitCommand.matches("休息一下"))
+ assertTrue(VoiceExitCommand.matches("安迪,你先休息一下。"))
+ }
+
+ @Test
+ fun `tolerates ASR capitalization spacing and punctuation`() {
+ assertTrue(VoiceExitCommand.matches(" EXIT ANDEE! "))
+ assertTrue(VoiceExitCommand.matches("Take\na\tbreak…"))
+ assertTrue(VoiceExitCommand.matches("安迪,休息一下。"))
+ }
+
+ @Test
+ fun `questions negations and app-specific exit requests remain ordinary turns`() {
+ for (text in listOf(
+ "How do I exit Andee?",
+ "Don't exit Andee",
+ "Say exit Andee",
+ "What does take a break mean?",
+ "Remind me to take a break",
+ "Exit WeChat",
+ "Close the subscription page",
+ "不要退出安迪",
+ "怎么退出 Andee?",
+ "帮我退出微信",
+ "先休息一下,然后帮我回复消息",
+ "", " ", "…",
+ )) {
+ assertFalse(text, VoiceExitCommand.matches(text))
+ }
+ }
+
+ @Test
+ fun `matching does not depend on the device locale`() {
+ val previous = Locale.getDefault()
+ try {
+ Locale.setDefault(Locale("tr", "TR"))
+ assertTrue(VoiceExitCommand.matches("EXIT ANDEE"))
+ } finally {
+ Locale.setDefault(previous)
+ }
+ }
+}