@Test public void removeNonContainedPart() { WorkbenchPartPresenter mockPresenter = mock(WorkbenchPartPresenter.class); WorkbenchPartPresenter.View mockPartView = mock(WorkbenchPartPresenter.View.class); PartDefinition mockPartDefinition = new PartDefinitionImpl(new DefaultPlaceRequest("mock1")); when(mockPartView.getPresenter()).thenReturn(mockPresenter); when(mockPresenter.getDefinition()).thenReturn(mockPartDefinition); WorkbenchPartPresenter mockPresenter2 = mock(WorkbenchPartPresenter.class); WorkbenchPartPresenter.View mockPartView2 = mock(WorkbenchPartPresenter.View.class); PartDefinition mockPartDefinition2 = new PartDefinitionImpl(new DefaultPlaceRequest("mock2")); when(mockPartView2.getPresenter()).thenReturn(mockPresenter2); when(mockPresenter2.getDefinition()).thenReturn(mockPartDefinition2); when(view.panel.getPartView()).thenReturn(null); view.addPart(mockPartView); when(view.panel.getPartView()).thenReturn(mockPartView); boolean removed = view.removePart(mockPartDefinition2); assertFalse(removed); verify(panel, never()).clear(); }
@Test public void onResize() { final int width = 42; final int height = 10; view.setPixelSize(width, height); view.onResize(); verify(panel).onResize(); }
@Test public void addPartToPanelWhenPartViewIsNull() { WorkbenchPartPresenter.View viewWbPartPresenter = mock(WorkbenchPartPresenter.View.class); when(panel.getPartView()).thenReturn(null); view.addPart(viewWbPartPresenter); verify(panel).setPart(viewWbPartPresenter); }
@Test public void addPresenterOnInit() { assertEquals(presenter, view.getPresenter()); }
@Before public void setup() { view.postConstruct(); view.init(presenter); }
@Test public void getPartsShouldReturnCurrentPart() { assertFalse(view.getParts().isEmpty()); }