feat: PC steuern im neuen Stil, Warteschlange, Playlists, dauerhafte Verbindung (1.3.0)
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
@@ -92,4 +92,40 @@ class PcRemoteTest {
|
||||
assertEquals("1:05", PcRemote.formatTime(65.9))
|
||||
assertEquals("1:01:01", PcRemote.formatTime(3661.0))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun parsesQueueAndKeepsOrder() {
|
||||
val reply = JSONObject(
|
||||
"""{"ok": true, "queue": [
|
||||
{"title": "A", "subtitle": "X", "thumbnail": "https://lh3.googleusercontent.com/a=w60-h60-l90-rj", "current": true},
|
||||
{"title": "", "subtitle": "leer"},
|
||||
{"title": "B", "thumbnail": "http://unsicher", "current": false}
|
||||
]}""",
|
||||
)
|
||||
val queue = PcRemote.parseQueue(reply)
|
||||
assertEquals(3, queue.size)
|
||||
assertEquals(QueueItem("A", "X", "https://lh3.googleusercontent.com/a=w226-h226-l90-rj", true), queue[0])
|
||||
assertEquals(QueueItem("", "leer", "", false), queue[1])
|
||||
assertEquals(QueueItem("B", "", "", false), queue[2])
|
||||
assertTrue(PcRemote.parseQueue(JSONObject("""{"ok": true}""")).isEmpty())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun parsesPlaylists() {
|
||||
val reply = JSONObject("""{"ok": true, "playlists": [{"id": "LM", "title": "Mag ich"}, {"id": "PL1"}, {"title": "x"}]}""")
|
||||
assertEquals(listOf(PcPlaylist("LM", "Mag ich"), PcPlaylist("PL1", "PL1")), PcRemote.parsePlaylists(reply))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun recognisesOldPcsWithoutQueue() {
|
||||
assertTrue(PcRemote.isUnknownCommand("unbekannter Befehl: queue"))
|
||||
assertFalse(PcRemote.isUnknownCommand("Falscher Code"))
|
||||
assertFalse(PcRemote.isUnknownCommand(null))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun readsRepeatMode() {
|
||||
val reply = JSONObject("""{"ok": true, "state": {"activeTab": "music", "tabs": {"music": {"repeatMode": "one"}}}}""")
|
||||
assertEquals("ONE", PcRemote.parseState(reply)!!.repeatMode)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user