Exemplo n.º 1
0
  @Test
  public void testRenderSelectionListenerUnchanged() throws Exception {
    Fixture.markInitialized(display);
    Fixture.markInitialized(combo);
    Fixture.preserveWidgets();

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

    Message message = Fixture.getProtocolMessage();
    assertNull(message.findListenOperation(combo, "selection"));
  }
  public void testRenderSelectionListenerUnchanged() throws Exception {
    Scale scale = new Scale(shell, SWT.NONE);
    Fixture.markInitialized(display);
    Fixture.markInitialized(scale);
    Fixture.preserveWidgets();

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

    Message message = Fixture.getProtocolMessage();
    assertNull(message.findListenOperation(scale, "selection"));
  }
Exemplo n.º 3
0
 @Test
 public void testEditablePreserveValues() {
   Fixture.markInitialized(display);
   Fixture.preserveWidgets();
   WidgetAdapter adapter = WidgetUtil.getAdapter(combo);
   assertEquals(Boolean.TRUE, adapter.getPreserved(ComboLCA.PROP_EDITABLE));
   Fixture.clearPreserved();
   // textLimit
   combo.setTextLimit(10);
   Fixture.preserveWidgets();
   Integer textLimit = (Integer) adapter.getPreserved(ComboLCA.PROP_TEXT_LIMIT);
   assertEquals(new Integer(10), textLimit);
 }
Exemplo n.º 4
0
 @Test
 public void testPreserveValues() {
   Fixture.preserveWidgets();
   WidgetAdapter adapter = WidgetUtil.getAdapter(progressBar);
   Object preserved = adapter.getPreserved(ProgressBarLCA.PROP_STATE);
   assertNull(preserved);
 }
Exemplo n.º 5
0
  @Test
  public void testRenderVerifyListenerUnchanged() throws Exception {
    Fixture.markInitialized(display);
    Fixture.markInitialized(combo);
    Fixture.preserveWidgets();

    combo.addVerifyListener(
        new VerifyListener() {
          public void verifyText(VerifyEvent event) {}
        });
    Fixture.preserveWidgets();
    lca.renderChanges(combo);

    Message message = Fixture.getProtocolMessage();
    assertNull(message.findListenOperation(combo, "verify"));
  }
 private void testPreserveControlProperties(Scale scale) {
   // bound
   Rectangle rectangle = new Rectangle(10, 10, 10, 10);
   scale.setBounds(rectangle);
   Fixture.preserveWidgets();
   IWidgetAdapter adapter = WidgetUtil.getAdapter(scale);
   assertEquals(rectangle, adapter.getPreserved(Props.BOUNDS));
   Fixture.clearPreserved();
   // enabled
   Fixture.preserveWidgets();
   adapter = WidgetUtil.getAdapter(scale);
   assertEquals(Boolean.TRUE, adapter.getPreserved(Props.ENABLED));
   Fixture.clearPreserved();
   scale.setEnabled(false);
   Fixture.preserveWidgets();
   adapter = WidgetUtil.getAdapter(scale);
   assertEquals(Boolean.FALSE, adapter.getPreserved(Props.ENABLED));
   Fixture.clearPreserved();
   scale.setEnabled(true);
   // visible
   Fixture.preserveWidgets();
   adapter = WidgetUtil.getAdapter(scale);
   assertEquals(Boolean.TRUE, adapter.getPreserved(Props.VISIBLE));
   Fixture.clearPreserved();
   scale.setVisible(false);
   Fixture.preserveWidgets();
   adapter = WidgetUtil.getAdapter(scale);
   assertEquals(Boolean.FALSE, adapter.getPreserved(Props.VISIBLE));
   Fixture.clearPreserved();
   // menu
   Fixture.preserveWidgets();
   adapter = WidgetUtil.getAdapter(scale);
   assertEquals(null, adapter.getPreserved(Props.MENU));
   Fixture.clearPreserved();
   Menu menu = new Menu(scale);
   MenuItem item = new MenuItem(menu, SWT.NONE);
   item.setText("1 Item");
   scale.setMenu(menu);
   Fixture.preserveWidgets();
   adapter = WidgetUtil.getAdapter(scale);
   assertEquals(menu, adapter.getPreserved(Props.MENU));
   Fixture.clearPreserved();
   // foreground background font
   Color background = Graphics.getColor(122, 33, 203);
   scale.setBackground(background);
   Color foreground = Graphics.getColor(211, 178, 211);
   scale.setForeground(foreground);
   Font font = Graphics.getFont("font", 12, SWT.BOLD);
   scale.setFont(font);
   Fixture.preserveWidgets();
   adapter = WidgetUtil.getAdapter(scale);
   assertEquals(background, adapter.getPreserved(Props.BACKGROUND));
   assertEquals(foreground, adapter.getPreserved(Props.FOREGROUND));
   assertEquals(font, adapter.getPreserved(Props.FONT));
   Fixture.clearPreserved();
 }
