Example #1
0
  @Test
  public void testSelectionAfterRemoveAll() {
    combo = new Combo(shell, SWT.READ_ONLY);
    Fixture.markInitialized(display);
    Fixture.markInitialized(combo);
    combo.add("item 1");
    combo.select(0);
    Button button = new Button(shell, SWT.PUSH);
    button.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            combo.removeAll();
            combo.add("replacement for item 1");
            combo.select(0);
          }
        });

    // Simulate button click that executes widgetSelected
    Fixture.fakeNotifyOperation(getId(button), ClientMessageConst.EVENT_SELECTION, null);
    Fixture.executeLifeCycleFromServerThread();

    Message message = Fixture.getProtocolMessage();
    assertEquals(new Integer(0), message.findSetProperty(combo, PROP_SELECTION_INDEX));
  }
Example #2
0
  @Test
  public void testRenderItemHeight() throws IOException {
    combo.setFont(new Font(display, "Arial", 16, SWT.NONE));
    lca.renderChanges(combo);

    Message message = Fixture.getProtocolMessage();
    assertEquals(new Integer(22), message.findSetProperty(combo, "itemHeight"));
  }
Example #3
0
  @Test
  public void testRenderCreate() throws IOException {
    lca.renderInitialization(progressBar);

    Message message = Fixture.getProtocolMessage();
    CreateOperation operation = message.findCreateOperation(progressBar);
    assertEquals("rwt.widgets.ProgressBar", operation.getType());
  }
Example #4
0
  @Test
  public void testRenderState() throws IOException {
    progressBar.setState(SWT.ERROR);
    lca.renderChanges(progressBar);

    Message message = Fixture.getProtocolMessage();
    assertEquals("error", message.findSetProperty(progressBar, "state").asString());
  }
Example #5
0
  @Test
  public void testRenderSelection() throws IOException {
    progressBar.setSelection(10);
    lca.renderChanges(progressBar);

    Message message = Fixture.getProtocolMessage();
    assertEquals(10, message.findSetProperty(progressBar, "selection").asInt());
  }
Example #6
0
  @Test
  public void testRenderListVisible() throws IOException {
    combo.setListVisible(true);
    lca.renderChanges(combo);

    Message message = Fixture.getProtocolMessage();
    assertEquals(Boolean.TRUE, message.findSetProperty(combo, "listVisible"));
  }
Example #7
0
  @Test
  public void testRenderInitialState() throws IOException {
    lca.render(progressBar);

    Message message = Fixture.getProtocolMessage();
    CreateOperation operation = message.findCreateOperation(progressBar);
    assertTrue(operation.getPropertyNames().indexOf("state") == -1);
  }
Example #8
0
  @Test
  public void testRenderParent() throws IOException {
    lca.renderInitialization(progressBar);

    Message message = Fixture.getProtocolMessage();
    CreateOperation operation = message.findCreateOperation(progressBar);
    assertEquals(WidgetUtil.getId(progressBar.getParent()), operation.getParent());
  }
Example #9
0
  @Test
  public void testRenderInitialItemHeight() throws IOException {
    lca.render(combo);

    Message message = Fixture.getProtocolMessage();
    CreateOperation operation = message.findCreateOperation(combo);
    assertTrue(operation.getPropertyNames().contains("itemHeight"));
  }
Example #10
0
  @Test
  public void testRenderInitialTextLimit() throws IOException {
    lca.render(combo);

    Message message = Fixture.getProtocolMessage();
    CreateOperation operation = message.findCreateOperation(combo);
    assertTrue(operation.getPropertyNames().indexOf("textLimit") == -1);
  }
Example #11
0
  @Test
  public void testRenderTextLimit() throws IOException {
    combo.setTextLimit(10);
    lca.renderChanges(combo);

    Message message = Fixture.getProtocolMessage();
    assertEquals(new Integer(10), message.findSetProperty(combo, "textLimit"));
  }
Example #12
0
  @Test
  public void testRenderText() throws IOException {
    combo.setText("foo");
    lca.renderChanges(combo);

    Message message = Fixture.getProtocolMessage();
    assertEquals("foo", message.findSetProperty(combo, "text"));
  }
  public void testRenderMaxmum() throws IOException {
    Scale scale = new Scale(shell, SWT.NONE);

    scale.setMaximum(10);
    lca.renderChanges(scale);

    Message message = Fixture.getProtocolMessage();
    assertEquals(new Integer(10), message.findSetProperty(scale, "maximum"));
  }
  public void testRenderPageIncrement() throws IOException {
    Scale scale = new Scale(shell, SWT.NONE);

    scale.setPageIncrement(20);
    lca.renderChanges(scale);

    Message message = Fixture.getProtocolMessage();
    assertEquals(new Integer(20), message.findSetProperty(scale, "pageIncrement"));
  }
  public void testRenderInitialPageIncrement() throws IOException {
    Scale scale = new Scale(shell, SWT.NONE);

    lca.render(scale);

    Message message = Fixture.getProtocolMessage();
    CreateOperation operation = message.findCreateOperation(scale);
    assertTrue(operation.getPropertyNames().indexOf("pageIncrement") == -1);
  }
  public void testRenderParent() throws IOException {
    Scale scale = new Scale(shell, SWT.NONE);

    lca.renderInitialization(scale);

    Message message = Fixture.getProtocolMessage();
    CreateOperation operation = message.findCreateOperation(scale);
    assertEquals(WidgetUtil.getId(scale.getParent()), operation.getParent());
  }
  public void testRenderCreate() throws IOException {
    Scale scale = new Scale(shell, SWT.NONE);

    lca.renderInitialization(scale);

    Message message = Fixture.getProtocolMessage();
    CreateOperation operation = message.findCreateOperation(scale);
    assertEquals("rwt.widgets.Scale", operation.getType());
  }
Example #18
0
  @Test
  public void testRenderChanges_rendersClientListener() throws IOException {
    progressBar.addListener(SWT.MouseEnter, new ClientListener(""));

    lca.renderChanges(progressBar);

    Message message = Fixture.getProtocolMessage();
    assertNotNull(message.findCallOperation(progressBar, "addListener"));
  }
Example #19
0
  @Test
  public void testRenderTextNotEditable() throws IOException {
    Combo combo = new Combo(shell, SWT.READ_ONLY);

    combo.setText("foo");
    lca.renderChanges(combo);

    Message message = Fixture.getProtocolMessage();
    assertNull(message.findSetOperation(combo, "text"));
  }
Example #20
0
  @Test
  public void testRenderSelectionIndex() throws IOException {
    combo.setItems(new String[] {"a", "b", "c"});

    combo.select(1);
    lca.renderChanges(combo);

    Message message = Fixture.getProtocolMessage();
    assertEquals(new Integer(1), message.findSetProperty(combo, "selectionIndex"));
  }
Example #21
0
  @Test
  public void testRenderEditable_ReadOnly() throws IOException {
    Combo combo = new Combo(shell, SWT.READ_ONLY);

    lca.render(combo);

    Message message = Fixture.getProtocolMessage();
    CreateOperation operation = message.findCreateOperation(combo);
    assertEquals(Boolean.FALSE, operation.getProperty("editable"));
  }
  public void testRenderCreateWithHorizontal() throws IOException {
    Scale scale = new Scale(shell, SWT.HORIZONTAL);

    lca.renderInitialization(scale);

    Message message = Fixture.getProtocolMessage();
    CreateOperation operation = message.findCreateOperation(scale);
    Object[] styles = operation.getStyles();
    assertTrue(Arrays.asList(styles).contains("HORIZONTAL"));
  }
Example #23
0
  @Test
  public void testRenderItems() throws IOException, JSONException {
    combo.setItems(new String[] {"a", "b", "c"});
    lca.renderChanges(combo);

    Message message = Fixture.getProtocolMessage();
    String expected = "[ \"a\", \"b\", \"c\" ]";
    JSONArray actual = (JSONArray) message.findSetProperty(combo, "items");
    assertTrue(ProtocolTestUtil.jsonEquals(expected, actual));
  }
Example #24
0
  @Test
  public void testRenderSelection() throws IOException, JSONException {
    combo.setText("foo bar");

    combo.setSelection(new Point(1, 3));
    lca.renderChanges(combo);

    Message message = Fixture.getProtocolMessage();
    JSONArray actual = (JSONArray) message.findSetProperty(combo, "selection");
    assertTrue(ProtocolTestUtil.jsonEquals("[ 1, 3 ]", actual));
  }
Example #25
0
  @Test
  public void testRenderStateUnchanged() throws IOException {
    Fixture.markInitialized(display);
    Fixture.markInitialized(progressBar);

    progressBar.setState(SWT.ERROR);
    Fixture.preserveWidgets();
    lca.renderChanges(progressBar);

    Message message = Fixture.getProtocolMessage();
    assertNull(message.findSetOperation(progressBar, "state"));
  }
Example #26
0
  @Test
  public void testRenderTextLimitUnchanged() throws IOException {
    Fixture.markInitialized(display);
    Fixture.markInitialized(combo);

    combo.setTextLimit(10);
    Fixture.preserveWidgets();
    lca.renderChanges(combo);

    Message message = Fixture.getProtocolMessage();
    assertNull(message.findSetOperation(combo, "textLimit"));
  }
  public void testRenderPageIncrementUnchanged() throws IOException {
    Scale scale = new Scale(shell, SWT.NONE);
    Fixture.markInitialized(display);
    Fixture.markInitialized(scale);

    scale.setPageIncrement(20);
    Fixture.preserveWidgets();
    lca.renderChanges(scale);

    Message message = Fixture.getProtocolMessage();
    assertNull(message.findSetOperation(scale, "pageIncrement"));
  }
  public void testRenderAddSelectionListener() throws Exception {
    Scale scale = new Scale(shell, SWT.NONE);
    Fixture.markInitialized(display);
    Fixture.markInitialized(scale);
    Fixture.preserveWidgets();

    scale.addSelectionListener(new SelectionAdapter() {});
    lca.renderChanges(scale);

    Message message = Fixture.getProtocolMessage();
    assertEquals(Boolean.TRUE, message.findListenProperty(scale, "selection"));
  }
Example #29
0
  @Test
  public void testRenderMaxmumUnchanged() throws IOException {
    Fixture.markInitialized(display);
    Fixture.markInitialized(progressBar);

    progressBar.setMaximum(10);
    Fixture.preserveWidgets();
    lca.renderChanges(progressBar);

    Message message = Fixture.getProtocolMessage();
    assertNull(message.findSetOperation(progressBar, "maximum"));
  }
Example #30
0
  @Test
  public void testRenderCreateWithVerticalAndIndeterminate() throws IOException {
    progressBar = new ProgressBar(shell, SWT.VERTICAL | SWT.INDETERMINATE);

    lca.renderInitialization(progressBar);

    Message message = Fixture.getProtocolMessage();
    CreateOperation operation = message.findCreateOperation(progressBar);
    Object[] styles = operation.getStyles();
    assertTrue(Arrays.asList(styles).contains("VERTICAL"));
    assertTrue(Arrays.asList(styles).contains("INDETERMINATE"));
  }