-
Notifications
You must be signed in to change notification settings - Fork 1.4k
TextViews on Robolectric always have width and height 0 #4153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The same problem. |
Me too. |
I was having the same problem as well, but now issue fixed when used 4.2.1 and setting the width and hight manually in the xml. If they are set to wrap content it doesn't work. I was able to get it to work by setting minHeight for the TextViews (this should mitigate the issue until we get a fix). |
Fixes #4236, #4153 This change makes UI layout and text measurement in Robolectric more realistic, by shadowing additional native text measurement calls and setting a valid, non-zero window frame size during UI layout. Some tests may need adjustment after this change in the following ways: - switched to paused looper when doing layouts, especially when RecyclerView is used. See #3369. Its recommended to use the upcoming @LooperMode(PAUSED) - adjust screen size or other dimensions of tests to account for the fact that TextViews are no longer always 0-sized Because of this potential effect on tests, the new layout logic is turned off by default for now, but can be enabled via the @LayoutMode(REALISTIC) annotation. PiperOrigin-RevId: 241141684
…tric Fixes #4236, #4153 This change makes UI layout and text measurement in Robolectric more realistic, by shadowing additional native text measurement calls and setting a valid, non-zero window frame size during UI layout. Some tests may need adjustment after this change in the following ways: - switched to paused looper when doing layouts, especially when RecyclerView is used. See https://github.com/robolectric/robolectric/... PiperOrigin-RevId: 241153371
Fixed if you use @TextLayoutMode(REALISTIC) I'll track switching TextLayoutMode to default to REALISTIC in a separate issue |
Description
TextViews on Robolectric always seem to have a width and height of 0. This makes Espresso think they are always not displayed
Steps to Reproduce
TextView textView = ....
assertThat(textView.getGlobalVisibleRectangle(new Rect())).isTrue(); // Fails
Robolectric & Android Version
Robolectric 4.0.2, Android 28
Link to a public git repo demonstrating the problem:
https://github.com/googlesamples/android-testing CustomMatcherSample
The text was updated successfully, but these errors were encountered: