From 9a6c78fcd14d71ef9af1d53176abd19b5d2ab2ef Mon Sep 17 00:00:00 2001
From: Phil Oliver <3497406+poliver@users.noreply.github.com>
Date: Tue, 7 Oct 2025 12:23:41 -0400
Subject: [PATCH] Move tests to appropriate modules (#3377)
---
.../mesh/ExampleInstrumentedTest.kt | 39 -------------------
core/model/build.gradle.kts | 2 +
.../org/meshtastic/core/model}/ChannelTest.kt | 5 +--
.../core/model/util}/ChannelSetTest.kt | 20 ++--------
.../core}/model/DeviceVersionTest.kt | 3 +-
.../meshtastic/core/model}/NodeInfoTest.kt | 6 +--
.../meshtastic/core/model}/PositionTest.kt | 3 +-
7 files changed, 12 insertions(+), 66 deletions(-)
delete mode 100644 app/src/androidTest/java/com/geeksville/mesh/ExampleInstrumentedTest.kt
rename {app/src/androidTest/java/com/geeksville/mesh => core/model/src/androidTest/kotlin/org/meshtastic/core/model}/ChannelTest.kt (94%)
rename {app/src/androidTest/java/com/geeksville/mesh => core/model/src/androidTest/kotlin/org/meshtastic/core/model/util}/ChannelSetTest.kt (83%)
rename {app/src/test/java/com/geeksville/mesh => core/model/src/test/kotlin/org/meshtastic/core}/model/DeviceVersionTest.kt (93%)
rename {app/src/test/java/com/geeksville/mesh => core/model/src/test/kotlin/org/meshtastic/core/model}/NodeInfoTest.kt (94%)
rename {app/src/test/java/com/geeksville/mesh => core/model/src/test/kotlin/org/meshtastic/core/model}/PositionTest.kt (94%)
diff --git a/app/src/androidTest/java/com/geeksville/mesh/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/geeksville/mesh/ExampleInstrumentedTest.kt
deleted file mode 100644
index 558ffc6e2..000000000
--- a/app/src/androidTest/java/com/geeksville/mesh/ExampleInstrumentedTest.kt
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (c) 2025 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
- * 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 .
- */
-
-package com.geeksville.mesh
-
-import androidx.test.ext.junit.runners.AndroidJUnit4
-import androidx.test.platform.app.InstrumentationRegistry
-import org.junit.Assert.assertEquals
-import org.junit.Test
-import org.junit.runner.RunWith
-
-/**
- * Instrumented test, which will execute on an Android device.
- *
- * See [testing documentation](http://d.android.com/tools/testing).
- */
-@RunWith(AndroidJUnit4::class)
-class ExampleInstrumentedTest {
- @Test
- fun useAppContext() {
- // Context of the app under test.
- val appContext = InstrumentationRegistry.getInstrumentation().targetContext
- assertEquals("com.geeksville.mesh", appContext.packageName)
- }
-}
diff --git a/core/model/build.gradle.kts b/core/model/build.gradle.kts
index 9a28ce209..3495b3158 100644
--- a/core/model/build.gradle.kts
+++ b/core/model/build.gradle.kts
@@ -38,4 +38,6 @@ dependencies {
implementation(libs.timber)
implementation(libs.zxing.android.embedded) { isTransitive = false }
implementation(libs.zxing.core)
+
+ testImplementation(libs.androidx.core.ktx)
}
diff --git a/app/src/androidTest/java/com/geeksville/mesh/ChannelTest.kt b/core/model/src/androidTest/kotlin/org/meshtastic/core/model/ChannelTest.kt
similarity index 94%
rename from app/src/androidTest/java/com/geeksville/mesh/ChannelTest.kt
rename to core/model/src/androidTest/kotlin/org/meshtastic/core/model/ChannelTest.kt
index 120e7d9d3..0e86c8576 100644
--- a/app/src/androidTest/java/com/geeksville/mesh/ChannelTest.kt
+++ b/core/model/src/androidTest/kotlin/org/meshtastic/core/model/ChannelTest.kt
@@ -15,14 +15,13 @@
* along with this program. If not, see .
*/
-package com.geeksville.mesh
+package org.meshtastic.core.model
import androidx.test.ext.junit.runners.AndroidJUnit4
+import com.geeksville.mesh.channelSet
import org.junit.Assert
import org.junit.Test
import org.junit.runner.RunWith
-import org.meshtastic.core.model.Channel
-import org.meshtastic.core.model.numChannels
import org.meshtastic.core.model.util.URL_PREFIX
import org.meshtastic.core.model.util.getChannelUrl
import org.meshtastic.core.model.util.toChannelSet
diff --git a/app/src/androidTest/java/com/geeksville/mesh/ChannelSetTest.kt b/core/model/src/androidTest/kotlin/org/meshtastic/core/model/util/ChannelSetTest.kt
similarity index 83%
rename from app/src/androidTest/java/com/geeksville/mesh/ChannelSetTest.kt
rename to core/model/src/androidTest/kotlin/org/meshtastic/core/model/util/ChannelSetTest.kt
index 11b60950b..869705108 100644
--- a/app/src/androidTest/java/com/geeksville/mesh/ChannelSetTest.kt
+++ b/core/model/src/androidTest/kotlin/org/meshtastic/core/model/util/ChannelSetTest.kt
@@ -15,29 +15,17 @@
* along with this program. If not, see .
*/
-package com.geeksville.mesh
+package org.meshtastic.core.model.util
import android.net.Uri
-import dagger.hilt.android.testing.HiltAndroidRule
-import dagger.hilt.android.testing.HiltAndroidTest
+import androidx.test.ext.junit.runners.AndroidJUnit4
import org.junit.Assert
-import org.junit.Before
-import org.junit.Rule
import org.junit.Test
-import org.meshtastic.core.model.util.getChannelUrl
-import org.meshtastic.core.model.util.primaryChannel
-import org.meshtastic.core.model.util.toChannelSet
+import org.junit.runner.RunWith
-@HiltAndroidTest
+@RunWith(AndroidJUnit4::class)
class ChannelSetTest {
- @get:Rule var hiltRule = HiltAndroidRule(this)
-
- @Before
- fun init() {
- hiltRule.inject()
- }
-
/** make sure we match the python and device code behavior */
@Test
fun matchPython() {
diff --git a/app/src/test/java/com/geeksville/mesh/model/DeviceVersionTest.kt b/core/model/src/test/kotlin/org/meshtastic/core/model/DeviceVersionTest.kt
similarity index 93%
rename from app/src/test/java/com/geeksville/mesh/model/DeviceVersionTest.kt
rename to core/model/src/test/kotlin/org/meshtastic/core/model/DeviceVersionTest.kt
index 91d645aac..a353230a6 100644
--- a/app/src/test/java/com/geeksville/mesh/model/DeviceVersionTest.kt
+++ b/core/model/src/test/kotlin/org/meshtastic/core/model/DeviceVersionTest.kt
@@ -15,11 +15,10 @@
* along with this program. If not, see .
*/
-package com.geeksville.mesh.model
+package org.meshtastic.core.model
import org.junit.Assert.assertEquals
import org.junit.Test
-import org.meshtastic.core.model.DeviceVersion
class DeviceVersionTest {
/** make sure we match the python and device code behavior */
diff --git a/app/src/test/java/com/geeksville/mesh/NodeInfoTest.kt b/core/model/src/test/kotlin/org/meshtastic/core/model/NodeInfoTest.kt
similarity index 94%
rename from app/src/test/java/com/geeksville/mesh/NodeInfoTest.kt
rename to core/model/src/test/kotlin/org/meshtastic/core/model/NodeInfoTest.kt
index 80bddce51..593d66e65 100644
--- a/app/src/test/java/com/geeksville/mesh/NodeInfoTest.kt
+++ b/core/model/src/test/kotlin/org/meshtastic/core/model/NodeInfoTest.kt
@@ -15,17 +15,15 @@
* along with this program. If not, see .
*/
-package com.geeksville.mesh
+package org.meshtastic.core.model
import androidx.core.os.LocaleListCompat
import com.geeksville.mesh.ConfigProtos.Config.DisplayConfig.DisplayUnits
+import com.geeksville.mesh.MeshProtos
import org.junit.After
import org.junit.Assert
import org.junit.Before
import org.junit.Test
-import org.meshtastic.core.model.MeshUser
-import org.meshtastic.core.model.NodeInfo
-import org.meshtastic.core.model.Position
import java.util.Locale
class NodeInfoTest {
diff --git a/app/src/test/java/com/geeksville/mesh/PositionTest.kt b/core/model/src/test/kotlin/org/meshtastic/core/model/PositionTest.kt
similarity index 94%
rename from app/src/test/java/com/geeksville/mesh/PositionTest.kt
rename to core/model/src/test/kotlin/org/meshtastic/core/model/PositionTest.kt
index a217f7627..c120e7753 100644
--- a/app/src/test/java/com/geeksville/mesh/PositionTest.kt
+++ b/core/model/src/test/kotlin/org/meshtastic/core/model/PositionTest.kt
@@ -15,11 +15,10 @@
* along with this program. If not, see .
*/
-package com.geeksville.mesh
+package org.meshtastic.core.model
import org.junit.Assert
import org.junit.Test
-import org.meshtastic.core.model.Position
class PositionTest {
@Test