From 243bcf017b4957237b3ddf556bd0a37296eb8798 Mon Sep 17 00:00:00 2001 From: Christophe Besson Date: Mon, 5 Oct 2026 01:16:12 +0200 Subject: feat(cast): photos on the TV, and a television chosen once for the session A cast button in Videos' toolbar, at the top of Photos, in an album's bar and in the lightbox, in a group and in Search alike. A television chosen there is kept for the session: a film opened plays on it with the player as its remote from the start, and a photo opened in the lightbox is shown on it, scaled to 1920x1080, upright, as JPEG. The lightbox gains a slideshow. The relay serves one photo at /image behind the stream's token, on the desktop and on Android; the shell, not the page, decides that the receiver loads it as a picture. Co-Authored-By: Claude Opus 5.5 --- .../kotlin/org/meshbay/client/CastRelayTest.kt | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'packages/meshbay-android/app/src/test/kotlin/org') diff --git a/packages/meshbay-android/app/src/test/kotlin/org/meshbay/client/CastRelayTest.kt b/packages/meshbay-android/app/src/test/kotlin/org/meshbay/client/CastRelayTest.kt index 5d3125f..8013e29 100644 --- a/packages/meshbay-android/app/src/test/kotlin/org/meshbay/client/CastRelayTest.kt +++ b/packages/meshbay-android/app/src/test/kotlin/org/meshbay/client/CastRelayTest.kt @@ -158,6 +158,34 @@ class CastRelayTest { assertEquals(200, get(r.getString("url"), readBytes = 0).status) } + @Test fun `a photo starts the relay and is served behind the token, re-addressed when it changes`() { + val jpeg = byteArrayOf(0xFF.toByte(), 0xD8.toByte(), 1, 2, 3, 0xFF.toByte(), 0xD9.toByte()) + val first = relay.showImage(jpeg, "image/jpeg").getString("url") + assertTrue(relay.active) + val reply = get(first) + assertEquals(200, reply.status) + assertEquals("image/jpeg", reply.headers["content-type"]) + assertEquals("no-store", reply.headers["cache-control"]) + assertArrayEquals(jpeg, reply.body) + assertEquals(403, get(first.replace(Regex("t=[0-9a-f]+"), "t=x")).status) + // A receiver handed the same address twice shows what it already has. + val second = relay.showImage(byteArrayOf(9), "image/jpeg").getString("url") + assertNotEquals(first, second) + assertArrayEquals(byteArrayOf(9), get(second).body) + } + + @Test fun `only a picture is served as one`() { + val refused = try { relay.showImage(byteArrayOf(1), "text/html"); false } catch (e: IllegalArgumentException) { true } + assertTrue(refused) + assertNull(relay.imageUrl) + } + + @Test fun `a film started over a photo takes the photo down`() { + relay.showImage(byteArrayOf(1), "image/jpeg") + relay.start(null, null) + assertNull(relay.imageUrl) + } + @Test fun `the preflight is answered before the token is checked`() { val url = relay.start(null, null).getString("url") val reply = get(url.substringBefore("?"), method = "OPTIONS") -- cgit v1.2.3