diff options
Diffstat (limited to 'packages/meshbay-android/app/src/test/kotlin/org')
| -rw-r--r-- | packages/meshbay-android/app/src/test/kotlin/org/meshbay/client/CastRelayTest.kt | 24 |
1 files changed, 24 insertions, 0 deletions
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 9fe1cfd..e11c8c0 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 @@ -92,6 +92,19 @@ class CastRelayTest { assertArrayEquals(init + fragment(1) + fragment(2), reply.body) } + @Test fun `a first chunk that carries film is served as its header only`() { + // As the page delivers it from a real film: a 64 KB slice holding the + // header, the first moof and the start of its mdat — pushed as well. + val header = box("ftyp", 20) + box("moov", 1200) + val stream = header + fragment(1) + fragment(2) + val firstChunk = stream.copyOfRange(0, header.size + 300) + val started = relay.start(firstChunk, null) + var at = 0 + while (at < stream.size) { val n = minOf(300, stream.size - at); relay.push(stream, at, n); at += n } + val reply = get(started.getString("url"), readBytes = stream.size) + assertArrayEquals("header, then each fragment once", stream, reply.body) + } + @Test fun `the token is required and unguessable`() { val url = relay.start(null, null).getString("url") val token = url.substringAfter("t=") @@ -142,6 +155,17 @@ class CastRelayTest { assertTrue(relay.backlogBytes() >= CastRelay.RING_MAX_BYTES - big.size) } + @Test fun `seek after seek, the relay restarts on its ports`() { + // A seek restarts the relay, and a receiver was connected each time: + // the ports it closed sit in TIME_WAIT. + repeat(8) { + val url = relay.start(null, null).getString("url") + relay.push(fragment(it)) + get(url, readBytes = fragment(it).size) + relay.stop() + } + } + @Test fun `stopping closes the port`() { val url = relay.start(null, null).getString("url") relay.stop() |