Skip to content

Instantly share code, notes, and snippets.

@TechIsFun
Created January 26, 2016 14:38
Show Gist options
  • Save TechIsFun/e64619408a88ea745e23 to your computer and use it in GitHub Desktop.
Save TechIsFun/e64619408a88ea745e23 to your computer and use it in GitHub Desktop.
@Test
public void testOnClickMapButton() throws Exception {
Context spyContext = spy(RuntimenEnvironment.application);
mActivity.onClickOnMapButton(spyContext);
verify(spyContext).startActivity(argThat(googleMapsIntentMatcher()));
}
private static Matcher<Intent> googleMapsIntentMatcher() {
return new ArgumentMatcher<Intent>() {
@Override
public boolean matches(Object argument) {
if (argument instanceof Intent) {
Intent intent = (Intent) argument;
return "com.google.android.apps.maps".equals(intent.getPackage());
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment