File tree Expand file tree Collapse file tree
app/src/androidTest/java/com/mitteloupe/whoami/launcher
architecture/instrumentation-test/src/main/java/com/mitteloupe/whoami/test/launcher Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11package com.mitteloupe.whoami.launcher
22
3- import androidx.activity.ComponentActivity
4- import androidx.activity.compose.LocalActivity
53import androidx.appcompat.app.AppCompatActivity
64import com.mitteloupe.whoami.di.testAppDependenciesEntryPoint
75import com.mitteloupe.whoami.test.launcher.AppLauncher
@@ -10,13 +8,12 @@ import com.mitteloupe.whoami.test.test.TypedAndroidComposeTestRule
108import com.mitteloupe.whoami.ui.main.AppNavHost
119import com.mitteloupe.whoami.ui.theme.WhoAmITheme
1210
13- fun <ACTIVITY : ComponentActivity > fromScreen (
11+ fun <ACTIVITY : AppCompatActivity > fromScreen (
1412 composeContentTestRule : TypedAndroidComposeTestRule <ACTIVITY >,
1513 startDestination : Any
1614) = AppLauncher {
17- fromComposable(composeContentTestRule) {
15+ fromComposable(composeContentTestRule) { activity ->
1816 WhoAmITheme {
19- val activity = LocalActivity .current as AppCompatActivity
2017 with (testAppDependenciesEntryPoint(activity).appNavHostDependencies) {
2118 AppNavHost (
2219 supportFragmentManager = activity.supportFragmentManager,
Original file line number Diff line number Diff line change @@ -9,14 +9,13 @@ import kotlinx.coroutines.runBlocking
99
1010fun <ACTIVITY : ComponentActivity > fromComposable (
1111 composeContentTestRule : TypedAndroidComposeTestRule <ACTIVITY >,
12- composable : @Composable () -> Unit
12+ composable : @Composable (ACTIVITY ) -> Unit
1313) = AppLauncher {
1414 val activity = composeContentTestRule.activity
15- val root = activity.findViewById<ViewGroup >(android.R .id.content)
16- if (root != null ) {
15+ activity.findViewById<ViewGroup >(android.R .id.content)?.let { root ->
1716 runBlocking(Dispatchers .Main ) {
1817 root.removeAllViews()
1918 }
2019 }
21- composeContentTestRule.setContent( composable)
20+ composeContentTestRule.setContent { composable(activity) }
2221}
You can’t perform that action at this time.
0 commit comments