File tree Expand file tree Collapse file tree 2 files changed +5
-9
lines changed
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 2 files changed +5
-9
lines changed Original file line number Diff line number Diff line change 1
1
package com.mitteloupe.whoami.launcher
2
2
3
- import androidx.activity.ComponentActivity
4
- import androidx.activity.compose.LocalActivity
5
3
import androidx.appcompat.app.AppCompatActivity
6
4
import com.mitteloupe.whoami.di.testAppDependenciesEntryPoint
7
5
import com.mitteloupe.whoami.test.launcher.AppLauncher
@@ -10,13 +8,12 @@ import com.mitteloupe.whoami.test.test.TypedAndroidComposeTestRule
10
8
import com.mitteloupe.whoami.ui.main.AppNavHost
11
9
import com.mitteloupe.whoami.ui.theme.WhoAmITheme
12
10
13
- fun <ACTIVITY : ComponentActivity > fromScreen (
11
+ fun <ACTIVITY : AppCompatActivity > fromScreen (
14
12
composeContentTestRule : TypedAndroidComposeTestRule <ACTIVITY >,
15
13
startDestination : Any
16
14
) = AppLauncher {
17
- fromComposable(composeContentTestRule) {
15
+ fromComposable(composeContentTestRule) { activity ->
18
16
WhoAmITheme {
19
- val activity = LocalActivity .current as AppCompatActivity
20
17
with (testAppDependenciesEntryPoint(activity).appNavHostDependencies) {
21
18
AppNavHost (
22
19
supportFragmentManager = activity.supportFragmentManager,
Original file line number Diff line number Diff line change @@ -9,14 +9,13 @@ import kotlinx.coroutines.runBlocking
9
9
10
10
fun <ACTIVITY : ComponentActivity > fromComposable (
11
11
composeContentTestRule : TypedAndroidComposeTestRule <ACTIVITY >,
12
- composable : @Composable () -> Unit
12
+ composable : @Composable (ACTIVITY ) -> Unit
13
13
) = AppLauncher {
14
14
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 ->
17
16
runBlocking(Dispatchers .Main ) {
18
17
root.removeAllViews()
19
18
}
20
19
}
21
- composeContentTestRule.setContent( composable)
20
+ composeContentTestRule.setContent { composable(activity) }
22
21
}
You can’t perform that action at this time.
0 commit comments