@Test(expected = IllegalArgumentException.class) public void testRenderControlColumnOther() throws NoRendererFoundException, NoPropertyDescriptorFoundExeption { final SWTGridCell swtGridCell = mock(SWTGridCell.class); when(swtGridCell.getColumn()).thenReturn(2); final CompoundControlSWTRenderer renderer = spy(createRenderer()); renderer.renderControl(swtGridCell, shell); }
@Test public void testRenderControlColumn1() throws NoRendererFoundException, NoPropertyDescriptorFoundExeption { final SWTGridCell swtGridCell = mock(SWTGridCell.class); when(swtGridCell.getColumn()).thenReturn(1); final CompoundControlSWTRenderer renderer = spy(createRenderer()); doReturn(new Label(shell, SWT.NONE)).when(renderer).createControls(shell); renderer.renderControl(swtGridCell, shell); verify(renderer, times(1)).createControls(shell); }
@Override public SWTGridDescription getGridDescription(SWTGridDescription gridDescription) { if (rendererGridDescription == null) { rendererGridDescription = GridDescriptionFactory.INSTANCE.createSimpleGrid(1, 2, this); for (int i = 0; i < rendererGridDescription.getGrid().size() - 1; i++) { final SWTGridCell swtGridCell = rendererGridDescription.getGrid().get(i); swtGridCell.setHorizontalGrab(false); } } return rendererGridDescription; }
@Override protected Control renderControl(SWTGridCell gridCell, Composite parent) throws NoRendererFoundException, NoPropertyDescriptorFoundExeption { switch (gridCell.getColumn()) { case 0: return createLabel(C_VALIDATION, parent); case 1: return createLabel(C_CONTROL, parent); default: throw new IllegalArgumentException(); } }
@Test public void testGetGridDescription() { final CompoundControlSWTRenderer renderer = createRenderer(); final SWTGridDescription gridDescription = renderer.getGridDescription(mock(SWTGridDescription.class)); assertEquals(2, gridDescription.getColumns()); assertEquals(1, gridDescription.getRows()); assertEquals(2, gridDescription.getGrid().size()); final SWTGridCell label = gridDescription.getGrid().get(0); assertEquals(0, label.getColumn()); assertEquals(1, label.getHorizontalSpan()); assertEquals(0, label.getRow()); assertSame(renderer, label.getRenderer()); assertTrue(label.isHorizontalFill()); assertFalse(label.isHorizontalGrab()); assertFalse(label.isVerticalFill()); assertFalse(label.isVerticalGrab()); final SWTGridCell controls = gridDescription.getGrid().get(1); assertEquals(1, controls.getColumn()); assertEquals(1, controls.getHorizontalSpan()); assertEquals(0, controls.getRow()); assertSame(renderer, controls.getRenderer()); assertTrue(controls.isHorizontalFill()); assertTrue(controls.isHorizontalGrab()); assertFalse(controls.isVerticalFill()); assertFalse(controls.isVerticalGrab()); }