Package tangowidget.util.listenerimpl

Examples of tangowidget.util.listenerimpl.InputListenerImpl


        initFirstDevice();
        final AttributeBooleanCombo widget = new AttributeBooleanCombo.Builder(m_deviceName,
                attributeName).jframe(jf1).build();
        Sleeper.SECONDS.sleep(4);

        final InputListenerImpl listenerSpy = new InputListenerImpl();
        widget.addInputListener(listenerSpy);

        switchComboBoxState(widget);

        // Test listener is notify only one time (per methods)
        Sleeper.SECONDS.sleep(2);
        assertThat(listenerSpy.getNotifyCount()).isEqualTo(3);
        // methods which are not notify
        assertThat(listenerSpy.isLaterNotified("actionPerformed", 1000)).isFalse();
        assertThat(listenerSpy.isNotified("stepValueChange")).isFalse();

        // methods which are notify
        assertThat((Boolean) listenerSpy.getNotification("booleanValueChange")).isFalse();
        assertThat((String) listenerSpy.getNotification("stringValueChange")).isEqualTo("false");
        assertThat((Double) listenerSpy.getNotification("numberValueChange")).isEqualTo(0.0);

        // switch state and check update is notify
        switchComboBoxState(widget);

        // methods which are not notify
        assertThat(listenerSpy.isLaterNotified("actionPerformed", 1000)).isFalse();
        assertThat(listenerSpy.isNotified("stepValueChange")).isFalse();

        assertThat((Boolean) listenerSpy.getNotification("booleanValueChange")).isTrue();
        assertThat((String) listenerSpy.getNotification("stringValueChange")).isEqualTo("true");
        assertThat((Double) listenerSpy.getNotification("numberValueChange")).isEqualTo(1.0);

        // remove lister and check is no more lotify
        widget.removeInputListener(listenerSpy);
        listenerSpy.reset();
        switchComboBoxState(widget);

        assertThat(listenerSpy.getNotifyCount()).isEqualTo(0);

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


    }

    private void controlBooleanValueChange(final JComboBox combobox,
            final AttributeBooleanCombo widget) throws DevFailed {

        final InputListenerImpl listenerTest = new InputListenerImpl();
        widget.addInputListener(listenerTest);

        assertTrue("Listener should not yet be called", listenerTest.getNotifyCount() == 0);

        final boolean newValue = switchComboBoxState(widget);
        Sleeper.SECONDS.sleep(1);

        assertTrue("InputListener has not been wake up on booleanValueChange",
                listenerTest.isLaterNotified("booleanValueChange", 5000L));
        final Object booleanNotification = listenerTest.getNotification("booleanValueChange");
        final boolean currentValueTest = (booleanNotification instanceof Boolean) ? ((Boolean) booleanNotification)
                .booleanValue() : !newValue;

        assertTrue("Value received in InputListener.booleanValueChange is not the good one",
                currentValueTest == newValue);

        Sleeper.SECONDS.sleep(2);
        assertTrue("Listener should be called 2 times", listenerTest.getNotifyCount() == 3);
        assertTrue("booleanValueChange method should be called",
                listenerTest.getNotification("booleanValueChange").equals(newValue));
        assertTrue("booleanValueChange method should be called",
                listenerTest.getNotification("booleanValueChange").equals(newValue));

        // check if the listener is correctly removed
        widget.removeInputListener(listenerTest);
        listenerTest.reset();

        switchComboBoxState(widget);

        assertFalse("InputListener has not been correctly removed",
                listenerTest.isLaterNotified("booleanValueChange", 5000L));
    }
View Full Code Here

    final AttributeBooleanCheckBoxCometeV2 widget = new AttributeBooleanCheckBoxCometeV2.Builder(
        m_deviceName, attribute).jframe(jf1).build();
    Sleeper.SECONDS.sleep(3);

    final InputListenerImpl listenerTest = new InputListenerImpl();
    widget.addInputListener(listenerTest);

    assertTrue("Listener should not yet be called",
        listenerTest.getNotifyCount() == 0);

    tth.click(widget);
    Sleeper.SECONDS.sleep(1);

    assertTrue("Listener should be called 3 times",
        listenerTest.getNotifyCount() == 3);
    assertTrue("stringValueChange method shoud be called", listenerTest
        .getNotification("stringValueChange").equals("true"));
    assertTrue("numberValueChange method should be called", listenerTest
        .getNotification("numberValueChange").equals(new Double(1.0)));
    assertTrue("booleanValueChange method should be called", listenerTest
        .getNotification("booleanValueChange").equals(true));

    widget.removeInputListener(listenerTest);
    listenerTest.reset();

    Sleeper.SECONDS.sleep(1);

    assertTrue("Listener should not be called",
        listenerTest.getNotifyCount() == 0);

    // clear
    widget.stop();
    jf1.remove(widget);
    jf1.dispose();
