Exemplo n.º 1
0
  @Test
  public void testRenderInitialScrollBarsVisible() throws IOException {
    lca.render(sc);

    TestMessage message = Fixture.getProtocolMessage();
    assertNull(message.findSetOperation(hScroll, "visibility"));
    assertNull(message.findSetOperation(vScroll, "visibility"));
  }
Exemplo n.º 2
0
  @Test
  public void testRenderInitialization_setsOperationHandler() throws IOException {
    String id = getId(sc);
    lca.renderInitialization(sc);

    OperationHandler handler = RemoteObjectRegistry.getInstance().get(id).getHandler();
    assertTrue(handler instanceof ScrolledCompositeOperationHandler);
  }
Exemplo n.º 3
0
  @Test
  public void testRenderParent() throws IOException {
    lca.renderInitialization(sc);

    TestMessage message = Fixture.getProtocolMessage();
    CreateOperation operation = message.findCreateOperation(sc);
    assertEquals(getId(sc.getParent()), getParent(operation));
  }
Exemplo n.º 4
0
  @Test
  public void testRenderShowFocusedControl() throws IOException {
    sc.setShowFocusedControl(true);
    lca.renderChanges(sc);

    TestMessage message = Fixture.getProtocolMessage();
    assertEquals(JsonValue.TRUE, message.findSetProperty(sc, "showFocusedControl"));
  }
Exemplo n.º 5
0
  @Test
  public void testRenderInitialShowFocusedControl() throws IOException {
    lca.render(sc);

    TestMessage message = Fixture.getProtocolMessage();
    CreateOperation operation = message.findCreateOperation(sc);
    assertFalse(operation.getProperties().names().contains("showFocusedControl"));
  }
Exemplo n.º 6
0
  @Test
  public void testRenderScrollBarsVisible_Vertical() throws IOException {
    vScroll.setVisible(true);
    lca.renderChanges(sc);

    TestMessage message = Fixture.getProtocolMessage();
    assertNull(message.findSetOperation(hScroll, "visibility"));
    assertEquals(JsonValue.TRUE, message.findSetProperty(vScroll, "visibility"));
  }
Exemplo n.º 7
0
  @Test
  public void testReadData_usesOperationHandler() {
    ScrolledCompositeOperationHandler handler = spy(new ScrolledCompositeOperationHandler(sc));
    getRemoteObject(getId(sc)).setHandler(handler);

    Fixture.fakeNotifyOperation(getId(sc), "Help", new JsonObject());
    lca.readData(sc);

    verify(handler).handleNotifyHelp(sc, new JsonObject());
  }
Exemplo n.º 8
0
  @Test
  public void testRenderInitialOrigin() throws IOException {
    Composite content = new Composite(sc, SWT.NONE);
    sc.setContent(content);

    lca.render(sc);

    TestMessage message = Fixture.getProtocolMessage();
    assertNull(message.findSetOperation(hScroll, "selection"));
    assertNull(message.findSetOperation(vScroll, "selection"));
  }
Exemplo n.º 9
0
  @Test
  public void testRenderContent() throws IOException {
    Composite content = new Composite(sc, SWT.NONE);
    String contentId = WidgetUtil.getId(content);

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

    TestMessage message = Fixture.getProtocolMessage();
    assertEquals(contentId, message.findSetProperty(sc, "content").asString());
  }
Exemplo n.º 10
0
  @Test
  public void testRenderCreate() throws IOException {
    lca.renderInitialization(sc);

    TestMessage message = Fixture.getProtocolMessage();
    CreateOperation operation = message.findCreateOperation(sc);
    assertEquals("rwt.widgets.ScrolledComposite", operation.getType());
    List<String> styles = getStyles(operation);
    assertTrue(styles.contains("H_SCROLL"));
    assertTrue(styles.contains("V_SCROLL"));
  }
Exemplo n.º 11
0
  @Test
  public void testRenderOrigin() throws IOException {
    Composite content = new Composite(sc, SWT.NONE);
    sc.setContent(content);

    sc.setOrigin(1, 2);
    lca.renderChanges(sc);

    TestMessage message = Fixture.getProtocolMessage();
    JsonArray expected = JsonArray.readFrom("[ 1, 2 ]");
    assertEquals(expected, message.findSetProperty(sc, "origin"));
  }
Exemplo n.º 12
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.º 13
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.º 14
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.º 15
0
  @Test
  public void testRenderScrollBarsSelectionListenerUnchanged_Vertical() throws Exception {
    Fixture.markInitialized(display);
    Fixture.markInitialized(sc);
    Fixture.markInitialized(vScroll);
    Fixture.preserveWidgets();

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

    TestMessage message = Fixture.getProtocolMessage();
    assertNull(message.findListenOperation(vScroll, "Selection"));
  }
Exemplo n.º 16
0
  @Test
  public void testRenderRemoveScrollBarsSelectionListener_Horizontal() throws Exception {
    SelectionListener listener = new SelectionAdapter() {};
    hScroll.addSelectionListener(listener);
    Fixture.markInitialized(display);
    Fixture.markInitialized(sc);
    Fixture.markInitialized(hScroll);
    Fixture.preserveWidgets();

    hScroll.removeSelectionListener(listener);
    lca.renderChanges(sc);

    TestMessage message = Fixture.getProtocolMessage();
    assertEquals(JsonValue.FALSE, message.findListenProperty(hScroll, "Selection"));
  }
Exemplo n.º 17
0
  @Test
  public void testRenderScrollBarsVisibleUnchanged() throws IOException {
    Fixture.markInitialized(display);
    Fixture.markInitialized(sc);
    Fixture.markInitialized(hScroll);
    Fixture.markInitialized(vScroll);

    hScroll.setVisible(false);
    vScroll.setVisible(false);
    Fixture.preserveWidgets();
    lca.renderChanges(sc);

    TestMessage message = Fixture.getProtocolMessage();
    assertNull(message.findSetOperation(hScroll, "visibility"));
    assertNull(message.findSetOperation(vScroll, "visibility"));
  }