added gui test for net renaming

This commit is contained in:
hneemann 2019-08-28 09:48:08 +02:00
parent e43355eda8
commit dce75d9667
2 changed files with 148 additions and 9 deletions

View File

@ -16,6 +16,7 @@ import de.neemann.digital.core.io.Out;
import de.neemann.digital.core.memory.ROM; import de.neemann.digital.core.memory.ROM;
import de.neemann.digital.core.wiring.Driver; import de.neemann.digital.core.wiring.Driver;
import de.neemann.digital.draw.elements.Circuit; import de.neemann.digital.draw.elements.Circuit;
import de.neemann.digital.draw.elements.Tunnel;
import de.neemann.digital.draw.elements.VisualElement; import de.neemann.digital.draw.elements.VisualElement;
import de.neemann.digital.draw.elements.Wire; import de.neemann.digital.draw.elements.Wire;
import de.neemann.digital.draw.graphics.GraphicMinMax; import de.neemann.digital.draw.graphics.GraphicMinMax;
@ -62,7 +63,7 @@ import static de.neemann.digital.testing.TestCaseElement.TESTDATA;
* These tests are excluded from the maven build because gui tests are sometimes fragile. * These tests are excluded from the maven build because gui tests are sometimes fragile.
* They may not behave as expected on all systems. * They may not behave as expected on all systems.
* Run this tests directly from your IDE. * Run this tests directly from your IDE.
* * <p>
* maven: mvn -Dtest=TestInGUI test * maven: mvn -Dtest=TestInGUI test
*/ */
public class TestInGUI extends TestCase { public class TestInGUI extends TestCase {
@ -240,14 +241,14 @@ public class TestInGUI extends TestCase {
.add(new EnterTruthTable(0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1)) .add(new EnterTruthTable(0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1))
.press("F1") .press("F1")
.delay(500) .delay(500)
.add(new GuiTester.ColorPicker(KarnaughMapComponent.class, 146, 110, new Color(215,175,175))) .add(new GuiTester.ColorPicker(KarnaughMapComponent.class, 146, 110, new Color(215, 175, 175)))
.add(new GuiTester.ColorPicker(KarnaughMapComponent.class, 266, 109, new Color(187,187,221))) .add(new GuiTester.ColorPicker(KarnaughMapComponent.class, 266, 109, new Color(187, 187, 221)))
.add(new GuiTester.ColorPicker(KarnaughMapComponent.class, 86, 169, new Color(255,187,187))) .add(new GuiTester.ColorPicker(KarnaughMapComponent.class, 86, 169, new Color(255, 187, 187)))
.add(new GuiTester.ColorPicker(KarnaughMapComponent.class, 205, 169, new Color(127,255,127))) .add(new GuiTester.ColorPicker(KarnaughMapComponent.class, 205, 169, new Color(127, 255, 127)))
.add(new GuiTester.ColorPicker(KarnaughMapComponent.class, 145, 228, new Color(127,127,255))) .add(new GuiTester.ColorPicker(KarnaughMapComponent.class, 145, 228, new Color(127, 127, 255)))
.add(new GuiTester.ColorPicker(KarnaughMapComponent.class, 266, 230, new Color(255,175,255))) .add(new GuiTester.ColorPicker(KarnaughMapComponent.class, 266, 230, new Color(255, 175, 255)))
.add(new GuiTester.ColorPicker(KarnaughMapComponent.class, 86, 288, new Color(242,242,191))) .add(new GuiTester.ColorPicker(KarnaughMapComponent.class, 86, 288, new Color(242, 242, 191)))
.add(new GuiTester.ColorPicker(KarnaughMapComponent.class, 205, 289, new Color(127,255,255))) .add(new GuiTester.ColorPicker(KarnaughMapComponent.class, 205, 289, new Color(127, 255, 255)))
// .add(new GuiTester.ColorPickerCreator(KarnaughMapComponent.class)) // .add(new GuiTester.ColorPickerCreator(KarnaughMapComponent.class))
// .ask("Shows the k-map a checkerboard pattern?") // .ask("Shows the k-map a checkerboard pattern?")
.add(new GuiTester.CloseTopMost()) .add(new GuiTester.CloseTopMost())
@ -954,6 +955,31 @@ public class TestInGUI extends TestCase {
.execute(); .execute();
} }
public void testNetRename() {
new GuiTester("dig/net/netRename.dig")
.add(new SetMouseToElement(v -> v.equalsDescription(Tunnel.DESCRIPTION) && v.getPos().x < 400))
.mouseClick(InputEvent.BUTTON3_MASK)
.delay(200)
.type("et")
.press("ENTER")
.delay(200)
.add(new GuiTester.CheckTextInWindow<>(JDialog.class, "'net'"))
.delay(200)
.press("ENTER")
.delay(200)
.add(new GuiTester.WindowCheck<Main>(Main.class){
@Override
public void checkWindow(GuiTester guiTester, Main main) {
List<VisualElement> e = main.getCircuitComponent().getCircuit()
.findElements(v -> v.equalsDescription(Tunnel.DESCRIPTION));
assertEquals(3, e.size());
for (VisualElement v : e)
assertEquals("net", v.getElementAttributes().get(Keys.NETNAME));
}
})
.execute();
}
public void testFSM() { public void testFSM() {
new GuiTester() new GuiTester()
.press("F10") .press("F10")

View File

@ -0,0 +1,113 @@
<?xml version="1.0" encoding="utf-8"?>
<circuit>
<version>1</version>
<attributes/>
<visualElements>
<visualElement>
<elementName>In</elementName>
<elementAttributes>
<entry>
<string>Label</string>
<string>A</string>
</entry>
</elementAttributes>
<pos x="360" y="140"/>
</visualElement>
<visualElement>
<elementName>Tunnel</elementName>
<elementAttributes>
<entry>
<string>NetName</string>
<string>n</string>
</entry>
</elementAttributes>
<pos x="380" y="140"/>
</visualElement>
<visualElement>
<elementName>Tunnel</elementName>
<elementAttributes>
<entry>
<string>rotation</string>
<rotation rotation="2"/>
</entry>
<entry>
<string>NetName</string>
<string>n</string>
</entry>
</elementAttributes>
<pos x="500" y="140"/>
</visualElement>
<visualElement>
<elementName>Tunnel</elementName>
<elementAttributes>
<entry>
<string>rotation</string>
<rotation rotation="2"/>
</entry>
<entry>
<string>NetName</string>
<string>n</string>
</entry>
</elementAttributes>
<pos x="500" y="180"/>
</visualElement>
<visualElement>
<elementName>Out</elementName>
<elementAttributes>
<entry>
<string>Label</string>
<string>Y</string>
</entry>
</elementAttributes>
<pos x="580" y="140"/>
</visualElement>
<visualElement>
<elementName>Out</elementName>
<elementAttributes>
<entry>
<string>Label</string>
<string>X</string>
</entry>
</elementAttributes>
<pos x="580" y="180"/>
</visualElement>
<visualElement>
<elementName>Not</elementName>
<elementAttributes/>
<pos x="520" y="180"/>
</visualElement>
<visualElement>
<elementName>Testcase</elementName>
<elementAttributes>
<entry>
<string>Testdata</string>
<testData>
<dataString>A Y X
0 0 1
1 1 0</dataString>
</testData>
</entry>
</elementAttributes>
<pos x="420" y="220"/>
</visualElement>
</visualElements>
<wires>
<wire>
<p1 x="500" y="180"/>
<p2 x="520" y="180"/>
</wire>
<wire>
<p1 x="560" y="180"/>
<p2 x="580" y="180"/>
</wire>
<wire>
<p1 x="360" y="140"/>
<p2 x="380" y="140"/>
</wire>
<wire>
<p1 x="500" y="140"/>
<p2 x="580" y="140"/>
</wire>
</wires>
<measurementOrdering/>
</circuit>