Exemplo n.º 7
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.º 8
0
  @Test
  public void testRenderItemsUnchanged() throws IOException {
    Fixture.markInitialized(display);
    Fixture.markInitialized(combo);

    combo.setItems(new String[] {"a", "b", "c"});
    Fixture.preserveWidgets();
    lca.renderChanges(combo);

    Message message = Fixture.getProtocolMessage();
    assertNull(message.findSetOperation(combo, "items"));
  }
  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.º 10
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.º 11
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.º 12
0
  @Test
  public void testRenderItemHeightUnchanged() throws IOException {
    Fixture.markInitialized(display);
    Fixture.markInitialized(combo);

    combo.setFont(new Font(display, "Arial", 16, SWT.NONE));
    Fixture.preserveWidgets();
    lca.renderChanges(combo);

    Message message = Fixture.getProtocolMessage();
    assertNull(message.findSetOperation(combo, "itemHeight"));
  }
Exemplo n.º 13
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.º 14
0
  @Test
  public void testRenderListVisibleUnchanged() throws IOException {
    Fixture.markInitialized(display);
    Fixture.markInitialized(combo);

    combo.setListVisible(true);
    Fixture.preserveWidgets();
    lca.renderChanges(combo);

    Message message = Fixture.getProtocolMessage();
    assertNull(message.findSetOperation(combo, "listVisible"));
  }
Exemplo n.º 15
0
  @Test
  public void testListenDefaultSelection() throws Exception {
    Fixture.markInitialized(display);
    Fixture.markInitialized(combo);
    Fixture.preserveWidgets();

    combo.addListener(SWT.DefaultSelection, mock(Listener.class));
    lca.renderChanges(combo);

    Message message = Fixture.getProtocolMessage();
    assertNull(message.findListenOperation(combo, "Selection"));
    assertEquals(Boolean.TRUE, message.findListenProperty(combo, "DefaultSelection"));
  }
Exemplo n.º 16
0
  @Test
  public void testRenderTextLimitResetWithNegative() throws IOException {
    Fixture.markInitialized(display);
    Fixture.markInitialized(combo);

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

    Message message = Fixture.getProtocolMessage();
    assertEquals(JSONObject.NULL, message.findSetProperty(combo, "textLimit"));
  }
Exemplo n.º 17
0
  @Test
  public void testRenderSelectionUnchanged() throws IOException {
    combo.setText("foo bar");
    Fixture.markInitialized(display);
    Fixture.markInitialized(combo);

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

    Message message = Fixture.getProtocolMessage();
    assertNull(message.findSetOperation(combo, "selection"));
  }
Exemplo n.º 18
0
  @Test
  public void testRemoveListenSelection() throws Exception {
    Fixture.markInitialized(display);
    Fixture.markInitialized(combo);
    Listener listener = mock(Listener.class);
    combo.addListener(SWT.Selection, listener);
    Fixture.preserveWidgets();

    combo.removeListener(SWT.Selection, listener);
    lca.renderChanges(combo);

    Message message = Fixture.getProtocolMessage();
    assertEquals(Boolean.FALSE, message.findListenProperty(combo, "Selection"));
  }
Exemplo n.º 19
0
  @Test
  public void testRenderAddVerifyListener() throws Exception {
    Fixture.markInitialized(display);
    Fixture.markInitialized(combo);
    Fixture.preserveWidgets();

    combo.addVerifyListener(
        new VerifyListener() {
          public void verifyText(VerifyEvent event) {}
        });
    lca.renderChanges(combo);

    Message message = Fixture.getProtocolMessage();
    assertEquals(Boolean.TRUE, message.findListenProperty(combo, "Modify"));
  }
Exemplo n.º 20
0
  @Test
  public void testRenderRemoveModifyListener() throws Exception {
    ModifyListener listener =
        new ModifyListener() {
          public void modifyText(ModifyEvent event) {}
        };
    combo.addModifyListener(listener);
    Fixture.markInitialized(display);
    Fixture.markInitialized(combo);
    Fixture.preserveWidgets();

    combo.removeModifyListener(listener);
    lca.renderChanges(combo);

    Message message = Fixture.getProtocolMessage();
    assertEquals(Boolean.FALSE, message.findListenProperty(combo, "Modify"));
  }
