Skip to content

Instantly share code, notes, and snippets.

@Lukmannudin
Created January 28, 2020 06:37
Show Gist options
  • Select an option

  • Save Lukmannudin/36ded6ce67c7137723449d10595a1c72 to your computer and use it in GitHub Desktop.

Select an option

Save Lukmannudin/36ded6ce67c7137723449d10595a1c72 to your computer and use it in GitHub Desktop.
public class ToastMatcher extends TypeSafeMatcher<Root> {
@Override
public void describeTo(Description description) {
description.appendText("is toast");
}
@Override
public boolean matchesSafely(Root root) {
int type = root.getWindowLayoutParams().get().type;
if ((type == WindowManager.LayoutParams.TYPE_TOAST)) {
IBinder windowToken = root.getDecorView().getWindowToken();
IBinder appToken = root.getDecorView().getApplicationWindowToken();
return windowToken == appToken;
}
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment