Pretty common scenario: an Android application has settings activity and selecting an option from the ListPreference trigger code to modify this ListPreference summary text. i.e.: Green from the color of the ListPreference would change the summary text of the ListPreference to Green by using the onPreferenceChange .
I would like to use Android JUnit testing to confirm that these resulting changes are being performed correctly. However, there seems to be very little information on how to do this.
I tried the options for using setValue() in ListPreference, both in the test thread and through runOnUiThread() , without success - this does not cause the onPreferenceChange() call. I also tried getInstrumentation().waitForIdleSync() after calling setValue() , but also without success.
So my question is: how is this done?
Thank!
android unit-testing junit android-preferences
Chris Aug 03 2018-11-11T00: 00Z
source share