@Test
  public void testClosingATabIsBlockedByTheActivity() throws Exception {
    Place place = mock(Place.class);
    multiActivityManager.setTabbedPanel(tabbedPanel);

    Activity activity = goTo(place);
    when(activity.mayStop()).thenReturn(false);

    multiActivityManager.onCloseTab(new ClosePlaceEvent(place));
    verify(activity, never()).onStop();
  }
  @Test
  public void testCloseTabCallsOnStopAndRemovesWrappersHandlers() throws Exception {
    Place place = mock(Place.class);
    multiActivityManager.setTabbedPanel(tabbedPanel);
    ArgumentCaptor<ResettableEventBus> resettableEventBusArgumentCaptor =
        ArgumentCaptor.forClass(ResettableEventBus.class);

    HandlerRegistration handlerRegistration = mock(HandlerRegistration.class);
    ClosePlaceEvent.Handler handler = mock(ClosePlaceEvent.Handler.class);
    when(eventBus.addHandler(ClosePlaceEvent.TYPE, handler)).thenReturn(handlerRegistration);

    Activity activity = goTo(place);

    when(activity.mayStop()).thenReturn(true);

    verify(activity).start(any(AcceptTabItem.class), resettableEventBusArgumentCaptor.capture());
    resettableEventBusArgumentCaptor.getValue().addHandler(ClosePlaceEvent.TYPE, handler);

    multiActivityManager.onCloseTab(new ClosePlaceEvent(place));
    verify(activity).onStop();
    verify(handlerRegistration).removeHandler();
  }
 @Test
 public void testItIsSafeToCloseATabThatDoesNotExist() throws Exception {
   multiActivityManager.onCloseTab(new ClosePlaceEvent(new AssetEditorPlace("I-do-Not-Exist")));
   // Does nothing
 }