Exemplo n.º 1
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());
  }
Exemplo n.º 2
0
  @Test
  public void testRedraw() {
    final Table[] table = {null};
    shell.setSize(100, 100);
    Button button = new Button(shell, SWT.PUSH);
    getRemoteObject(button).setHandler(new ButtonOperationHandler(button));
    button.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent event) {
            table[0] = new Table(shell, SWT.VIRTUAL);
            table[0].setItemCount(500);
            table[0].setSize(90, 90);
            assertFalse(isItemVirtual(table[0], 0));
            table[0].clearAll();
            table[0].redraw();
          }
        });
    shell.open();

    Fixture.fakeNotifyOperation(getId(button), ClientMessageConst.EVENT_SELECTION, null);
    Fixture.readDataAndProcessAction(display);

    assertFalse(isItemVirtual(table[0], 0));
  }
Exemplo n.º 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());
  }
Exemplo n.º 4
0
 @Before
 public void setUp() {
   Fixture.setUp();
   display = new Display();
   shell = new Shell(display);
   grid = new Grid(shell, SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
   column = new GridColumn(grid, SWT.NONE);
   lca = (GridColumnLCA) WidgetUtil.getLCA(column);
   Fixture.fakeNewRequest();
 }
Exemplo n.º 5
0
  @Test
  public void testDontRenderSetDataWithoutVirtual() throws Exception {
    Fixture.markInitialized(display);
    Fixture.markInitialized(table);
    Fixture.preserveWidgets();

    lca.renderChanges(table);

    TestMessage message = Fixture.getProtocolMessage();
    assertNull(message.findListenOperation(table, "SetData"));
  }
Exemplo n.º 6
0
  @Test
  public void testRenderScrollLeftUnchanged() throws IOException {
    Fixture.markInitialized(display);
    Fixture.markInitialized(table);

    table.getAdapter(ITableAdapter.class).setLeftOffset(10);
    Fixture.preserveWidgets();
    getLCA(display).render(display);

    TestMessage message = Fixture.getProtocolMessage();
    assertNull(message.findSetOperation(table, "scrollLeft"));
  }
Exemplo n.º 7
0
  @Test
  public void testRenderLinesVisibleUnchanged() throws IOException {
    Fixture.markInitialized(display);
    Fixture.markInitialized(table);

    table.setLinesVisible(true);
    Fixture.preserveWidgets();
    lca.renderChanges(table);

    TestMessage message = Fixture.getProtocolMessage();
    assertNull(message.findSetOperation(table, "linesVisible"));
  }
Exemplo n.º 8
0
  @Test
  public void testRenderColumnCountUnchanged() throws IOException {
    Fixture.markInitialized(display);
    Fixture.markInitialized(table);

    new TableColumn(table, SWT.NONE);
    Fixture.preserveWidgets();
    lca.renderChanges(table);

    TestMessage message = Fixture.getProtocolMessage();
    assertNull(message.findSetOperation(table, "columnCount"));
  }
Exemplo n.º 9
0
  @Test
  public void testRenderItemCountUnchanged() throws IOException {
    Fixture.markInitialized(display);
    Fixture.markInitialized(table);

    table.setItemCount(10);
    Fixture.preserveWidgets();
    lca.renderChanges(table);

    TestMessage message = Fixture.getProtocolMessage();
    assertNull(message.findSetOperation(table, "itemCount"));
  }
Exemplo n.º 10
0
  @Test
  public void testDontRenderSetDataListenerTwice() throws Exception {
    table = new Table(shell, SWT.VIRTUAL | SWT.NO_SCROLL | SWT.MULTI);
    Fixture.markInitialized(display);
    Fixture.markInitialized(table);
    Fixture.preserveWidgets();

    lca.renderChanges(table);

    TestMessage message = Fixture.getProtocolMessage();
    assertNull(message.findListenOperation(table, "SetData"));
  }
Exemplo n.º 11
0
  @Test
  public void testRenderEnableCellToolTipUnchanged() throws IOException {
    Fixture.markInitialized(display);
    Fixture.markInitialized(table);

    table.setData(ICellToolTipProvider.ENABLE_CELL_TOOLTIP, Boolean.TRUE);
    Fixture.preserveWidgets();
    lca.renderChanges(table);

    TestMessage message = Fixture.getProtocolMessage();
    assertNull(message.findSetOperation(table, "enableCellToolTip"));
  }
Exemplo n.º 12
0
  @Test
  public void testRenderCustomVariantUnchanged() throws IOException {
    Fixture.markInitialized(display);
    Fixture.markInitialized(column);

    column.setData(RWT.CUSTOM_VARIANT, "blue");
    Fixture.preserveWidgets();
    lca.renderChanges(column);

    TestMessage message = Fixture.getProtocolMessage();
    assertNull(message.findSetOperation(column, "customVariant"));
  }
Exemplo n.º 13
0
  @Test
  public void testRenderAlignmentUnchanged() throws IOException {
    Fixture.markInitialized(display);
    Fixture.markInitialized(column);

    column.setAlignment(SWT.RIGHT);
    Fixture.preserveWidgets();
    lca.renderChanges(column);

    TestMessage message = Fixture.getProtocolMessage();
    assertNull(message.findSetOperation(column, "alignment"));
  }
Exemplo n.º 14
0
  @Test
  public void testRenderMnemonicIndexUnchanged() throws IOException {
    Fixture.markInitialized(display);
    Fixture.markInitialized(group);

    group.setText("te&st");
    Fixture.preserveWidgets();
    lca.renderChanges(group);

    TestMessage message = Fixture.getProtocolMessage();
    assertNull(message.findSetOperation(group, "mnemonicIndex"));
  }
Exemplo n.º 15
0
  @Test
  public void testRenderHeaderWordWrapUnchanged() throws IOException {
    Fixture.markInitialized(display);
    Fixture.markInitialized(column);

    column.setHeaderWordWrap(true);
    Fixture.preserveWidgets();
    lca.renderChanges(column);

    TestMessage message = Fixture.getProtocolMessage();
    assertNull(message.findSetOperation(column, "headerWordWrap"));
  }
Exemplo n.º 16
0
  @Test
  public void testRenderShowFocusedControlUnchanged() throws IOException {
    Fixture.markInitialized(display);
    Fixture.markInitialized(sc);

    sc.setShowFocusedControl(true);
    Fixture.preserveWidgets();
    lca.renderChanges(sc);

    TestMessage message = Fixture.getProtocolMessage();
    assertNull(message.findSetOperation(sc, "showFocusedControl"));
  }
Exemplo n.º 17
0
  @Test
  public void testRenderFontUnchanged() throws IOException {
    Fixture.markInitialized(display);
    Fixture.markInitialized(column);

    column.setHeaderFont(new Font(display, "Arial", 20, SWT.BOLD));
    Fixture.preserveWidgets();
    lca.renderChanges(column);

    TestMessage message = Fixture.getProtocolMessage();
    assertNull(message.findSetOperation(column, "font"));
  }
Exemplo n.º 18
0
  @Test
  public void testRenderFooterTextUnchanged() throws IOException {
    Fixture.markInitialized(display);
    Fixture.markInitialized(column);

    column.setFooterText("foo");
    Fixture.preserveWidgets();
    lca.renderChanges(column);

    TestMessage message = Fixture.getProtocolMessage();
    assertNull(message.findSetOperation(column, "footerText"));
  }
Exemplo n.º 19
0
  @Test
  public void testRenderAddSelectionListener() throws Exception {
    Fixture.markInitialized(display);
    Fixture.markInitialized(column);
    Fixture.preserveWidgets();

    column.addListener(SWT.Selection, mock(Listener.class));
    lca.renderChanges(column);

    TestMessage message = Fixture.getProtocolMessage();
    assertEquals(JsonValue.TRUE, message.findListenProperty(column, "Selection"));
  }
Exemplo n.º 20
0
  @Test
  public void testRenderCheckUnchanged() throws IOException {
    column = new GridColumn(grid, SWT.CHECK);
    Fixture.markInitialized(display);
    Fixture.markInitialized(column);

    Fixture.preserveWidgets();
    lca.renderChanges(column);

    TestMessage message = Fixture.getProtocolMessage();
    assertNull(message.findSetOperation(column, "check"));
  }
Exemplo n.º 21
0
  @Test
  public void testRenderVisibleUnchanged() throws IOException {
    Fixture.markInitialized(display);
    Fixture.markInitialized(column);

    column.setVisible(false);
    Fixture.preserveWidgets();
    lca.renderChanges(column);

    TestMessage message = Fixture.getProtocolMessage();
    assertNull(message.findSetOperation(column, "visibility"));
  }
Exemplo n.º 22
0
  @Test
  public void testRenderAlwaysHideSelectionUnchanged() throws IOException {
    Fixture.markInitialized(display);
    Fixture.markInitialized(table);

    table.setData(Table.ALWAYS_HIDE_SELECTION, Boolean.TRUE);
    Fixture.preserveWidgets();
    lca.renderChanges(table);

    TestMessage message = Fixture.getProtocolMessage();
    assertNull(message.findSetOperation(table, "alwaysHideSelection"));
  }
Exemplo n.º 23
0
  @Test
  public void testRenderAddScrollBarsSelectionListener_Vertical() throws Exception {
    Fixture.markInitialized(display);
    Fixture.markInitialized(sc);
    Fixture.markInitialized(vScroll);
    Fixture.preserveWidgets();

    vScroll.addSelectionListener(new SelectionAdapter() {});
    lca.renderChanges(sc);

    TestMessage message = Fixture.getProtocolMessage();
    assertEquals(JsonValue.TRUE, message.findListenProperty(vScroll, "Selection"));
  }
Exemplo n.º 24
0
  @Test
  public void testRenderContentUnchanged() throws IOException {
    Composite content = new Composite(sc, SWT.NONE);
    Fixture.markInitialized(display);
    Fixture.markInitialized(sc);

    sc.setContent(content);
    Fixture.preserveWidgets();
    lca.renderChanges(sc);

    TestMessage message = Fixture.getProtocolMessage();
    assertNull(message.findSetOperation(sc, "content"));
  }
Exemplo n.º 25
0
  @Test
  public void testReadData_ScrollBarsSelectionEvent() {
    sc.setContent(new Composite(sc, SWT.NONE));
    SelectionListener selectionListener = mock(SelectionListener.class);
    hScroll.addSelectionListener(selectionListener);
    vScroll.addSelectionListener(selectionListener);

    Fixture.fakeNotifyOperation(getId(hScroll), "Selection", null);
    Fixture.fakeNotifyOperation(getId(vScroll), "Selection", null);
    Fixture.readDataAndProcessAction(sc);

    verify(selectionListener, times(2)).widgetSelected(any(SelectionEvent.class));
  }
Exemplo n.º 26
0
  @Test
  public void testRenderFooterSpanUnchanged() throws IOException {
    Fixture.markInitialized(display);
    Fixture.markInitialized(column);
    createGridColumns(grid, 3, SWT.NONE);
    column.setData("footerSpan", Integer.valueOf(2));

    Fixture.preserveWidgets();
    lca.renderChanges(column);

    TestMessage message = Fixture.getProtocolMessage();
    assertNull(message.findSetOperation(column, "footerSpan"));
  }
Exemplo n.º 27
0
  @Test
  public void testRenderFooterImageUnchanged() throws IOException {
    Fixture.markInitialized(display);
    Fixture.markInitialized(column);
    Image image = loadImage(display, Fixture.IMAGE_100x50);

    column.setFooterImage(image);
    Fixture.preserveWidgets();
    lca.renderChanges(column);

    TestMessage message = Fixture.getProtocolMessage();
    assertNull(message.findSetOperation(column, "footerImage"));
  }
Exemplo n.º 28
0
  @Test
  public void testRenderFocusItemUnchanged() throws IOException {
    createTableItems(table, 3);
    Fixture.markInitialized(display);
    Fixture.markInitialized(table);

    table.getAdapter(ITableAdapter.class).setFocusIndex(2);
    Fixture.preserveWidgets();
    getLCA(display).render(display);

    TestMessage message = Fixture.getProtocolMessage();
    assertNull(message.findSetOperation(table, "focusItem"));
  }
Exemplo n.º 29
0
  @Test
  public void testRenderSelectionListenerUnchanged() throws Exception {
    Fixture.markInitialized(display);
    Fixture.markInitialized(column);
    Fixture.preserveWidgets();

    column.addListener(SWT.Selection, mock(Listener.class));
    Fixture.preserveWidgets();
    lca.renderChanges(column);

    TestMessage message = Fixture.getProtocolMessage();
    assertNull(message.findListenOperation(column, "Selection"));
  }
Exemplo n.º 30
0
  @Test
  public void testRenderLeftUnchanged() throws IOException {
    Fixture.markInitialized(display);
    Fixture.markInitialized(column);

    GridColumn column2 = new GridColumn(grid, SWT.NONE, 0);
    column2.setWidth(50);
    Fixture.preserveWidgets();
    lca.renderChanges(column);

    TestMessage message = Fixture.getProtocolMessage();
    assertNull(message.findSetOperation(column, "left"));
  }