mirror of
https://github.com/aljazceru/Android-nRF-Toolbox.git
synced 2025-12-20 16:04:22 +01:00
Modernization of modular approach
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
package no.nordicsemi.android.utils
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
import org.junit.Assert.*
|
||||
|
||||
/**
|
||||
* 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("no.nordicsemi.android.utils.test", appContext.packageName)
|
||||
}
|
||||
}
|
||||
5
lib_utils/src/main/AndroidManifest.xml
Normal file
5
lib_utils/src/main/AndroidManifest.xml
Normal file
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="no.nordicsemi.android.utils">
|
||||
|
||||
</manifest>
|
||||
16
lib_utils/src/main/java/no/nordicsemi/android/utils/Ext.kt
Normal file
16
lib_utils/src/main/java/no/nordicsemi/android/utils/Ext.kt
Normal file
@@ -0,0 +1,16 @@
|
||||
package no.nordicsemi.android.utils
|
||||
|
||||
import android.app.ActivityManager
|
||||
import android.content.Context
|
||||
|
||||
val <T> T.exhaustive
|
||||
get() = this
|
||||
|
||||
val String.Companion.EMPTY
|
||||
get() = ""
|
||||
|
||||
fun Context.isServiceRunning(serviceClassName: String): Boolean {
|
||||
val activityManager = getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
|
||||
val services = activityManager.getRunningServices(Integer.MAX_VALUE)
|
||||
return services.find { it.service.className == serviceClassName } != null
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package no.nordicsemi.android.utils
|
||||
|
||||
import org.junit.Test
|
||||
|
||||
import org.junit.Assert.*
|
||||
|
||||
/**
|
||||
* Example local unit test, which will execute on the development machine (host).
|
||||
*
|
||||
* See [testing documentation](http://d.android.com/tools/testing).
|
||||
*/
|
||||
class ExampleUnitTest {
|
||||
@Test
|
||||
fun addition_isCorrect() {
|
||||
assertEquals(4, 2 + 2)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user