Fixed
Status Update
Comments
il...@google.com <il...@google.com>
hu...@google.com <hu...@google.com> #2
Hi Ed, Thank you so much for these suggestions. I've been reviewing them and merging them in. Hopefully it should be live. I've included a thank you note too in the article.
ru...@gmail.com <ru...@gmail.com> #3
Great! Thanks a lot, I'll look for the live updates soon!
hu...@google.com <hu...@google.com> #4
Hmm, that's too bad. Agreed, introducing a dependency to the material component doesn't sound a right option. FragmentScenario probably needs an another launch method taking activity's theme and call setTheme before views are instantiated. Let me try building a prototype.
om...@gmail.com <om...@gmail.com> #7
Sorry for interrupt, but I found this bug occur in fragment-testing 1.1.0-alpha09 again.
Here is my small project to reproduce it. (Reproduced in both AS 3.6.1 Canary 1 and AS 3.4.1)
Just run the `androidTest/LoginFragmentInstrumentedTest` as these two images show.
Here is my small project to reproduce it. (Reproduced in both AS 3.6.1 Canary 1 and AS 3.4.1)
Just run the `androidTest/LoginFragmentInstrumentedTest` as these two images show.
il...@google.com <il...@google.com> #8
Re #7 - you have to use one of the overloads to launchFragmentInContainer that take the theme resource ID for it to use a custom theme:
private val loginFragmentScenario = launchFragmentInContainer<LoginFragment>(
themeResId = R.style.Theme_Shrine)
private val loginFragmentScenario = launchFragmentInContainer<LoginFragment>(
themeResId = R.style.Theme_Shrine)
om...@gmail.com <om...@gmail.com> #9
Re #8
Yes, this way will "fix" this issue. But you could find that the "Theme_Shrine" is actually a descendant of "Theme.MaterialComponents.Light.NoActionBar" which is a "Theme.Appcompat.Light".
Therefore, I wonder if the solution you post above is by designed or a bug.
Yes, this way will "fix" this issue. But you could find that the "Theme_Shrine" is actually a descendant of "Theme.MaterialComponents.Light.NoActionBar" which is a "Theme.Appcompat.Light".
Therefore, I wonder if the solution you post above is by designed or a bug.
il...@google.com <il...@google.com> #10
You need to tell FragmentScenario what theme you want if you want something other than the default Theme.WithActionBar, that's correct.
Description
com.google.android.material:material:1.0.0
Using FragmentScenario to launch a Fragment with a MaterialButton, my instrumentation test crashes with:
"IllegalArgumentException: The style on this component requires your app theme to be Theme.AppCompat (or a descendant)."
It appears that the EmptyFragmentActivity in FragmentScenario doesn't inherent a compatible theme with Material. I am currently working around this issue by manually overriding the EmptyFragmentActivity theme with a material one:
<style name="FragmentScenarioEmptyFragmentActivityTheme" parent="@style/Theme.MaterialComponents">
<item name="android:windowIsFloating">false</item>
</style>