Package fr.soleil.globalscreen.tangowidget.attribute

Examples of fr.soleil.globalscreen.tangowidget.attribute.AttributeNumberScalarWheelSwitch$Builder


    jf1 = new JFrame();

    final String attributeName = "double_scalar_rw_with_format";
    // Initialiser le device et le composant
    initFirstDevice();
    final AttributeNumberScalarWheelSwitch widget = new AttributeNumberScalarWheelSwitch.Builder(
        m_deviceName, attributeName).jframe(jf1).build();

    Sleeper.SECONDS.sleep(2);

    final JLabel label = getLabel(jf1);
    assertTrue(label != null);

    final List<ArrowButton> upButtons = new ArrayList<ArrowButton>();
    final List<ArrowButton> downButtons = new ArrayList<ArrowButton>();

    widget.setUserEnabled(false);
    Sleeper.SECONDS.sleep(1);
    getButtons(jf1, upButtons, downButtons);

    for (int i = 0; i < upButtons.size(); i++) {
      assertFalse("Button shouldn't be enable", upButtons.get(i)
          .isEnabled() || downButtons.get(i).isEnabled());
    }

    widget.setUserEnabled(true);
    Sleeper.SECONDS.sleep(1);
    getButtons(jf1, upButtons, downButtons);
    System.out.println("" + upButtons.size() + " " + downButtons.size());

    assertTrue((upButtons.size() == 8) & (downButtons.size() == 8));

    // v�rifier que la valeur courante de l'attribut est bien affich�e
    double value = 1234.567;
    m_deviceProxy
        .write_attribute(new DeviceAttribute(attributeName, value));
    String format = "%7.3f";
    assertTrue(waitLabelText(label, formatValue(value, format), 5000));

    tth.click(upButtons.get(7));
    value = 1234.568;
    assertTrue(waitAttributeValue(m_deviceProxy, attributeName, value, 5000));

    tth.click(downButtons.get(6));
    value = 1234.558;
    assertTrue(waitAttributeValue(m_deviceProxy, attributeName, value, 5000));

    tth.click(upButtons.get(5));
    value = 1234.658;
    assertTrue(waitAttributeValue(m_deviceProxy, attributeName, value, 5000));

    tth.click(downButtons.get(4));
    value = 1233.658;
    assertTrue(waitAttributeValue(m_deviceProxy, attributeName, value, 5000));

    // v�rifier les boutons de signe
    tth.click(upButtons.get(0));
    value = -1233.658;
    assertTrue(waitAttributeValue(m_deviceProxy, attributeName, value, 5000));
    tth.click(downButtons.get(0));
    value = 1233.658;
    assertTrue(waitAttributeValue(m_deviceProxy, attributeName, value, 5000));

    // v�rifier que le nombre de boutons s'adapte en cas de d�passement du
    // format
    value = 12345.678;
    m_deviceProxy
        .write_attribute(new DeviceAttribute(attributeName, value));
    Sleeper.SECONDS.sleep(1);
    // label = getLabel(jf);
    format = "%8.3f";
    assertTrue(waitLabelText(label, formatValue(value, format), 5000));
    getButtons(jf1, upButtons, downButtons);
    assertTrue((upButtons.size() == 9) & (downButtons.size() == 9));

    // v�rifier l'entr�e des chiffres au clavier
    // tth.click(label);
    // tth.simulateInput('1');
    // tth.simulateInput('3');
    // tth.simulateInput('2');
    // tth.simulateInput('4');
    // tth.simulateInput('.');
    // tth.simulateInput('7');
    // tth.simulateInput('6');
    // tth.simulateEnter();

    final KeyListener keyListener = ((WheelSwitch) tth.findFirstComponent(
        WheelSwitch.class, widget)).getKeyListeners()[0];

    tth.click(label);
    tth.sendEventsToKeyListener(keyListener, widget, "1324.76");
    tth.sendEnterToKeyListener(keyListener, widget, true);

    // to be "sure" the confirmation dialog has the necessary time to appear
    Sleeper.SECONDS.sleep(1);

    value = 1324.76;
    assertTrue("write failed, bean has not the same value as device",
        waitAttributeValue(m_deviceProxy, attributeName, value, 5000));

    // Faire varier le nom du device
    initSecondDevice();

    value = 1111.222;
    m_deviceProxy2
        .write_attribute(new DeviceAttribute(attributeName, value));

    widget.setDeviceName(m_deviceName2);
    Sleeper.SECONDS.sleep(1);

    assertTrue(waitLabelText(label, formatValue(value, format), 5000));

    // clean
    widget.stop();
    jf1.dispose();
  }
View Full Code Here


  @Override
  protected void componentNotWritableTest() throws DevFailed {
    jf1 = new JFrame();
    initFirstDevice();

    final AttributeNumberScalarWheelSwitch widget = new AttributeNumberScalarWheelSwitch.Builder(
        m_deviceName, "double_scalar_rw_with_format").userEnable(false)
        .jframe(jf1).build();

    Sleeper.SECONDS.sleep(2);

    final List<ArrowButton> upButtons = new ArrayList<ArrowButton>();
    final List<ArrowButton> downButtons = new ArrayList<ArrowButton>();

    // test we can't edit bean
    getButtons(jf1, upButtons, downButtons);
    for (int i = 0; i < upButtons.size(); i++) {
      assertFalse("Button shouldn't be enable", upButtons.get(i)
          .isEnabled() || downButtons.get(i).isEnabled());
    }
    widget.stop();
    jf1.dispose();
  }
View Full Code Here

    final String attributeName = "double_scalar_rw_with_format";
    final String format = "%7.3f";

    // Initialiser l'attribut
    initFirstDevice();
    final AttributeNumberScalarWheelSwitch widget = new AttributeNumberScalarWheelSwitch.Builder(
        m_deviceName, attributeName).jframe(jf1).confirmation(true)
        .build();

    Sleeper.SECONDS.sleep(5);

    final JLabel label = getLabel(jf1);
    assertNotNull("can't find label", label);

    final List<ArrowButton> upButtons = new ArrayList<ArrowButton>();
    final List<ArrowButton> downButtons = new ArrayList<ArrowButton>();
    getButtons(jf1, upButtons, downButtons);
    assertTrue("invalid number of buttons", (upButtons.size() == 8)
        && (downButtons.size() == 8));

    // v�rifier que la valeur courante de l'attribut est bien affich�e
    final double value = 1234.567;
    m_deviceProxy
        .write_attribute(new DeviceAttribute(attributeName, value));
    assertTrue(waitLabelText(label, formatValue(value, format), 5000));

    // tester la comfirmation sur l'utilisation des fl�ches
    tth.click(downButtons.get(6));
    final double newValue = 1234.557;

    if (withCancel) {
      final JDialog fd = tth.findDialog("Confirmation");
      Sleeper.SECONDS.sleep(2);
      tth.rejectDialog(fd);
      assertTrue("reject confirmation failed", m_deviceProxy
          .read_attribute(attributeName).extractDouble() == value);
    } else {
      // Valider la confirmation
      validateConfirmation("");
      assertTrue(
          "write failed",
          waitAttributeValue(m_deviceProxy, attributeName, newValue,
              5000));
    }
    jf1.dispose();
    widget.stop();
  }
