Exemplo n.º 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));
  }
Exemplo n.º 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"));
  }
Exemplo n.º 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());
  }
Exemplo n.º 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());
  }
Exemplo n.º 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());
  }
Exemplo n.º 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"));
  }
Exemplo n.º 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);
  }
Exemplo n.º 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());
  }
Exemplo n.º 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"));
  }
Exemplo n.º 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);
  }
Exemplo n.º 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"));
  }
Exemplo n.º 12
0
  @Test
  public void testRenderText() throws IOException {
    combo.setText("foo");
    lca.renderChanges(combo);

    Message message = Fixture.getProtocolMessage();
    assertEquals("foo", message.findSetProperty(combo, "text"));
  }
Exemplo n.º 13
0
  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"));
  }
Exemplo n.º 14
0
  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"));
  }
Exemplo n.º 15
0
  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);
  }
Exemplo n.º 16
0
  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());
  }
Exemplo n.º 17
0
  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());
  }
Exemplo n.º 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"));
  }
Exemplo n.º 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"));
  }
Exemplo n.º 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"));
  }
Exemplo n.º 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"));
  }
Exemplo n.º 22
0
  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"));
  }
Exemplo n.º 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));
  }
Exemplo n.º 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));
  }
Exemplo n.º 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"));
  }
Exemplo n.º 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"));
  }
Exemplo n.º 27
0
  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"));
  }
Exemplo n.º 28
0
  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"));
  }
Exemplo n.º 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"));
  }
Exemplo n.º 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"));
  }