Skip to content

Instantly share code, notes, and snippets.

@DevPicon
Created November 15, 2015 06:27
Show Gist options
  • Save DevPicon/ec811ff19708a512c600 to your computer and use it in GitHub Desktop.
Save DevPicon/ec811ff19708a512c600 to your computer and use it in GitHub Desktop.
Un ejemplo de cómo testear un item del menu
@Test
public void testActionButtonSettings() {
// Con esta función abrimos el popup menu
openActionBarOverflowOrOptionsMenu(InstrumentationRegistry.getTargetContext());
// Buscamos el elemento que contenga la cadena que buscamos,
// verificamos el tipo de componente raíz y pulsamos
onData(
hasToString(is(
activityTestRule.getActivity().getString(R.string.action_settings)
)))
.inRoot(isPlatformPopup()).perform(click());
onData(hasToString(is(
activityTestRule.getActivity().getString(R.string.pref_locationDialogTitle)
))).perform(click());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment