Examples of InputListenerImpl


Examples of tangowidget.util.listenerimpl.InputListenerImpl

    initDevice();
    final CommandCombo widget = new CommandCombo.Builder(commands)
        .backgroundColor(Color.RED).jframe(jf).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.enterIndexForCombo(widget, 1);
    Sleeper.SECONDS.sleep(1);

    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

Examples of tangowidget.util.listenerimpl.InputListenerImpl

    }

    private void controlBooleanValueChange(final JComboBox combobox,
            final AttributeBooleanCombo widget) throws DevFailed {
      
        final InputListenerImpl listenerTest = new InputListenerImpl();
        widget.addInputListener(listenerTest);

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

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

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

        Assert.assertTrue("Listener should be called 2 times", listenerTest.getNotifyCount() == 3);
        Assert.assertTrue("booleanValueChange method should be called", listenerTest
                .getNotification("booleanValueChange").equals(newValue));
        Assert.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

Examples of tangowidget.util.listenerimpl.InputListenerImpl

  protected void controlStringAndNumberValueChange(
      final CommandDeviceComboCometeV2 widget, final int index)
      throws DevFailed {

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

    final JComboBox comboBox = (JComboBox) tth.findFirstComponent(
        JComboBox.class, widget);
    tth.enterIndexForCombo(comboBox, index);

    assertTrue(listenerTest.isLaterNotified("stringValueChange", 5000L));
    assertTrue(comboBox.getSelectedItem().toString()
        .equals(listenerTest.getNotification("stringValueChange")));
    // check listener is notify only one time.
    Sleeper.SECONDS.sleep(2);
    assertThat(listenerTest.getNotifyCount()).isEqualTo(1);

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

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

    tth.enterIndexForCombo(comboBox, index);

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

Examples of tangowidget.util.listenerimpl.InputListenerImpl

    Sleeper.SECONDS.sleep(4);

    final JComboBox comboBox = (JComboBox) tth.findFirstComponent(
        JComboBox.class, jf1);

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

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

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

    // FIXME : Listener called 4 times instead of 2
    // assertEquals("Listener should be called 2 times", 2,
    // listenerTest.getNotifyCount());

    assertEquals("stringValueChange method shoud be called",
        "increment_double_scalar_rwAlarm",
        listenerTest.getNotification("stringValueChange"));

    assertEquals("numberValueChange method should be called", 1.0,
        listenerTest.getNotification("numberValueChange"));

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

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

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

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

Examples of tangowidget.util.listenerimpl.InputListenerImpl

        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

Examples of tangowidget.util.listenerimpl.InputListenerImpl

          new String[] { "setBoolean_scalar_rwTrue","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

Examples of tangowidget.util.listenerimpl.InputListenerImpl

  protected boolean isEnable(final CommandCombo widget) {
    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

Examples of tangowidget.util.listenerimpl.InputListenerImpl

    initFirstDevice();
    final AttributeBooleanComboCometeV2 widget = new AttributeBooleanComboCometeV2.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(6);
    // 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(1.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(0.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

Examples of tangowidget.util.listenerimpl.InputListenerImpl

    final JFrame jf = new JFrame();
    initDevice();
    final CommandCombo widget = new CommandCombo.Builder(commands).backgroundColor(Color.RED).jframe(jf).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.enterIndexForCombo(widget,1);
    Sleeper.SECONDS.sleep(1);

    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

Examples of tangowidget.util.listenerimpl.InputListenerImpl

  }

  private void controlBooleanValueChange(final JComboBox combobox,
      final AttributeBooleanComboCometeV2 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 6 times instead of "
        + listenerTest.getNotifyCount() + " time(s)",
        listenerTest.getNotifyCount() == 6);
    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
TOP
Copyright © 2018 www.massapi.com. 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.