View Full Code Here

    final String attributeName = "double_scalar_rw_with_format";
    final String format = "%7.3f";

    // Initialiser l'attribut
    initFirstDevice();
    final AttributeNumberScalarWheelSwitch widget = new AttributeNumberScalarWheelSwitch.Builder(
        m_deviceName, attributeName).jframe(jf1).confirmation(true)
        .build();

    Sleeper.SECONDS.sleep(3);

    final JLabel label = getLabel(jf1);
    assertTrue(label != null);

    final List<ArrowButton> upButtons = new ArrayList<ArrowButton>();
    final List<ArrowButton> downButtons = new ArrayList<ArrowButton>();
    getButtons(jf1, upButtons, downButtons);
    assertTrue((upButtons.size() == 8) & (downButtons.size() == 8));

    // initialiser l'attribut
    final double value = 1111.222;
    m_deviceProxy
        .write_attribute(new DeviceAttribute(attributeName, value));
    assertTrue(waitLabelText(label, formatValue(value, format), 5000));

    final KeyListener keyListener = ((WheelSwitch) tth.findFirstComponent(
        WheelSwitch.class, widget)).getKeyListeners()[0];

    // tester la comfirmation sur l'entr�e des donn�es au clavier
    tth.click(label);

    tth.sendEventsToKeyListener(keyListener, widget, "01324.765");
    tth.sendEnterToKeyListener(keyListener, widget, true);

    // to be "sure" the confirmation dialog has the necessary time to appear
    Sleeper.SECONDS.sleep(1);

    final double newValue = 1324.765;

    if (withCancel) {
      final JDialog fd = tth.findDialog("Confirmation");

      assertNotNull(fd);
      Sleeper.SECONDS.sleep(2);
      tth.rejectDialog(fd);
      assertTrue("reject confirmation failed", m_deviceProxy
          .read_attribute(attributeName).extractDouble() == value);
    } else {
      // Valider la confirmation
      validateConfirmation("");
      assertTrue(
          "write failed",
          waitAttributeValue(m_deviceProxy, attributeName, newValue,
              5000));
    }
    jf1.dispose();
    widget.stop();
  }
View Full Code Here

  }

  private void invalidDeviceTest(final JFrame jf, final AssertErrorConf aec,
      final boolean autoStart) {

    AttributeNumberScalarWheelSwitch widget;
    for (int i = 0; i < NB_INVALID_DEVICE_CONF_TEST; i++) {

      // Widget creation
      if (autoStart) {
        widget = new AttributeNumberScalarWheelSwitch.Builder(
            m_deviceName, "double_scalar_rw").jframe(jf).build();
        Sleeper.SECONDS.sleep(2);
      } else {
        // construct a widget with userEnable = true,alarmEnable =true,
        widget = new AttributeNumberScalarWheelSwitch.Builder(
            m_deviceName, "double_scalar_rw").jframe(jf)
            .autoStart(false).build();
      }
      // Configuration test
      invalidDeviceConfigTest(widget, i, aec, !autoStart);

      // clear
      widget.stop();
      jf.remove(widget);// clear jframe

    }
  }
