robolectric / robolectric

Android Unit Testing Framework
http://robolectric.org
Other
5.91k stars 1.37k forks source link

AutoCompleteTextView and Robolectric Limitations #6912

Open joshallenit opened 2 years ago

joshallenit commented 2 years ago

Description

Hi, this is more of a question as to what the systemic limitations of Robolectric are, rather than asking for a fix.

I am trying to test clicking on a drop down selection of an AutoCompleteTextView. I created a test in /androidTest and a near identical test under /test. FragmentScenario + Espresso is used to do the actual testing.

I notice that the existing test for AutoCompleteTextView in the Roblectric repository only tests the count of the adapter, not whether the drop-down is in view hierarchy.

Is Robolectric intended to work in this case? I would like to know if the "write-once, run-anywhere" idea is ever going to be viable.

Thanks!

Steps to Reproduce

Example code

  1. Type into an AutoCompleteTextView such that a popup should be displayed
  2. Try to click on the text view

Expected result

Actual result

Robolectric & Android Version

Robolectric 4.7.3, Android SDK 31

Link to a public git repo demonstrating the problem:

https://github.com/joshallenit/issue-robolectric-autocompletetextview

maanuanubhav999 commented 2 years ago

Thanks for raising this, I am also having a hard time testing it. Is there any other known methods by which we could click on the drop down selection ( with extra implementation)

joshallenit commented 2 years ago

... Is there any other known methods by which we could click on the drop down selection ( with extra implementation)

@maanuanubhav999 Nope, because the dropdown item is never inflated and so does not exist to click on.

utzcoz commented 1 year ago

@joshallenit What about trying native graphics mode with latest Robolectric?