nowinandroid icon indicating copy to clipboard operation
nowinandroid copied to clipboard

[Bug]: Splash screen shows when running composable tests

Open paetztm opened this issue 10 months ago • 11 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Is there a StackOverflow question about this issue?

  • [X] I have searched StackOverflow

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

  • [X] I agree to follow this project's Code of Conduct

paetztm avatar Apr 24 '24 02:04 paetztm

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.

paetztm avatar Apr 24 '24 03:04 paetztm

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

Vishwajith-Shettigar avatar Aug 15 '24 07:08 Vishwajith-Shettigar

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

anhtuannd avatar Aug 15 '24 13:08 anhtuannd

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

Okay, thanks @anhtuannd.

Vishwajith-Shettigar avatar Aug 15 '24 13:08 Vishwajith-Shettigar

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.

Vishwajith-Shettigar avatar Aug 16 '24 04:08 Vishwajith-Shettigar

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.

SimonMarquis avatar Aug 16 '24 06:08 SimonMarquis

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

Jaehwa-Noh avatar Aug 16 '24 06:08 Jaehwa-Noh

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

Vishwajith-Shettigar avatar Aug 16 '24 07:08 Vishwajith-Shettigar

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 avatar Aug 16 '24 07:08 Vishwajith-Shettigar

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?

Vishwajith-Shettigar avatar Aug 18 '24 04:08 Vishwajith-Shettigar

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

Jaehwa-Noh avatar Aug 18 '24 07:08 Jaehwa-Noh