Exemplo n.º 1
0
  private void checkRenderedSelectedCells(
      final int selectionRowIndex,
      final int selectionColumnIndex,
      final int selectionColumnCount,
      final int selectionRowCount,
      final int minVisibleRowIndex,
      final int maxVisibleRowIndex) {
    this.model.selectCells(
        selectionRowIndex, selectionColumnIndex, selectionColumnCount, selectionRowCount);
    when(context.getMinVisibleRowIndex()).thenReturn(minVisibleRowIndex);
    when(context.getMaxVisibleRowIndex()).thenReturn(maxVisibleRowIndex);

    renderer.renderSelectedCells(model, context, rendererHelper);

    verify(renderer, times(1))
        .renderSelectedRange(
            eq(model),
            columnsCaptor.capture(),
            eq(selectionColumnIndex),
            selectedRangeCaptor.capture());

    final List<GridColumn<?>> columns = columnsCaptor.getValue();
    assertNotNull(columns);
    assertEquals(1, columns.size());
    assertEquals(column, columns.get(0));

    final SelectedRange selectedRange = selectedRangeCaptor.getValue();
    assertNotNull(selectedRange);
    assertEquals(selectionColumnIndex, selectedRange.getUiColumnIndex());
    assertEquals(minVisibleRowIndex, selectedRange.getUiRowIndex());
    assertEquals(selectionColumnCount, selectedRange.getWidth());
    assertEquals(maxVisibleRowIndex - minVisibleRowIndex + 1, selectedRange.getHeight());
  }
Exemplo n.º 2
0
  @Before
  public void setup() {
    final BaseGridRenderer wrapped = new BaseGridRenderer(theme);
    this.renderer = spy(wrapped);

    this.column = new StringPopupColumn(new BaseHeaderMetaData("title"), columnRenderer, 100.0);

    this.model = new BaseGridData();
    this.model.appendColumn(column);
    this.model.appendRow(new BaseGridRow());
    this.model.appendRow(new BaseGridRow());
    this.model.appendRow(new BaseGridRow());

    this.selectionsTransformer =
        new DefaultSelectionsTransformer(model, Collections.singletonList(column));

    when(context.getBlockColumns()).thenReturn(Collections.singletonList(column));
    when(context.getTransformer()).thenReturn(selectionsTransformer);
  }