mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
use unmock to test and fix the channel suffix generation to match device
This commit is contained in:
parent
c405cdc200
commit
699d5076b5
6 changed files with 68 additions and 50 deletions
|
|
@ -8,9 +8,10 @@ import org.junit.Test
|
|||
import java.util.*
|
||||
|
||||
class NodeInfoTest {
|
||||
val ni1 = NodeInfo(4, MeshUser("+one", "User One", "U1"), Position(37.1, 121.1, 35))
|
||||
val ni2 = NodeInfo(5, MeshUser("+two", "User Two", "U2"), Position(37.11, 121.1, 40))
|
||||
val ni3 = NodeInfo(6, MeshUser("+three", "User Three", "U3"), Position(37.101, 121.1, 40))
|
||||
val model = MeshProtos.HardwareModel.ANDROID_SIM
|
||||
val ni1 = NodeInfo(4, MeshUser("+one", "User One", "U1", model), Position(37.1, 121.1, 35))
|
||||
val ni2 = NodeInfo(5, MeshUser("+two", "User Two", "U2", model), Position(37.11, 121.1, 40))
|
||||
val ni3 = NodeInfo(6, MeshUser("+three", "User Three", "U3", model), Position(37.101, 121.1, 40))
|
||||
|
||||
private val currentDefaultLocale = LocaleListCompat.getDefault().get(0)
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
package com.geeksville.mesh.model
|
||||
|
||||
import android.net.Uri
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
|
||||
class ChannelSetTest {
|
||||
/** make sure we match the python and device code behavior */
|
||||
@Test
|
||||
fun matchPython() {
|
||||
val url = Uri.parse("https://www.meshtastic.org/d/#CgUYAyIBAQ")
|
||||
val cs = ChannelSet(url)
|
||||
Assert.assertEquals("LongSlow", cs.primaryChannel!!.name, )
|
||||
Assert.assertEquals("#LongSlow-V", cs.primaryChannel!!.humanName, )
|
||||
}
|
||||
}
|
||||
|
|
@ -1,31 +1,32 @@
|
|||
package com.geeksville.mesh.service
|
||||
|
||||
import com.geeksville.mesh.MeshUser
|
||||
import com.geeksville.mesh.NodeInfo
|
||||
import com.geeksville.mesh.Position
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
|
||||
|
||||
class MeshServiceTest {
|
||||
|
||||
val nodeInfo = NodeInfo(4, MeshUser("+one", "User One", "U1"), Position(37.1, 121.1, 35, 10))
|
||||
|
||||
@Test
|
||||
fun givenNodeInfo_whenUpdatingWithNewTime_thenPositionTimeIsUpdated() {
|
||||
|
||||
val newerTime = 20
|
||||
updateNodeInfoTime(nodeInfo, newerTime)
|
||||
Assert.assertEquals(newerTime, nodeInfo.position?.time)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun givenNodeInfo_whenUpdatingWithOldTime_thenPositionTimeIsNotUpdated() {
|
||||
val olderTime = 5
|
||||
val timeBeforeTryingToUpdate = nodeInfo.position?.time
|
||||
updateNodeInfoTime(nodeInfo, olderTime)
|
||||
Assert.assertEquals(timeBeforeTryingToUpdate, nodeInfo.position?.time)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
package com.geeksville.mesh.service
|
||||
|
||||
import com.geeksville.mesh.MeshProtos
|
||||
import com.geeksville.mesh.MeshUser
|
||||
import com.geeksville.mesh.NodeInfo
|
||||
import com.geeksville.mesh.Position
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
|
||||
|
||||
class MeshServiceTest {
|
||||
val model = MeshProtos.HardwareModel.ANDROID_SIM
|
||||
val nodeInfo = NodeInfo(4, MeshUser("+one", "User One", "U1", model), Position(37.1, 121.1, 35, 10))
|
||||
|
||||
@Test
|
||||
fun givenNodeInfo_whenUpdatingWithNewTime_thenPositionTimeIsUpdated() {
|
||||
|
||||
val newerTime = 20
|
||||
updateNodeInfoTime(nodeInfo, newerTime)
|
||||
Assert.assertEquals(newerTime, nodeInfo.position?.time)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun givenNodeInfo_whenUpdatingWithOldTime_thenPositionTimeIsNotUpdated() {
|
||||
val olderTime = 5
|
||||
val timeBeforeTryingToUpdate = nodeInfo.position?.time
|
||||
updateNodeInfoTime(nodeInfo, olderTime)
|
||||
Assert.assertEquals(timeBeforeTryingToUpdate, nodeInfo.position?.time)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue