/** * Test to ensure we don't start an infinite loop when the PlaceManager closes the activity. * See also the complementary case, {@link #shouldNotCallHideOnViewWhenCloseOperationTriggeredByView()}. */ @SuppressWarnings("unchecked") @Test public void shouldNotCallCloseOnPlaceManagerWhenCloseOperationTriggeredByPlaceManager() throws Exception { doAnswer(new Answer<Void>() { @Override public Void answer(InvocationOnMock invocation) throws Throwable { // simulate is what PopupView will do in response to hide() registeredCloseHandler.onClose(mock(CloseEvent.class)); return null; } }).when(popupView).hide(); popupActivity.onStartup(popupPlace); popupActivity.onOpen(); popupActivity.onClose(); verify(popupView).hide(); // PlaceManager initiated this operation, so we mustn't call back into it verify(placeManager, never()).closePlace(popupPlace); }
/** * Test to ensure we don't start an infinite loop when the PlaceManager closes the activity. * See also the complementary case, {@link #shouldNotCallHideOnViewWhenCloseOperationTriggeredByView()}. */ @SuppressWarnings("unchecked") @Test public void shouldNotCallCloseOnPlaceManagerWhenCloseOperationTriggeredByPlaceManager() throws Exception { doAnswer(new Answer<Void>() { @Override public Void answer(InvocationOnMock invocation) throws Throwable { // simulate is what PopupView will do in response to hide() registeredCloseHandler.onClose(mock(CloseEvent.class)); return null; } }).when(popupView).hide(); popupActivity.onStartup(popupPlace); popupActivity.onOpen(); popupActivity.onClose(); verify(popupView).hide(); // PlaceManager initiated this operation, so we mustn't call back into it verify(placeManager, never()).closePlace(popupPlace); }
@Test public void shouldCloseViewInOnClose() throws Exception { popupActivity.onStartup(popupPlace); popupActivity.onOpen(); popupActivity.onClose(); verify(popupView, times(1)).hide(); }
@Test public void shouldCloseViewInOnClose() throws Exception { popupActivity.onStartup(popupPlace); popupActivity.onOpen(); popupActivity.onClose(); verify(popupView, times(1)).hide(); }
@Override public Void answer(InvocationOnMock invocation) throws Throwable { // simulate is what PlaceManager will do in response to the close hook popupActivity.onClose(); return null; } }).when(placeManager).closePlace(popupPlace);
@Override public Void answer(InvocationOnMock invocation) throws Throwable { // simulate is what PlaceManager will do in response to the close hook popupActivity.onClose(); return null; } }).when(placeManager).closePlace(popupPlace);