2024-11-26 08:38:12 -03:00
|
|
|
/*
|
2025-01-02 06:50:26 -03:00
|
|
|
* Copyright (c) 2025 Meshtastic LLC
|
2024-11-26 08:38:12 -03:00
|
|
|
*
|
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
2020-03-17 14:56:06 -07:00
|
|
|
package com.geeksville.mesh
|
|
|
|
|
|
|
|
|
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
2023-07-18 22:28:16 -03:00
|
|
|
import com.geeksville.mesh.model.Channel
|
2023-10-07 08:22:12 -03:00
|
|
|
import com.geeksville.mesh.model.URL_PREFIX
|
|
|
|
|
import com.geeksville.mesh.model.getChannelUrl
|
2024-01-10 05:33:19 -03:00
|
|
|
import com.geeksville.mesh.model.numChannels
|
2023-10-07 08:22:12 -03:00
|
|
|
import com.geeksville.mesh.model.toChannelSet
|
2020-03-17 14:56:06 -07:00
|
|
|
import org.junit.Assert
|
|
|
|
|
import org.junit.Test
|
|
|
|
|
import org.junit.runner.RunWith
|
|
|
|
|
|
|
|
|
|
@RunWith(AndroidJUnit4::class)
|
|
|
|
|
class ChannelTest {
|
|
|
|
|
@Test
|
|
|
|
|
fun channelUrlGood() {
|
2023-10-07 08:22:12 -03:00
|
|
|
val ch = channelSet {
|
|
|
|
|
settings.add(Channel.default.settings)
|
|
|
|
|
loraConfig = Channel.default.loraConfig
|
|
|
|
|
}
|
|
|
|
|
val channelUrl = ch.getChannelUrl()
|
2020-03-17 14:56:06 -07:00
|
|
|
|
2023-10-07 08:22:12 -03:00
|
|
|
Assert.assertTrue(channelUrl.toString().startsWith(URL_PREFIX))
|
|
|
|
|
Assert.assertEquals(channelUrl.toChannelSet(), ch)
|
2020-03-17 14:56:06 -07:00
|
|
|
}
|
2023-07-18 22:28:16 -03:00
|
|
|
|
2024-01-10 05:33:19 -03:00
|
|
|
@Test
|
|
|
|
|
fun channelHashGood() {
|
|
|
|
|
val ch = Channel.default
|
|
|
|
|
|
|
|
|
|
Assert.assertEquals(8, ch.hash)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
fun numChannelsGood() {
|
|
|
|
|
val ch = Channel.default
|
|
|
|
|
|
|
|
|
|
Assert.assertEquals(104, ch.loraConfig.numChannels)
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-18 22:28:16 -03:00
|
|
|
@Test
|
|
|
|
|
fun channelNumGood() {
|
|
|
|
|
val ch = Channel.default
|
|
|
|
|
|
|
|
|
|
Assert.assertEquals(20, ch.channelNum)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
fun radioFreqGood() {
|
|
|
|
|
val ch = Channel.default
|
|
|
|
|
|
|
|
|
|
Assert.assertEquals(906.875f, ch.radioFreq)
|
|
|
|
|
}
|
|
|
|
|
}
|