View Full Code Here

        jf1 = new JFrame();

        final String attributeName = "double_scalar_rw_with_format";
        // Initialiser le device et le composant
        initFirstDevice();
        final AttributeNumberScalarWheelSwitch widget = new AttributeNumberScalarWheelSwitch.Builder(
                m_deviceName, attributeName).jframe(jf1).build();

        Sleeper.SECONDS.sleep(2);

        final JLabel label = getLabel(jf1);
        Assert.assertTrue(label != null);

        final List<ArrowButton> upButtons = new ArrayList<ArrowButton>();
        final List<ArrowButton> downButtons = new ArrayList<ArrowButton>();

        widget.setUserEnabled(false);
        Sleeper.SECONDS.sleep(1);
        getButtons(jf1, upButtons, downButtons);

        for (int i = 0; i < upButtons.size(); i++) {
            Assert.assertFalse("Button shouldn't be enable", upButtons.get(i).isEnabled()
                    || downButtons.get(i).isEnabled());
        }

        widget.setUserEnabled(true);
        Sleeper.SECONDS.sleep(1);
        getButtons(jf1, upButtons, downButtons);
        System.out.println("" + upButtons.size() + " " + downButtons.size());

        Assert.assertTrue((upButtons.size() == 8) & (downButtons.size() == 8));

        // v�rifier que la valeur courante de l'attribut est bien affich�e
        double value = 1234.567;
        m_deviceProxy.write_attribute(new DeviceAttribute(attributeName, value));
        String format = "%7.3f";
        Assert.assertTrue(waitLabelText(label, formatValue(value, format), 5000));

        tth.click(upButtons.get(7));
        value = 1234.568;
        Assert.assertTrue(waitAttributeValue(m_deviceProxy, attributeName, value, 5000));

        tth.click(downButtons.get(6));
        value = 1234.558;
        Assert.assertTrue(waitAttributeValue(m_deviceProxy, attributeName, value, 5000));

        tth.click(upButtons.get(5));
        value = 1234.658;
        Assert.assertTrue(waitAttributeValue(m_deviceProxy, attributeName, value, 5000));

        tth.click(downButtons.get(4));
        value = 1233.658;
        Assert.assertTrue(waitAttributeValue(m_deviceProxy, attributeName, value, 5000));

        // v�rifier les boutons de signe
        tth.click(upButtons.get(0));
        value = -1233.658;
        Assert.assertTrue(waitAttributeValue(m_deviceProxy, attributeName, value, 5000));
        tth.click(downButtons.get(0));
        value = 1233.658;
        Assert.assertTrue(waitAttributeValue(m_deviceProxy, attributeName, value, 5000));

        // v�rifier que le nombre de boutons s'adapte en cas de d�passement du format
        value = 12345.678;
        m_deviceProxy.write_attribute(new DeviceAttribute(attributeName, value));
        Sleeper.SECONDS.sleep(1);
        // label = getLabel(jf);
        format = "%8.3f";
        Assert.assertTrue(waitLabelText(label, formatValue(value, format), 5000));
        getButtons(jf1, upButtons, downButtons);
        Assert.assertTrue((upButtons.size() == 9) & (downButtons.size() == 9));

        // v�rifier l'entr�e des chiffres au clavier
        tth.click(label);
        tth.simulateInput('1');
        tth.simulateInput('3');
        tth.simulateInput('2');
        tth.simulateInput('4');
        tth.simulateInput('.');
        tth.simulateInput('7');
        tth.simulateInput('6');
        tth.simulateEnter();

        value = 1324.76;
        Assert.assertTrue(waitAttributeValue(m_deviceProxy, attributeName, value, 5000));

        // Faire varier le nom du device
        initSecondDevice();

        value = 1111.222;
        m_deviceProxy2.write_attribute(new DeviceAttribute(attributeName, value));

        widget.setDeviceName(m_deviceName2);
        Sleeper.SECONDS.sleep(1);

        Assert.assertTrue(waitLabelText(label, formatValue(value, format), 5000));

        // clean
        widget.stop();
        jf1.dispose();
    }
View Full Code Here

    @Override
    protected void componentNotWritableTest() throws DevFailed {
        jf1 = new JFrame();
        initFirstDevice();

        final AttributeNumberScalarWheelSwitch widget = new AttributeNumberScalarWheelSwitch.Builder(
                m_deviceName, "double_scalar_rw_with_format").userEnable(false).jframe(jf1).build();

        Sleeper.SECONDS.sleep(2);

        final List<ArrowButton> upButtons = new ArrayList<ArrowButton>();
        final List<ArrowButton> downButtons = new ArrayList<ArrowButton>();

        // test we can't edit bean
        getButtons(jf1, upButtons, downButtons);
        for (int i = 0; i < upButtons.size(); i++) {
            Assert.assertFalse("Button shouldn't be enable", upButtons.get(i).isEnabled()
                    || downButtons.get(i).isEnabled());
        }
        widget.stop();
        jf1.dispose();
    }
