public class DeviceStateStatusPanelTest extends ABeansTest {
@Override
public void widgetTestDescription() throws DevFailed {
DeviceStateStatusPanel widgetBeforeStart;
DeviceStateStatusPanel widgetAfterStart;
// keep the same instance of JFrame for the test
final JFrame jfBeforeStart = new JFrame();
final JFrame jfAfterStart = new JFrame();
final AssertErrorConf aecBeforeStart = new AssertErrorConf(
jfBeforeStart);
final AssertErrorConf aecAfterStart = new AssertErrorConf(jfAfterStart);
componentInitialisationTest();
componentNotWritableTest();
// test invalid device Conf
for (int i = 0; i < NB_INVALID_DEVICE_CONF_TEST; i++) {
// reset device for test
// initFirstDevice();
// construct a widget with userEnable = true,alarmEnable =true,
widgetBeforeStart = new DeviceStateStatusPanel.Builder(m_deviceName)
.jframe(jfBeforeStart).autoStart(false).build();
widgetAfterStart = new DeviceStateStatusPanel.Builder(m_deviceName)
.jframe(jfAfterStart).build();
// Before Start
invalidDeviceConfigTest(widgetBeforeStart, i, aecBeforeStart, true);
// After Start
invalidDeviceConfigTest(widgetAfterStart, i, aecAfterStart, false);
jfBeforeStart.remove(widgetBeforeStart);// clear jframe
jfAfterStart.remove(widgetAfterStart);// clear jframe
// clear
widgetBeforeStart.stop();
widgetAfterStart.stop();
}
jfBeforeStart.dispose();
// //////////////////////////////////////////////////////////////////
// check if we change device name, bean is updated (state, status
// and tooltip)
// ////////////////////////////////////////////////////////////////
// init the 2 test device and change the state and status of device
// 2
initDevice();
final DeviceData dd = new DeviceData();
dd.insert(10);
m_deviceProxy2.command_inout("switchState", dd);
// create the bean and test is correctly display the sate, status
// and tootlip device 1
widgetAfterStart = new DeviceStateStatusPanel.Builder(m_deviceName)
.jframe(jfAfterStart).build();
Sleeper.SECONDS.sleep(2);
assertBeanShowSameDeviceValue(jfAfterStart, m_deviceProxy);
toolTiptest(m_deviceName + "/status", getTextArea(jfAfterStart));
// switch to device 2 and test bean is updated
widgetAfterStart.setDeviceName(m_deviceName2);
Sleeper.SECONDS.sleep(2);
assertBeanShowSameDeviceValue(jfAfterStart, m_deviceProxy2);
toolTiptest(m_deviceName2 + "/status", getTextArea(jfAfterStart));
// clean
widgetAfterStart.stop();
jfAfterStart.dispose();
}