mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
Fix last time issue with nodes
This commit is contained in:
parent
e6e80dec5f
commit
c56f14a259
3 changed files with 51 additions and 9 deletions
|
|
@ -14,5 +14,10 @@ class PositionTest {
|
|||
Assert.assertEquals(Position.degD(Position.degI(-89.0)), -89.0, 0.01)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun givenPositionCreatedWithoutTime_thenTimeIsSet() {
|
||||
val position = Position(37.1, 121.1, 35)
|
||||
Assert.assertTrue(position.time != 0)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,31 @@
|
|||
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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue