Package tangowidget.util.listenerimpl

Examples of tangowidget.util.listenerimpl.BooleanAttributeListenerImpl


    final NumberScalarAlarm widget = new NumberScalarAlarm.Builder(
        m_deviceName, attribute).backgroundColor(Color.RED).jframe(jf1)
        .build();
    Sleeper.SECONDS.sleep(3);

    final BooleanAttributeListenerImpl listenerTest = new BooleanAttributeListenerImpl();
    widget.addBooleanAttributeListener(listenerTest);

    deviceValue = !deviceValue;
    m_deviceProxy.write_attribute(new DeviceAttribute(attribute,
        deviceValue));

    Sleeper.SECONDS.sleep(3);

    Assert.assertTrue("Listener should be called 3 times",
        listenerTest.getNotifyCount() == 3);
    Assert.assertTrue(
        "readBooleanValueChange method should be called",
        listenerTest.getNotification("readBooleanValueChange").equals(
            deviceValue));
    Assert.assertTrue("stateChange method should be called", listenerTest
        .getNotification("stateChange").equals(deviceValue));
    Assert.assertTrue(
        "writeBooleanValueChange method should be called",
        listenerTest.getNotification("writeBooleanValueChange").equals(
            deviceValue));

    widget.removeBooleanAttributeListener(listenerTest);
    listenerTest.reset();

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

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


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

        final BooleanAttributeListenerImpl listenerSpy = new BooleanAttributeListenerImpl();
        widget.addBooleanAttributeListener(listenerSpy);

        switchComboBoxState(widget);

        // wait for notification, normaly all notification come at the same
        // time, so we wait only
        // one
        assertThat(listenerSpy.isLaterNotified("readBooleanValueChange", 3000)).isTrue();
        assertThat((Boolean) listenerSpy.getNotification("readBooleanValueChange")).isFalse();
        assertThat((Boolean) listenerSpy.getNotification("writeBooleanValueChange")).isFalse();
        assertThat((String) listenerSpy.getNotification("stateChange")).isEqualTo("VALID");
        // check listener is notify only one time.
        // FIXME listener is notify every sec even if value don't change
        // Sleeper.SECONDS.sleep(2);
        // assertThat(listenerSpy.getNotifyCount()).isEqualTo(4);

        // switch state and check update is notify
        switchComboBoxState(widget);
        // wait notification updata
        Sleeper.SECONDS.sleep(1);

        assertThat((Boolean) listenerSpy.getNotification("readBooleanValueChange")).isTrue();
        assertThat((Boolean) listenerSpy.getNotification("writeBooleanValueChange")).isTrue();
        assertThat((String) listenerSpy.getNotification("stateChange")).isEqualTo("VALID");

        // TODO change the attr quality, to change quality of boolean attr you
        // must code it in
        // device !
        // with IDL4 Java device, we need to have an dynamic attr. So this test
        // will be implemented
        // when TestGlobalScreen will be upgraded to have dynamic attr

        // check listener is no more notify if it's removed
        widget.removeBooleanAttributeListener(listenerSpy);
        listenerSpy.reset();

        switchComboBoxState(widget);

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

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

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

    private void controlReadBooleanValueChange(final DeviceProxy devProx,
            final AttributeBooleanCombo widget, final String attName) throws DevFailed {
        final BooleanAttributeListenerImpl listenerTest = new BooleanAttributeListenerImpl();
        widget.addBooleanAttributeListener(listenerTest);

        final boolean value = !getBooleanValue(widget);
        devProx.write_attribute(new DeviceAttribute(attName, value));

        assertTrue("Notification never called",
                listenerTest.isLaterNotified("readBooleanValueChange", 5000L));
        final Object booleanNotification = listenerTest.getNotification("writeBooleanValueChange");
        final boolean currentValueTest = (booleanNotification instanceof Boolean) ? ((Boolean) booleanNotification)
                .booleanValue() : !value;

        assertTrue("Notification value different from original", value == currentValueTest);

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

        devProx.write_attribute(new DeviceAttribute(attName, !value));

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

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

    final BooleanAttributeListenerImpl listenerTest = new BooleanAttributeListenerImpl();
    widget.addBooleanAttributeListener(listenerTest);

    deviceValue = !deviceValue;
    m_deviceProxy.write_attribute(new DeviceAttribute(attribute,
        deviceValue));

    Sleeper.SECONDS.sleep(3);

    // Test listener is notify only one time (per methods)
    // FIXME: when widget will be upgraded to cometeV2
    assertThat(listenerTest.getNotifyCount()).isEqualTo(3);

    assertThat(
        (Boolean) listenerTest
            .getNotification("readBooleanValueChange")).isEqualTo(
        deviceValue);
    assertThat(
        (Boolean) listenerTest
            .getNotification("writeBooleanValueChange")).isEqualTo(
        deviceValue);
    assertThat((String) listenerTest.getNotification("stateChange"))
        .isEqualTo("VALID");

    // check it's updated

    deviceValue = !deviceValue;
    m_deviceProxy.write_attribute(new DeviceAttribute(attribute,
        deviceValue));

    Sleeper.SECONDS.sleep(3);

    assertThat(
        (Boolean) listenerTest
            .getNotification("readBooleanValueChange")).isEqualTo(
        deviceValue);
    assertThat(
        (Boolean) listenerTest
            .getNotification("writeBooleanValueChange")).isEqualTo(
        deviceValue);
    assertThat((String) listenerTest.getNotification("stateChange"))
        .isEqualTo("VALID");

    widget.removeBooleanAttributeListener(listenerTest);
    listenerTest.reset();

    Sleeper.SECONDS.sleep(3);
    assertEquals("Listener should not be called", 0,
        listenerTest.getNotifyCount());

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

        jf1 = new JFrame();
        final NumberScalarAlarm widget = new NumberScalarAlarm.Builder(m_deviceName, attribute)
                .backgroundColor(Color.RED).jframe(jf1).build();
        Sleeper.SECONDS.sleep(3);

        final BooleanAttributeListenerImpl listenerTest = new BooleanAttributeListenerImpl();
        widget.addBooleanAttributeListener(listenerTest);

        deviceValue = !deviceValue;
        m_deviceProxy.write_attribute(new DeviceAttribute(attribute, deviceValue));

        Sleeper.SECONDS.sleep(3);

        Assert.assertTrue("Listener should be called 3 times", listenerTest.getNotifyCount() == 3);
        Assert.assertTrue("readBooleanValueChange method should be called", listenerTest
                .getNotification("readBooleanValueChange").equals(deviceValue));
        Assert.assertTrue("stateChange method should be called",
                listenerTest.getNotification("stateChange").equals(deviceValue));
        Assert.assertTrue("writeBooleanValueChange method should be called", listenerTest
                .getNotification("writeBooleanValueChange").equals(deviceValue));

        widget.removeBooleanAttributeListener(listenerTest);
        listenerTest.reset();

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

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

    }

    private void controlReadBooleanValueChange(final DeviceProxy devProx,
            final AttributeBooleanCombo widget, final String attName)
            throws DevFailed {
        final BooleanAttributeListenerImpl listenerTest = new BooleanAttributeListenerImpl();
        widget.addBooleanAttributeListener(listenerTest);

        boolean value = !getBooleanValue(widget);
        devProx.write_attribute(new DeviceAttribute(attName, value));

        assertTrue("Notification never called",
                listenerTest.isLaterNotified("readBooleanValueChange", 5000L));
        Object booleanNotification = listenerTest.getNotification("writeBooleanValueChange");
        boolean currentValueTest = (booleanNotification instanceof Boolean) ? ((Boolean)booleanNotification).booleanValue() : !value;
       
        assertTrue("Notification value different from original",
                value == currentValueTest);

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

        devProx.write_attribute(new DeviceAttribute(attName, !value));

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

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

    final BooleanAttributeListenerImpl listenerSpy = new BooleanAttributeListenerImpl();
    widget.addBooleanAttributeListener(listenerSpy);

    switchComboBoxState(widget);

    // wait for notification, normally all notification come at the same
    // time, so we wait only
    // one
    assertThat(listenerSpy.isLaterNotified("readBooleanValueChange", 3000))
        .isTrue();
    assertThat(
        (Boolean) listenerSpy.getNotification("readBooleanValueChange"))
        .isFalse();
    assertThat(
        (Boolean) listenerSpy
            .getNotification("writeBooleanValueChange")).isFalse();
    // FIXME : listener stateChange always return 'null' instead of 'VALID'
    // assertThat((String) listenerSpy.getNotification("stateChange"))
    // .isEqualTo("VALID");
    // check listener is notify only one time.
    Sleeper.SECONDS.sleep(3);
    // FIXME Listener notify 4 times in ATK Test (but bugged)
    assertThat(listenerSpy.getNotifyCount()).isEqualTo(2);

    // switch state and check update is notify
    switchComboBoxState(widget);
    // wait notification updata
    Sleeper.SECONDS.sleep(1);

    assertThat(
        (Boolean) listenerSpy.getNotification("readBooleanValueChange"))
        .isTrue();
    assertThat(
        (Boolean) listenerSpy
            .getNotification("writeBooleanValueChange")).isTrue();
    // FIXME : listener stateChange always return 'null' instead of 'VALID'
    // assertThat((String) listenerSpy.getNotification("stateChange"))
    // .isEqualTo("VALID");

    // TODO change the attr quality, to change quality of boolean attr you
    // must code it in
    // device !
    // with IDL4 Java device, we need to have an dynamic attr. So this test
    // will be implemented
    // when TestGlobalScreen will be upgraded to have dynamic attr

    // check listener is no more notify if it's removed
    widget.removeBooleanAttributeListener(listenerSpy);
    listenerSpy.reset();

    switchComboBoxState(widget);

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

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

  }

  private void controlReadBooleanValueChange(final DeviceProxy devProx,
      final AttributeBooleanComboCometeV2 widget, final String attName)
      throws DevFailed {
    final BooleanAttributeListenerImpl listenerTest = new BooleanAttributeListenerImpl();
    widget.addBooleanAttributeListener(listenerTest);

    final boolean value = !getBooleanValue(widget);
    devProx.write_attribute(new DeviceAttribute(attName, value));

    Sleeper.SECONDS.sleep(2);

    assertTrue("Notification never called",
        listenerTest.isLaterNotified("readBooleanValueChange", 5000L));
    final Object booleanNotification = listenerTest
        .getNotification("writeBooleanValueChange");
    final boolean currentValueTest = (booleanNotification instanceof Boolean) ? ((Boolean) booleanNotification)
        .booleanValue() : !value;

    assertTrue("Notification value different from original",
        value == currentValueTest);

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

    devProx.write_attribute(new DeviceAttribute(attName, !value));

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

TOP

Related Classes of tangowidget.util.listenerimpl.BooleanAttributeListenerImpl

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.