aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-android/app/src/test
diff options
context:
space:
mode:
authorChristophe Besson <cbesson@gmail.com>2026-10-19 21:47:34 +0200
committerChristophe Besson <cbesson@gmail.com>2026-10-19 21:47:34 +0200
commit89358ec1e8323d2ce11b4e10e84d0389e806b8dc (patch)
treed7a90e91f7c513a73be5a213325e50c506395cc7 /packages/meshbay-android/app/src/test
parent5e1121fe4f7c2f512d80e71b0fa267bf907c50a1 (diff)
downloadmeshbay-89358ec1e8323d2ce11b4e10e84d0389e806b8dc.tar.gz
fix(android): cast from the Wi-Fi the phone is on, not its hotspotHEADmain
Android 17 lists the phone's own hotspot as a Wi-Fi network; taken first, the television was handed an address it cannot reach. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'packages/meshbay-android/app/src/test')
-rw-r--r--packages/meshbay-android/app/src/test/kotlin/org/meshbay/client/CastLanTest.kt29
1 files changed, 29 insertions, 0 deletions
diff --git a/packages/meshbay-android/app/src/test/kotlin/org/meshbay/client/CastLanTest.kt b/packages/meshbay-android/app/src/test/kotlin/org/meshbay/client/CastLanTest.kt
new file mode 100644
index 00000000..8bdeed15
--- /dev/null
+++ b/packages/meshbay-android/app/src/test/kotlin/org/meshbay/client/CastLanTest.kt
@@ -0,0 +1,29 @@
+package org.meshbay.client
+
+import org.junit.Assert.assertEquals
+import org.junit.Assert.assertNull
+import org.junit.Test
+import org.meshbay.client.cast.CastChannels.Companion.pickLan
+import org.meshbay.client.cast.CastChannels.Lan
+import java.net.InetAddress
+
+/** Which address the relay is offered on, when the phone has more than one Wi-Fi. */
+class CastLanTest {
+ private val hotspot = Lan(InetAddress.getByName("10.105.183.74"), active = false, internet = false)
+ private val home = Lan(InetAddress.getByName("192.168.1.13"), active = true, internet = true)
+
+ @Test fun theWifiThePhoneIsOnWinsOverItsOwnHotspotListedFirst() =
+ assertEquals(home.address, pickLan(listOf(hotspot, home)))
+
+ @Test fun onMobileDataAWifiWithInternetWins() {
+ val wifi = Lan(InetAddress.getByName("192.168.1.13"), active = false, internet = true)
+ assertEquals(wifi.address, pickLan(listOf(hotspot, wifi)))
+ }
+
+ @Test fun aWifiWithoutInternetStillCasts() {
+ val offline = Lan(InetAddress.getByName("192.168.50.2"), active = false, internet = false)
+ assertEquals(offline.address, pickLan(listOf(offline)))
+ }
+
+ @Test fun noWifiNoRelay() = assertNull(pickLan(emptyList()))
+}