MultiPageEditorViewImpl extends ResizeTabPanel implements MultiPageEditorView { TabShownHandler getTabShownHandler() { return event -> { onResize(); final TabListItem tab = event.getTab(); final TabPanelEntry tabPanelEntry = findEntryForTabWidget(tab); final PageViewImpl page = (PageViewImpl) tabPanelEntry.getContentPane().getWidget(0); getSelectedPageEvent().ifPresent(selectedPageEvent -> { selectedPageEvent.fire(new MultiPageEditorSelectedPageEvent(tab.getTabIndex())); }); page.onLostFocus(); }; }  @Override void init(); void enableSelectedPageEvent(final Event<MultiPageEditorSelectedPageEvent> selectedPageEvent); void addPage(final Page page); @Override void addPage(int index, final Page page); void selectPage(int index); int selectedPage(); @Override void disablePage(int index); @Override void enablePage(int index); @Override int getPageIndex(final String title);  }
@Test public void testGetTabShownHandler() { final TabListItem tab = mock(TabListItem.class); final TabShownEvent event = mock(TabShownEvent.class); final TabPanelEntry tabPanelEntry = mock(TabPanelEntry.class); final TabPane tabPane = mock(TabPane.class); final PageViewImpl page = mock(PageViewImpl.class); final int pageIndex = 42; when(event.getTab()).thenReturn(tab); when(tabPanelEntry.getContentPane()).thenReturn(tabPane); when(tabPane.getWidget(0)).thenReturn(page); when(tab.getTabIndex()).thenReturn(pageIndex); doReturn(tabPanelEntry).when(view).findEntryForTabWidget(tab); view.enableSelectedPageEvent(selectedPageEvent); view.getTabShownHandler().onShown(event); verify(view).onResize(); verify(selectedPageEvent).fire(pageEvent.capture()); verify(page).onLostFocus(); assertEquals(pageIndex, pageEvent.getValue().getSelectedPage()); }