Skip to content

Commit

Permalink
Fix AndroidHandlerFunc tests
Browse files Browse the repository at this point in the history
  • Loading branch information
janseeger committed Nov 8, 2023
1 parent 3248770 commit 5166367
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
12 changes: 12 additions & 0 deletions dachlatten-compose/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
plugins {
id("android-library-base")
id("android-library-unit-test")
id("android-library-robolectric-test")
id("android-library-release")
}

dependencies {
implementation(libs.compose.ui)
}

android {
composeOptions {
kotlinCompilerExtensionVersion = libs.versions.compose.compiler.get()
}

buildFeatures {
compose = true
}
}

11 changes: 6 additions & 5 deletions dachlatten-compose/src/test/kotlin/AndroidHandlerFuncTest.kt
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package de.sipgate.dachlatten.compose

import android.content.Context
import org.junit.jupiter.api.Test
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
import org.robolectric.RuntimeEnvironment

@RunWith(RobolectricTestRunner::class)
class AndroidHandlerFuncTest {

private lateinit var context: Context

@Test
fun testAndroidHandlerFuncWillReceiveAContext() {

val context = RuntimeEnvironment.getApplication().applicationContext
val handlerFunc = context.withContext(::someFunctionThatAccessesTheAndroidContext)

handlerFunc.invoke()
Expand Down
3 changes: 2 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ turbine = "1.0.0"
annotation-jvm = "1.7.0"
androidx-lifecycle = "2.6.2"
robolectric = "4.10.3"
compose = "1.5.3"
compose = "1.5.4"
compose-compiler = "1.5.4"

[libraries]
coroutines = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version.ref = "coroutines" }
Expand Down

0 comments on commit 5166367

Please sign in to comment.