fix(4269): Add LongTurbo preset name and tests (#4273)

Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit is contained in:
James Rich
2026-01-20 21:36:31 -06:00
committed by GitHub
parent b73a304452
commit 7173a2da99
2 changed files with 24 additions and 4 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2025 Meshtastic LLC
* Copyright (c) 2025-2026 Meshtastic LLC
*
* 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
@@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.meshtastic.core.model
import androidx.test.ext.junit.runners.AndroidJUnit4
@@ -24,7 +23,9 @@ import org.junit.runner.RunWith
import org.meshtastic.core.model.util.URL_PREFIX
import org.meshtastic.core.model.util.getChannelUrl
import org.meshtastic.core.model.util.toChannelSet
import org.meshtastic.proto.ConfigProtos
import org.meshtastic.proto.channelSet
import org.meshtastic.proto.copy
@RunWith(AndroidJUnit4::class)
class ChannelTest {
@@ -67,4 +68,23 @@ class ChannelTest {
Assert.assertEquals(906.875f, ch.radioFreq)
}
@Test
fun allModemPresetsHaveValidNames() {
ConfigProtos.Config.LoRaConfig.ModemPreset.values().forEach { preset ->
// Skip UNRECOGNIZED if it exists (Wire generates it sometimes) or generic UNSET values if applicable
// In this specific enum, assuming all valid defined presets should map.
if (preset.name == "UNSET" || preset.name == "UNRECOGNIZED") return@forEach
val loraConfig =
Channel.default.loraConfig.copy {
usePreset = true
modemPreset = preset
}
val channel = Channel(loraConfig = loraConfig)
// We want to ensure it is NOT "Invalid"
Assert.assertNotEquals("Preset ${preset.name} should typically have a valid name", "Invalid", channel.name)
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2025 Meshtastic LLC
* Copyright (c) 2025-2026 Meshtastic LLC
*
* 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
@@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.meshtastic.core.model
import com.google.protobuf.ByteString
@@ -94,6 +93,7 @@ data class Channel(
ModemPreset.LONG_SLOW -> "LongSlow"
ModemPreset.LONG_MODERATE -> "LongMod"
ModemPreset.VERY_LONG_SLOW -> "VLongSlow"
ModemPreset.LONG_TURBO -> "LongTurbo"
else -> "Invalid"
}
} else {