I have a problem. I want to write a test for code that relies on execution of the PopupWindow.OnDismissListener.onDismiss() method. However, it never seems to be called. Am I doing something wrong?
Sample code:
View content = new View(Robolectric.application);
PopupWindow popup = new PopupWindow(content, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
popup.setOnDismissListener(new PopupWindow.OnDismissListener() {
@Override
public void onDismiss() {
Assert.fail();
}
});
View anchor = new View(Robolectric.application);
popup.showAsDropDown(anchor);
popup.dismiss();
The above test never fails! I have tried adding a small sleep after, in case there were some timing issues. I have looked at the generated code for the PopupWindow.class, but couldn't find anything there either.
Thanks!