コード例 #1
0
  @Test
  public void testMessageWithMixedOperations() {
    Button button = new Button(shell, SWT.PUSH);
    addShellCreate(shell);
    addShellListeners(shell);
    addButtonCreate(button);
    addButtonCall(button);
    String buttonId = WidgetUtil.getId(button);

    Message message = getMessage();
    assertEquals(4, message.getOperationCount());

    CreateOperation shellCreateOperation = (CreateOperation) message.getOperation(0);
    assertEquals(shellId, shellCreateOperation.getTarget());
    assertEquals(2, shellCreateOperation.getPropertyNames().size());

    ListenOperation shellListenOperation = (ListenOperation) message.getOperation(1);
    assertEquals(shellId, shellListenOperation.getTarget());
    assertEquals(2, shellListenOperation.getPropertyNames().size());

    CreateOperation buttonCreateOperation = (CreateOperation) message.getOperation(2);
    assertEquals(buttonId, buttonCreateOperation.getTarget());
    assertEquals(3, buttonCreateOperation.getPropertyNames().size());

    CallOperation buttonCallOperation = (CallOperation) message.getOperation(3);
    assertEquals(buttonId, buttonCallOperation.getTarget());
    assertEquals(1, buttonCallOperation.getPropertyNames().size());
  }
コード例 #2
0
  @Test
  public void testMessageWithListen() {
    Button button = new Button(shell, SWT.PUSH);
    String buttonId = WidgetUtil.getId(button);

    writer.appendListen(buttonId, "selection", false);
    writer.appendListen(buttonId, "focus", true);
    writer.appendListen(buttonId, "fake", true);

    ListenOperation operation = (ListenOperation) getMessage().getOperation(0);
    assertEquals(buttonId, operation.getTarget());
    assertFalse(operation.listensTo("selection"));
    assertTrue(operation.listensTo("focus"));
    assertTrue(operation.listensTo("fake"));
  }