I have a settingsActivity in which I used sharedPreference to set some simple options for my application. I have an editTextPreference and a listPreference. I want to test that when I select an option in my listPreference or when I enter some text in my editTextPreference the sharedPreference get set correctly. The problem I have is that I can click on my listPreference and a pop-up with my 5 options show up. But I cannot figure out a way to select one of the option. I tried this:
onView(withText(R.string.list_color_selection_title)).perform(click());
onView(withText("Yellow")).inRoot(isPlatformPopup()).perform(click());
SharedPreferences defaultSharedPreferences PreferenceManager.getDefaultSharedPreferences(mContext);
String defaultEmailValue = defaultSharedPreferences.getString("list_color", "null");
assertEquals("Yellow",defaultEmailValue);
This doesn't work. I have find people doing this kind of thing:
onView(ViewMatchers.withContentDescription("SOMEDESCRIPTION"))
.inRoot(RootMatchers.isPlatformPopup())
.perform(ViewActions.click());
It doesn't work either. I don't know how to find the contentDescription of my options. If I use the text "Yellow" it doesn't work.
Thank you for your help!
Aucun commentaire:
Enregistrer un commentaire