TestUtils.createImagePNG(m_testProject, "imA.png", 1, 2).getLocation().toPortableString();
addDevice(category, "dev", "name", imagePath, new Rectangle(1, 2, 10, 20));
}
// initial Device state
{
DeviceInfo device = DeviceManager.getDevice("dev");
assertEquals("name", device.getName());
assertEquals(new Rectangle(1, 2, 10, 20), device.getDisplayBounds());
assertEquals(1, device.getImage().getBounds().width);
assertEquals(2, device.getImage().getBounds().height);
}
// edit
{
String imagePath =
TestUtils.createImagePNG(m_testProject, "imB.png", 10, 20).getLocation().toPortableString();
// this command will be ignored
DeviceManager.commandsAdd(new DeviceEditCommand("dev",
"otherName",
imagePath,
new Rectangle(0, 0, 0, 0)));
// we will use this command
DeviceManager.commandsAdd(new DeviceEditCommand("dev",
"newName",
imagePath,
new Rectangle(10, 20, 100, 200)));
}
// Device was updated
{
DeviceInfo device = DeviceManager.getDevice("dev");
assertEquals("newName", device.getName());
assertEquals(new Rectangle(10, 20, 100, 200), device.getDisplayBounds());
assertEquals(10, device.getImage().getBounds().width);
assertEquals(20, device.getImage().getBounds().height);
}
// reload
DeviceManager.commandsWrite();
DeviceManager.forceReload();
// still updated Device
{
DeviceInfo device = DeviceManager.getDevice("dev");
assertEquals("newName", device.getName());
assertEquals(new Rectangle(10, 20, 100, 200), device.getDisplayBounds());
assertEquals(10, device.getImage().getBounds().width);
assertEquals(20, device.getImage().getBounds().height);
}
}