refactor: consolidate QR code scanning methods

This commit is contained in:
andrekir
2024-11-20 18:40:24 -03:00
committed by Andre K
parent 75003bb6f0
commit f73d909cd0
44 changed files with 89 additions and 226 deletions

View File

@@ -3,7 +3,6 @@ package com.geeksville.mesh
import android.net.Uri
import com.geeksville.mesh.model.getChannelUrl
import com.geeksville.mesh.model.primaryChannel
import com.geeksville.mesh.model.shouldAddChannels
import com.geeksville.mesh.model.toChannelSet
import dagger.hilt.android.testing.HiltAndroidRule
import dagger.hilt.android.testing.HiltAndroidTest
@@ -47,9 +46,8 @@ class ChannelSetTest {
fun handleAddInFragment() {
val url = Uri.parse("https://meshtastic.org/e/#CgMSAQESBggBQANIAQ?add=true")
val cs = url.toChannelSet()
val shouldAdd = url.shouldAddChannels()
Assert.assertEquals("LongFast", cs.primaryChannel!!.name)
Assert.assertTrue(shouldAdd)
Assert.assertEquals("Custom", cs.primaryChannel!!.name)
Assert.assertFalse(cs.hasLoraConfig())
}
/** properly parse channel config when `?add=true` is in the query parameters */
@@ -57,8 +55,7 @@ class ChannelSetTest {
fun handleAddInQueryParams() {
val url = Uri.parse("https://meshtastic.org/e/?add=true#CgMSAQESBggBQANIAQ")
val cs = url.toChannelSet()
val shouldAdd = url.shouldAddChannels()
Assert.assertEquals("LongFast", cs.primaryChannel!!.name)
Assert.assertTrue(shouldAdd)
Assert.assertEquals("Custom", cs.primaryChannel!!.name)
Assert.assertFalse(cs.hasLoraConfig())
}
}