Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.mitteloupe.whoami.launcher

import androidx.activity.ComponentActivity
import androidx.activity.compose.LocalActivity
import androidx.appcompat.app.AppCompatActivity
import com.mitteloupe.whoami.di.testAppDependenciesEntryPoint
import com.mitteloupe.whoami.test.launcher.AppLauncher
Expand All @@ -10,13 +8,12 @@ import com.mitteloupe.whoami.test.test.TypedAndroidComposeTestRule
import com.mitteloupe.whoami.ui.main.AppNavHost
import com.mitteloupe.whoami.ui.theme.WhoAmITheme

fun <ACTIVITY : ComponentActivity> fromScreen(
fun <ACTIVITY : AppCompatActivity> fromScreen(
composeContentTestRule: TypedAndroidComposeTestRule<ACTIVITY>,
startDestination: Any
) = AppLauncher {
fromComposable(composeContentTestRule) {
fromComposable(composeContentTestRule) { activity ->
WhoAmITheme {
val activity = LocalActivity.current as AppCompatActivity
with(testAppDependenciesEntryPoint(activity).appNavHostDependencies) {
AppNavHost(
supportFragmentManager = activity.supportFragmentManager,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@ import kotlinx.coroutines.runBlocking

fun <ACTIVITY : ComponentActivity> fromComposable(
composeContentTestRule: TypedAndroidComposeTestRule<ACTIVITY>,
composable: @Composable () -> Unit
composable: @Composable (ACTIVITY) -> Unit
) = AppLauncher {
val activity = composeContentTestRule.activity
val root = activity.findViewById<ViewGroup>(android.R.id.content)
if (root != null) {
activity.findViewById<ViewGroup>(android.R.id.content)?.let { root ->
runBlocking(Dispatchers.Main) {
root.removeAllViews()
}
}
composeContentTestRule.setContent(composable)
composeContentTestRule.setContent { composable(activity) }
}