aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-android/app/src/test/kotlin/org/meshbay
diff options
context:
space:
mode:
Diffstat (limited to 'packages/meshbay-android/app/src/test/kotlin/org/meshbay')
-rw-r--r--packages/meshbay-android/app/src/test/kotlin/org/meshbay/client/LocalNetworkTest.kt28
1 files changed, 28 insertions, 0 deletions
diff --git a/packages/meshbay-android/app/src/test/kotlin/org/meshbay/client/LocalNetworkTest.kt b/packages/meshbay-android/app/src/test/kotlin/org/meshbay/client/LocalNetworkTest.kt
new file mode 100644
index 00000000..cc5d3bac
--- /dev/null
+++ b/packages/meshbay-android/app/src/test/kotlin/org/meshbay/client/LocalNetworkTest.kt
@@ -0,0 +1,28 @@
+package org.meshbay.client
+
+import org.junit.Assert.assertEquals
+import org.junit.Test
+import org.meshbay.client.shell.LocalNetwork
+
+class LocalNetworkTest {
+ private fun state(sdk: Int = 37, granted: Boolean = false, asked: Boolean = false, rationale: Boolean = false) =
+ LocalNetwork.stateOf(sdk, granted, asked, rationale)
+
+ @Test fun `before Android 17 the local network comes with the internet`() {
+ assertEquals("granted", state(sdk = 36))
+ assertEquals("granted", state(sdk = 26, asked = true))
+ }
+
+ @Test fun `a permission given is granted`() {
+ assertEquals("granted", state(granted = true))
+ }
+
+ @Test fun `never asked, or refused once, Android still asks`() {
+ assertEquals("prompt", state())
+ assertEquals("prompt", state(asked = true, rationale = true))
+ }
+
+ @Test fun `refused for good, only the settings can change it`() {
+ assertEquals("denied", state(asked = true, rationale = false))
+ }
+}