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 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 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 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"));
  }
  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 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"));
  }
 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();
 }
 private void testSelectionEvent(final Scale scale) {
   final StringBuilder log = new StringBuilder();
   SelectionListener selectionListener =
       new SelectionAdapter() {
         public void widgetSelected(SelectionEvent event) {
           assertEquals(scale, event.getSource());
           assertEquals(null, event.item);
           assertEquals(SWT.NONE, event.detail);
           assertEquals(0, event.x);
           assertEquals(0, event.y);
           assertEquals(0, event.width);
           assertEquals(0, event.height);
           assertEquals(true, event.doit);
           log.append("widgetSelected");
         }
       };
   scale.addSelectionListener(selectionListener);
   String scaleId = WidgetUtil.getId(scale);
   Fixture.fakeRequestParam(JSConst.EVENT_WIDGET_SELECTED, scaleId);
   Fixture.readDataAndProcessAction(scale);
   assertEquals("widgetSelected", log.toString());
 }