@Before public void setup() { this.column = new BooleanDOMElementColumn(headerMetaData, factory, 100); }
@Test public void renderingWithDOMElementColumnsAndWithoutRows() { final BaseGridRendererHelper.RenderingInformation ri = makeRenderingInformation(model, Collections.emptyList()); when(rendererHelper.getRenderingInformation()).thenReturn(ri); final BooleanDOMElementColumn column = spy(new BooleanDOMElementColumn(new BaseHeaderMetaData("col1"), new CheckBoxDOMElementFactory(gridLayer, gridWidget), 100.0)); model.appendColumn(column); final Context2D context2D = mock(Context2D.class); final BoundingBox boundingBox = mock(BoundingBox.class); gridWidget.drawWithTransforms(context2D, 1.0, boundingBox); verify(column, times(1)).initialiseResources(); verify(column, times(1)).freeUnusedResources(); verify(gridWidget, times(1)).drawHeader(eq(ri)); verify(gridWidget, never()).drawBody(any(BaseGridRendererHelper.RenderingInformation.class)); }
@Test @SuppressWarnings("unchecked") public void editTrueToFalse() { final GridCell<Boolean> cell = new BaseGridCell<>(new BaseGridCellValue<>(true)); column.edit(cell, context, callback); verify(callback, times(1)).accept(callbackArgumentCaptor.capture()); final BaseGridCellValue<Boolean> callbackArgument = callbackArgumentCaptor.getValue(); assertFalse(callbackArgument.getValue()); }
@Test public void renderingWithDOMElementColumnsAndWithoutRows() { final BaseGridRendererHelper.RenderingInformation ri = makeRenderingInformation(model, Collections.emptyList()); when(rendererHelper.getRenderingInformation()).thenReturn(ri); final BooleanDOMElementColumn column = spy(new BooleanDOMElementColumn(new BaseHeaderMetaData("col1"), new CheckBoxDOMElementFactory(gridLayer, gridWidget), 100.0)); model.appendColumn(column); final Context2D context2D = mock(Context2D.class); final BoundingBox boundingBox = mock(BoundingBox.class); gridWidget.drawWithTransforms(context2D, 1.0, boundingBox); verify(column, times(1)).initialiseResources(); verify(column, times(1)).freeUnusedResources(); verify(gridWidget, times(1)).drawHeader(eq(ri)); verify(gridWidget, never()).drawBody(any(BaseGridRendererHelper.RenderingInformation.class)); }
@Test @SuppressWarnings("unchecked") public void editFalseToTrue() { final GridCell<Boolean> cell = new BaseGridCell<>(new BaseGridCellValue<>(false)); column.edit(cell, context, callback); verify(callback, times(1)).accept(callbackArgumentCaptor.capture()); final BaseGridCellValue<Boolean> callbackArgument = callbackArgumentCaptor.getValue(); assertTrue(callbackArgument.getValue()); } }
@Test public void renderingWithDOMElementColumnsAndRows() { final BaseGridRendererHelper.RenderingInformation ri = makeRenderingInformation(model, Collections.singletonList(0d)); when(rendererHelper.getRenderingInformation()).thenReturn(ri); final BooleanDOMElementColumn column = spy(new BooleanDOMElementColumn(new BaseHeaderMetaData("col1"), new CheckBoxDOMElementFactory(gridLayer, gridWidget), 100.0)); model.appendColumn(column); model.appendRow(new BaseGridRow(HEADER_ROW_HEIGHT)); final Context2D context2D = mock(Context2D.class); final BoundingBox boundingBox = mock(BoundingBox.class); gridWidget.drawWithTransforms(context2D, 1.0, boundingBox); verify(column, times(1)).initialiseResources(); verify(column, times(1)).freeUnusedResources(); verify(gridWidget, times(1)).drawHeader(eq(ri)); verify(gridWidget, times(1)).drawBody(eq(ri)); }
@Test @SuppressWarnings("unchecked") public void editTrueToFalse() { final GridCell<Boolean> cell = new BaseGridCell<>(new BaseGridCellValue<>(true)); column.edit(cell, context, callback); verify(callback, times(1)).accept(callbackArgumentCaptor.capture()); final BaseGridCellValue<Boolean> callbackArgument = callbackArgumentCaptor.getValue(); assertFalse(callbackArgument.getValue()); }
@Before public void setup() { this.column = new BooleanDOMElementColumn(headerMetaData, factory, 100); }
@Test public void renderingWithDOMElementColumnsAndRows() { final BaseGridRendererHelper.RenderingInformation ri = makeRenderingInformation(model, Collections.singletonList(0d)); when(rendererHelper.getRenderingInformation()).thenReturn(ri); final BooleanDOMElementColumn column = spy(new BooleanDOMElementColumn(new BaseHeaderMetaData("col1"), new CheckBoxDOMElementFactory(gridLayer, gridWidget), 100.0)); model.appendColumn(column); model.appendRow(new BaseGridRow(HEADER_ROW_HEIGHT)); final Context2D context2D = mock(Context2D.class); final BoundingBox boundingBox = mock(BoundingBox.class); gridWidget.drawWithTransforms(context2D, 1.0, boundingBox); verify(column, times(1)).initialiseResources(); verify(column, times(1)).freeUnusedResources(); verify(gridWidget, times(1)).drawHeader(eq(ri)); verify(gridWidget, times(1)).drawBody(eq(ri)); }
@Test @SuppressWarnings("unchecked") public void editFalseToTrue() { final GridCell<Boolean> cell = new BaseGridCell<>(new BaseGridCellValue<>(false)); column.edit(cell, context, callback); verify(callback, times(1)).accept(callbackArgumentCaptor.capture()); final BaseGridCellValue<Boolean> callbackArgument = callbackArgumentCaptor.getValue(); assertTrue(callbackArgument.getValue()); } }