architecture-samples icon indicating copy to clipboard operation
architecture-samples copied to clipboard

HiltTestActivity missing setTheme()

Open Sserra90 opened this issue 3 years ago • 1 comments

I was looking at HiltTestActivity comparing to EmptyTestActivity it is missing setTheme() during onCreate() method.

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setTheme(
                intent.getIntExtra(
                        "androidx.fragment.app.testing.FragmentScenario.EmptyFragmentActivity.THEME_EXTRAS_BUNDLE_KEY",
                        R.style.FragmentScenarioEmptyFragmentActivityTheme
                )
        )
    }

This ignores the theme passed to launchFragmentInHiltContainer method

Sserra90 avatar Apr 07 '22 10:04 Sserra90

I second this. Without it, my test fails with You need to use a Theme.AppCompat theme (or descendant) with this activity. Thanks for the hint @Sserra90

Syn-McJ avatar Jul 01 '22 13:07 Syn-McJ