android / nowinandroid

A fully functional Android app built entirely with Kotlin and Jetpack Compose
Apache License 2.0
16.47k stars 2.96k forks source link

[Bug]: Splash screen shows when running composable tests #1396

Open paetztm opened 4 months ago

paetztm commented 4 months ago

Is there an existing issue for this?

Is there a StackOverflow question about this issue?

What happened?

A bug happened!

When running UI Composable tests, the Splash Screen is displayed. To see this happen, run any test in NavigationUiTest.kt.

Screen shot for when running NavigationUiTest.compactWidth_compactHeight_showsNavigationBar() test: image

Expected results: Splash screen theme should not be shown when running compose UI tests. Instead, only the composable within composeTestRule.setContent should be displayed.

Relevant logcat output

No response

Code of Conduct

paetztm commented 4 months ago

Looks like a solution/work around is to set the splash theme at the activity level instead of the application level in AndroidManifest.xml.

Application theme changed from: android:theme="@style/Theme.Nia.Splash" to: android:theme="@style/Theme.Nia"

And adding: android:theme="@style/Theme.Nia.Splash" to .MainActivity

Seems to fix the issue.

Vishwajith-Shettigar commented 1 month ago

I would like to work on this, please feel free to assign me.

anhtuannd commented 4 weeks ago

@Vishwajith-Shettigar You can start working on this and open PR without any assignment.

Vishwajith-Shettigar commented 4 weeks ago

@Vishwajith-Shettigar You can start working on this and open PR without any assignment.

Okay, thanks @anhtuannd.

Vishwajith-Shettigar commented 4 weeks ago

There isn't any test suite named NavigationUiTest.kt. I ran tests in NavigationTest.kt; the splash screen was displayed (as it should be normally) but not like it is in the screenshot in the issue description. Any thoughts?

Edit: Realised this is screenshot testing not an espresso test and NavigationUiTest was renamed to NiaAppScreenSizesScreenshotTests.kt.

SimonMarquis commented 4 weeks ago

The worst thing in this screenshot is not the window background leaking in the screenshot, but the bottom bar that is not at the "bottom" of the screen, next to the navigation bar. This is probably the root cause. There might be something off in this screenshot.

Jaehwa-Noh commented 4 weeks ago

I think the bottom navigation bar location is normal, because that DeviceConfiguration had been overridden as height 400dp.

Vishwajith-Shettigar commented 4 weeks ago

It seems like the test suite has been renamed to NiaAppScreenSizesScreenshotTests.kt.

Vishwajith-Shettigar commented 4 weeks ago

I think the bottom navigation bar location is normal, because that DeviceConfiguration had been overridden as height 400dp.

I'm assuming that the device configuration affects only NiaTheme and, ultimately, the NiaApp, not the whole application. Since we applied the theme Theme.Nia.Splash to NiaApplication, it shows the splash screen. Therefore, this solution would resolve this issue.

Vishwajith-Shettigar commented 3 weeks ago

Hi, I'm unable to reproduce this issue; I don't see any splash screen in the screenshots as shown in the description above. @SimonMarquis, @Jaehwa-Noh, are you able to?

Jaehwa-Noh commented 3 weeks ago

That test had been removed at #1373. If no problems found in any other tests, this issue could be closed.