예제 #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));
  }
예제 #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"));
  }
예제 #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());
  }
예제 #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());
  }
예제 #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());
  }
예제 #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"));
  }
예제 #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);
  }
예제 #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());
  }
예제 #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"));
  }
예제 #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);
  }
예제 #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"));
  }
예제 #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());
  }
예제 #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"));
  }
예제 #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"));
  }
예제 #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"));
  }
예제 #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"));
  }
예제 #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));
  }
예제 #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));
  }
예제 #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"));
  }
예제 #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"));
  }
예제 #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"));
  }
예제 #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"));
  }