View Full Code Here

        assertTrue("Write failed", waitAttributeValue(devProx, attName, value, 2000));
    }

    private void controlStringValueChange(final JTextField jtf, final StringScalarPanel widget,
            final String value) throws DevFailed {
        final InputListenerImpl listenerTest = new InputListenerImpl();
        widget.addInputListener(listenerTest);

        writeInTextField(jtf, value);

        assertTrue("InputListener has not been wake up on stringValueChange",
                listenerTest.isLaterNotified("stringValueChange", 5000L));
        assertTrue("Value received in InputListener.stringValueChange is not the good one",
                value.equals(listenerTest.getNotification("stringValueChange")));

        // v�rifier que le remove du listener est correctement trait�
        widget.removeInputListener(listenerTest);
        listenerTest.reset();

        writeInTextField(jtf, value + value);

        assertFalse("InputListener has not been correctly removed",
                listenerTest.isLaterNotified("stringValueChange", 5000L));
    }
View Full Code Here

    final AttributeBooleanCheckBox widget = new AttributeBooleanCheckBox.Builder(
        m_deviceName, attribute).jframe(jf1).build();
    Sleeper.SECONDS.sleep(3);

    final InputListenerImpl listenerTest = new InputListenerImpl();
    widget.addInputListener(listenerTest);

    Assert.assertTrue("Listener should not yet be called",
        listenerTest.getNotifyCount() == 0);

    tth.click(widget);
    Sleeper.SECONDS.sleep(1);

    Assert.assertTrue("Listener should be called 3 times",
        listenerTest.getNotifyCount() == 3);
    Assert.assertTrue("stringValueChange method shoud be called",
        listenerTest.getNotification("stringValueChange")
            .equals("true"));
    Assert.assertTrue(
        "numberValueChange method should be called",
        listenerTest.getNotification("numberValueChange").equals(
            new Double(1.0)));
    Assert.assertTrue("booleanValueChange method should be called",
        listenerTest.getNotification("booleanValueChange").equals(true));

    widget.removeInputListener(listenerTest);
    listenerTest.reset();

    Sleeper.SECONDS.sleep(1);

    Assert.assertTrue("Listener should not be called",
        listenerTest.getNotifyCount() == 0);

    // clear
    widget.stop();
    jf1.remove(widget);
    jf1.dispose();
View Full Code Here

        final AttributeBooleanCheckBoxCometeV2 widget = new AttributeBooleanCheckBoxCometeV2.Builder(
                m_deviceName, attribute).jframe(jf1).build();
        Sleeper.SECONDS.sleep(3);

        final InputListenerImpl listenerTest = new InputListenerImpl();
        widget.addInputListener(listenerTest);

        assertTrue("Listener should not yet be called", listenerTest.getNotifyCount() == 0);

        tth.click(widget);
        Sleeper.SECONDS.sleep(1);

        assertTrue("Listener should be called 3 times", listenerTest.getNotifyCount() == 3);
        assertTrue("stringValueChange method shoud be called",
                listenerTest.getNotification("stringValueChange").equals("true"));
        assertTrue("numberValueChange method should be called",
                listenerTest.getNotification("numberValueChange").equals(new Double(1.0)));
        assertTrue("booleanValueChange method should be called",
                listenerTest.getNotification("booleanValueChange").equals(true));

        widget.removeInputListener(listenerTest);
        listenerTest.reset();

        Sleeper.SECONDS.sleep(1);

        assertTrue("Listener should not be called", listenerTest.getNotifyCount() == 0);

        // clear
        widget.stop();
        jf1.remove(widget);
        jf1.dispose();
