@Before @SuppressWarnings("unchecked") public void setup() { when(popupView.addCloseHandler(any(CloseHandler.class))).thenAnswer(new Answer<HandlerRegistration>() { @Override public HandlerRegistration answer(InvocationOnMock invocation) throws Throwable { registeredCloseHandler = (CloseHandler<PopupView>) invocation.getArguments()[0]; closeHandlerRegistration = mock(HandlerRegistration.class); return closeHandlerRegistration; } }); popupActivity = new TestingPopupActivity(placeManager, popupView); popupPlace = new DefaultPlaceRequest("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 to ensure we don't start an infinite loop when someone clicks the "X" in the popup header. * See also the complementary test, {@link #shouldNotCallCloseOnPlaceManagerWhenCloseOperationTriggeredByPlaceManager()}. */ @SuppressWarnings("unchecked") @Test public void shouldNotCallHideOnViewWhenCloseOperationTriggeredByView() throws Exception { doAnswer(new Answer<Void>() { @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); popupActivity.onStartup(popupPlace); popupActivity.onOpen(); registeredCloseHandler.onClose(mock(CloseEvent.class)); verify(placeManager, times(1)).closePlace(popupPlace); // we shouldn't call hide() on the popup, because this sequence of events // was triggered by the fact that it was already hiding itself verify(popupView, never()).hide(); }
/** * Test to ensure we don't start an infinite loop when someone clicks the "X" in the popup header. * See also the complementary test, {@link #shouldNotCallCloseOnPlaceManagerWhenCloseOperationTriggeredByPlaceManager()}. */ @SuppressWarnings("unchecked") @Test public void shouldNotCallHideOnViewWhenCloseOperationTriggeredByView() throws Exception { doAnswer(new Answer<Void>() { @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); popupActivity.onStartup(popupPlace); popupActivity.onOpen(); registeredCloseHandler.onClose(mock(CloseEvent.class)); verify(placeManager, times(1)).closePlace(popupPlace); // we shouldn't call hide() on the popup, because this sequence of events // was triggered by the fact that it was already hiding itself verify(popupView, never()).hide(); }
/** * 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); }
@Before @SuppressWarnings("unchecked") public void setup() { when(popupView.addCloseHandler(any(CloseHandler.class))).thenAnswer(new Answer<HandlerRegistration>() { @Override public HandlerRegistration answer(InvocationOnMock invocation) throws Throwable { registeredCloseHandler = (CloseHandler<PopupView>) invocation.getArguments()[0]; closeHandlerRegistration = mock(HandlerRegistration.class); return closeHandlerRegistration; } }); popupActivity = new TestingPopupActivity(placeManager, popupView); popupPlace = new DefaultPlaceRequest("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);
@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);