Exemplo n.º 21
0
 public void testScalePreserveValues() {
   Scale scale = new Scale(shell, SWT.HORIZONTAL);
   Fixture.markInitialized(display);
   // Test preserved minimum, maximum,
   // selection, increment and ageIncrement
   Fixture.preserveWidgets();
   IWidgetAdapter adapter = WidgetUtil.getAdapter(scale);
   Integer minimum = (Integer) adapter.getPreserved(ScaleLCA.PROP_MINIMUM);
   assertEquals(0, minimum.intValue());
   Integer maximum = (Integer) adapter.getPreserved(ScaleLCA.PROP_MAXIMUM);
   assertEquals(100, maximum.intValue());
   Integer selection = (Integer) adapter.getPreserved(ScaleLCA.PROP_SELECTION);
   assertEquals(0, selection.intValue());
   Integer increment = (Integer) adapter.getPreserved(ScaleLCA.PROP_INCREMENT);
   assertEquals(1, increment.intValue());
   Integer pageIncrement = (Integer) adapter.getPreserved(ScaleLCA.PROP_PAGE_INCREMENT);
   assertEquals(10, pageIncrement.intValue());
   Fixture.clearPreserved();
   // Test preserved control properties
   testPreserveControlProperties(scale);
 }
Exemplo n.º 22
0
 @Test
 public void testPreserveValues() {
   Combo combo = new Combo(shell, SWT.READ_ONLY);
   Fixture.markInitialized(display);
   // Test preserving a combo with no items and (naturally) no selection
   Fixture.preserveWidgets();
   WidgetAdapter adapter = WidgetUtil.getAdapter(combo);
   String[] items = ((String[]) adapter.getPreserved(PROP_ITEMS));
   assertEquals(0, items.length);
   assertEquals(new Integer(-1), adapter.getPreserved(PROP_SELECTION_INDEX));
   assertNull(adapter.getPreserved(ComboLCA.PROP_TEXT_LIMIT));
   Object visibleItemCount = adapter.getPreserved(ComboLCA.PROP_VISIBLE_ITEM_COUNT);
   assertEquals(new Integer(combo.getVisibleItemCount()), visibleItemCount);
   assertEquals(Boolean.FALSE, adapter.getPreserved(ComboLCA.PROP_EDITABLE));
   assertEquals(new Point(0, 0), adapter.getPreserved(ComboLCA.PROP_SELECTION));
   // Test preserving combo with items were one is selected
   Fixture.clearPreserved();
   combo.add("item 1");
   combo.add("item 2");
   combo.select(1);
   combo.setListVisible(true);
   SelectionListener selectionListener = new SelectionAdapter() {};
   combo.addSelectionListener(selectionListener);
   combo.addModifyListener(
       new ModifyListener() {
         public void modifyText(ModifyEvent event) {}
       });
   Fixture.preserveWidgets();
   adapter = WidgetUtil.getAdapter(combo);
   items = ((String[]) adapter.getPreserved(PROP_ITEMS));
   assertEquals(2, items.length);
   assertEquals("item 1", items[0]);
   assertEquals("item 2", items[1]);
   assertEquals(new Integer(1), adapter.getPreserved(PROP_SELECTION_INDEX));
   visibleItemCount = adapter.getPreserved(ComboLCA.PROP_VISIBLE_ITEM_COUNT);
   assertEquals(new Integer(combo.getVisibleItemCount()), visibleItemCount);
   assertEquals("item 2", adapter.getPreserved(Props.TEXT));
   assertEquals(Boolean.FALSE, adapter.getPreserved(ComboLCA.PROP_EDITABLE));
   Fixture.clearPreserved();
   // foreground background font
   Color background = new Color(display, 122, 33, 203);
   combo.setBackground(background);
   Color foreground = new Color(display, 211, 178, 211);
   combo.setForeground(foreground);
   Font font = new Font(display, "font", 12, SWT.BOLD);
   combo.setFont(font);
   Fixture.preserveWidgets();
   adapter = WidgetUtil.getAdapter(combo);
   assertEquals(background, adapter.getPreserved(Props.BACKGROUND));
   assertEquals(foreground, adapter.getPreserved(Props.FOREGROUND));
   assertEquals(font, adapter.getPreserved(Props.FONT));
   Fixture.clearPreserved();
   // tooltiptext
   Fixture.preserveWidgets();
   adapter = WidgetUtil.getAdapter(combo);
   assertEquals(null, combo.getToolTipText());
   Fixture.clearPreserved();
   combo.setToolTipText("some text");
   Fixture.preserveWidgets();
   adapter = WidgetUtil.getAdapter(combo);
   assertEquals("some text", combo.getToolTipText());
   Fixture.clearPreserved();
 }