Beispiel #1
0
  @Test
  public void testReadLeft() {
    final List<Event> events = new LinkedList<Event>();
    GridColumn[] columns = createGridColumns(grid, 2, SWT.NONE);
    column.addListener(SWT.Move, new LoggingControlListener(events));
    columns[0].addListener(SWT.Move, new LoggingControlListener(events));
    columns[1].addListener(SWT.Move, new LoggingControlListener(events));

    // Simulate request that initializes widgets
    Fixture.fakeNewRequest();
    Fixture.executeLifeCycleFromServerThread();
    // Simulate request that changes column left
    int newLeft = 3;
    Fixture.fakeNewRequest();
    JsonObject parameters = new JsonObject().add("left", newLeft);
    Fixture.fakeCallOperation(getId(columns[0]), "move", parameters);
    Fixture.executeLifeCycleFromServerThread();

    assertEquals(2, events.size());
    Event event = events.get(0);
    assertSame(columns[0], event.widget);
    event = events.get(1);
    assertSame(column, event.widget);
    TestMessage message = Fixture.getProtocolMessage();
    assertEquals(20, message.findSetProperty(column, "left").asInt());
    assertEquals(0, message.findSetProperty(columns[0], "left").asInt());
  }
Beispiel #2
0
  @Test
  public void testSetDataEvent() {
    shell.setSize(100, 100);
    table = new Table(shell, SWT.VIRTUAL);
    Fixture.markInitialized(table);
    getRemoteObject(table).setHandler(new TableOperationHandler(table));
    Listener listener =
        new Listener() {
          @Override
          public void handleEvent(Event event) {
            Item item = (Item) event.item;
            item.setText("Item " + event.index);
          }
        };
    table.addListener(SWT.SetData, listener);
    table.setSize(90, 90);
    table.setItemCount(1000);
    shell.layout();
    shell.open();
    assertTrue(isItemVirtual(table, 500)); // ensure precondition

    fakeSetTopItemIndex(table, 500);
    Fixture.executeLifeCycleFromServerThread();

    // Remove SetData listener to not accidentially resolve item with asserts
    table.removeListener(SWT.SetData, listener);
    assertFalse(isItemVirtual(table, 500));
    assertFalse(isItemVirtual(table, 502));
    assertTrue(isItemVirtual(table, 510));
    assertEquals("Item 500", table.getItem(500).getText());
    assertEquals("Item 502", table.getItem(502).getText());
  }
Beispiel #3
0
  @Test
  public void testRenderCellToolTipText() {
    Fixture.markInitialized(display);
    Fixture.markInitialized(table);
    getRemoteObject(table).setHandler(new TableOperationHandler(table));
    createTableItems(table, 5);
    final ICellToolTipAdapter adapter = CellToolTipUtil.getAdapter(table);
    adapter.setCellToolTipProvider(
        new ICellToolTipProvider() {
          @Override
          public void getToolTipText(Item item, int columnIndex) {
            StringBuilder buffer = new StringBuilder();
            buffer.append("[");
            buffer.append(WidgetUtil.getId(item));
            buffer.append(",");
            buffer.append(columnIndex);
            buffer.append("]");
            adapter.setCellToolTipText(buffer.toString());
          }
        });

    String itemId = WidgetUtil.getId(table.getItem(2));
    fakeCellToolTipRequest(table, itemId, 0);
    Fixture.executeLifeCycleFromServerThread();

    TestMessage message = Fixture.getProtocolMessage();
    String expected = "[" + itemId + ",0]";
    assertEquals(expected, message.findSetProperty(table, "cellToolTipText").asString());
  }
Beispiel #4
0
  @Test
  public void testNoUnwantedResolveItems() {
    shell.setSize(100, 100);
    table = new Table(shell, SWT.VIRTUAL);
    Fixture.markInitialized(table);
    getRemoteObject(table).setHandler(new TableOperationHandler(table));
    table.setSize(90, 90);
    table.setItemCount(1000);
    shell.open();

    fakeSetTopItemIndex(table, 500);
    Fixture.executeLifeCycleFromServerThread();

    assertTrue(isItemVirtual(table, 499));
    assertTrue(isItemVirtual(table, 800));
    assertTrue(isItemVirtual(table, 999));
  }
Beispiel #5
0
  @Test
  public void testRenderCellToolTipText_null() {
    Fixture.markInitialized(display);
    Fixture.markInitialized(table);
    getRemoteObject(table).setHandler(new TableOperationHandler(table));
    createTableItems(table, 5);
    final ICellToolTipAdapter adapter = CellToolTipUtil.getAdapter(table);
    adapter.setCellToolTipProvider(
        new ICellToolTipProvider() {
          @Override
          public void getToolTipText(Item item, int columnIndex) {
            adapter.setCellToolTipText(null);
          }
        });

    String itemId = WidgetUtil.getId(table.getItem(2));
    fakeCellToolTipRequest(table, itemId, 0);
    Fixture.executeLifeCycleFromServerThread();

    TestMessage message = Fixture.getProtocolMessage();
    assertNull(message.findSetOperation(table, "cellToolTipText"));
  }