View Full Code Here

    return widget.isEnabled();
  }

  protected void controlStringAndNumberValueChange(
      final CommandDeviceCombo widget, final int index) throws DevFailed {
    final InputListenerImpl listenerTest = new InputListenerImpl();
    widget.addInputListener(listenerTest);

    tth.enterIndexForCombo(widget, index);

    Assert.assertTrue(listenerTest.isLaterNotified("stringValueChange",
        5000L));
    Assert.assertTrue(getSelectedCommandText(widget).equals(
        listenerTest.getNotification("stringValueChange")));

    Assert.assertTrue(listenerTest.isLaterNotified("numberValueChange", 0));
    Assert.assertTrue(new Double(index).equals(listenerTest
        .getNotification("numberValueChange")));

    // check listener is correctly remove
    widget.removeInputListener(listenerTest);
    listenerTest.reset();

    tth.enterIndexForCombo(widget, index);

    Assert.assertFalse(listenerTest.isLaterNotified("stringValueChange",
        5000L));
  }
View Full Code Here

        "setBoolean_scalar_rwFalse" };
    final CommandDeviceCombo widget = new CommandDeviceCombo.Builder(
        m_deviceName).commands(commandList).jframe(jf).build();
    Sleeper.SECONDS.sleep(4);

    final InputListenerImpl listenerTest = new InputListenerImpl();
    widget.addInputListener(listenerTest);

    Assert.assertTrue("Listener should not yet be called",
        listenerTest.getNotifyCount() == 0);

    tth.enterIndexForCombo(widget, 1);
    Sleeper.SECONDS.sleep(2);

    Assert.assertTrue("Listener should be called 2 times",
        listenerTest.getNotifyCount() == 2);
    Assert.assertTrue(
        "stringValueChange method shoud be called",
        listenerTest.getNotification("stringValueChange").equals(
            "setBoolean_scalar_rwFalse"));
    Assert.assertTrue(
        "numberValueChange method should be called",
        listenerTest.getNotification("numberValueChange").equals(
            new Double(1.0)));

    widget.removeInputListener(listenerTest);
    listenerTest.reset();

    tth.enterIndexForCombo(widget, 0);
    Sleeper.SECONDS.sleep(1);

    Assert.assertTrue("Listener should not be called",
        listenerTest.getNotifyCount() == 0);

    // clear
    widget.stop();
    jf.remove(widget);
    jf.dispose();
View Full Code Here

  }

  private void controlStringValueChange(final JTextField jtf,
      final StringScalarPanel widget, final String value)
      throws DevFailed {
    final InputListenerImpl listenerTest = new InputListenerImpl();
    widget.addInputListener(listenerTest);

    writeInTextField(jtf, value);

    assertTrue("InputListener has not been wake up on stringValueChange",
        listenerTest.isLaterNotified("stringValueChange", 5000L));
    assertTrue(
        "Value received in InputListener.stringValueChange is not the good one",
        value.equals(listenerTest.getNotification("stringValueChange")));

    // v�rifier que le remove du listener est correctement trait�
    widget.removeInputListener(listenerTest);
    listenerTest.reset();

    writeInTextField(jtf, value + value);

    assertFalse("InputListener has not been correctly removed",
        listenerTest.isLaterNotified("stringValueChange", 5000L));
  }
View Full Code Here

    return widget.isEnabled();
  }

  protected void controlStringAndNumberValueChange(final CommandCombo widget,
      final int index) throws DevFailed {
    final InputListenerImpl listenerTest = new InputListenerImpl();
    widget.addInputListener(listenerTest);

    tth.enterIndexForCombo(widget, index);

    Assert.assertTrue(listenerTest.isLaterNotified("stringValueChange",
        5000L));
    Assert.assertTrue(getSelectedCommandText(widget).equals(
        listenerTest.getNotification("stringValueChange")));

    Assert.assertTrue(listenerTest.isLaterNotified("numberValueChange", 0));
    Assert.assertTrue(new Double(index).equals(listenerTest
        .getNotification("numberValueChange")));

    // check listener is correctly remove
    widget.removeInputListener(listenerTest);
    listenerTest.reset();

    tth.enterIndexForCombo(widget, index);

    Assert.assertFalse(listenerTest.isLaterNotified("stringValueChange",
        5000L));
  }
View Full Code Here

TOP

Related Classes of tangowidget.util.listenerimpl.InputListenerImpl

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.