View Full Code Here

        final String attributeName = "double_scalar_rw_with_format";
        final String format = "%7.3f";

        // Initialiser l'attribut
        initFirstDevice();
        final AttributeNumberScalarWheelSwitch widget = new AttributeNumberScalarWheelSwitch.Builder(
                m_deviceName, attributeName).jframe(jf1).confirmation(true).build();

        Sleeper.SECONDS.sleep(2);

        final JLabel label = getLabel(jf1);
        Assert.assertTrue(label != null);

        final List<ArrowButton> upButtons = new ArrayList<ArrowButton>();
        final List<ArrowButton> downButtons = new ArrayList<ArrowButton>();
        getButtons(jf1, upButtons, downButtons);
        Assert.assertTrue((upButtons.size() == 8) & (downButtons.size() == 8));

        // v�rifier que la valeur courante de l'attribut est bien affich�e
        final double value = 1234.567;
        m_deviceProxy.write_attribute(new DeviceAttribute(attributeName, value));
        Assert.assertTrue(waitLabelText(label, formatValue(value, format), 5000));

        // tester la comfirmation sur l'utilisation des fl�ches
        tth.click(downButtons.get(6));
        final double newValue = 1234.557;

        if (withCancel) {
            final JDialog fd = tth.findDialog("Confirmation");
            tth.rejectDialog(fd);
            Assert.assertTrue("reject confirmation failed",
                    m_deviceProxy.read_attribute(attributeName).extractDouble() == value);
        }
        else {
            // Valider la confirmation
            validateConfirmation("");
            Assert.assertTrue("write failed",
                    waitAttributeValue(m_deviceProxy, attributeName, newValue, 5000));
        }
        jf1.dispose();
        widget.stop();
    }
View Full Code Here

        final String attributeName = "double_scalar_rw_with_format";
        final String format = "%7.3f";

        // Initialiser l'attribut
        initFirstDevice();
        final AttributeNumberScalarWheelSwitch widget = new AttributeNumberScalarWheelSwitch.Builder(
                m_deviceName, attributeName).jframe(jf1).confirmation(true).build();

        Sleeper.SECONDS.sleep(2);

        final JLabel label = getLabel(jf1);
        Assert.assertTrue(label != null);

        final List<ArrowButton> upButtons = new ArrayList<ArrowButton>();
        final List<ArrowButton> downButtons = new ArrayList<ArrowButton>();
        getButtons(jf1, upButtons, downButtons);
        Assert.assertTrue((upButtons.size() == 8) & (downButtons.size() == 8));

        // initialiser l'attribut
        final double value = 1111.222;
        m_deviceProxy.write_attribute(new DeviceAttribute(attributeName, value));
        Assert.assertTrue(waitLabelText(label, formatValue(value, format), 5000));

        // tester la comfirmation sur l'entr�e des donn�es au clavier
        tth.click(label);
        tth.simulateInput('0');
        tth.simulateInput('1');
        tth.simulateInput('3');
        tth.simulateInput('2');
        tth.simulateInput('4');
        tth.simulateInput('.');
        tth.simulateInput('7');
        tth.simulateInput('6');
        tth.simulateInput('5');
        tth.simulateEnter();

        final double newValue = 1324.765;

        if (withCancel) {
            final JDialog fd = tth.findDialog("Confirmation");
            tth.rejectDialog(fd);
            Assert.assertTrue("reject confirmation failed",
                    m_deviceProxy.read_attribute(attributeName).extractDouble() == value);
        }
        else {
            // Valider la confirmation
            validateConfirmation("");
            Assert.assertTrue("write failed",
                    waitAttributeValue(m_deviceProxy, attributeName, newValue, 5000));
        }
        jf1.dispose();
        widget.stop();
    }
View Full Code Here

    }

    private void invalidDeviceTest(final JFrame jf, final AssertErrorConf aec,
            final boolean autoStart) {

        AttributeNumberScalarWheelSwitch widget;
        for (int i = 0; i < NB_INVALID_DEVICE_CONF_TEST; i++) {

            // Widget creation
            if (autoStart) {
                widget = new AttributeNumberScalarWheelSwitch.Builder(m_deviceName,
                        "double_scalar_rw").jframe(jf).build();
                Sleeper.SECONDS.sleep(2);
            }
            else {
                // construct a widget with userEnable = true,alarmEnable =true,
                widget = new AttributeNumberScalarWheelSwitch.Builder(m_deviceName,
                        "double_scalar_rw").jframe(jf).autoStart(false).build();
            }
            // Configuration test
            invalidDeviceConfigTest(widget, i, aec, !autoStart);

            // clear
            widget.stop();
            jf.remove(widget);// clear jframe

        }
    }
View Full Code Here

TOP

Related Classes of fr.soleil.globalscreen.tangowidget.attribute.AttributeNumberScalarWheelSwitch$Builder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.