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();
}