use of de.neemann.digital.draw.elements.Circuit in project Digital by hneemann.
the class CircuitBuilderTest method testBuilderSequentialJK_JequalsK.
public void testBuilderSequentialJK_JequalsK() throws Exception {
Variable y0 = new Variable("Y_0");
Variable y1 = new Variable("Y_1");
// counter
Expression y0s = not(y0);
Expression y1s = or(and(not(y0), y1), and(y0, not(y1)));
ElementLibrary library = new ElementLibrary();
Circuit circuit = new CircuitBuilder(new ShapeFactory(library), true).addSequential("Y_0", y0s).addSequential("Y_1", y1s).createCircuit();
ModelCreator m = new ModelCreator(circuit, library);
TestExecuter te = new TestExecuter(m.createModel(false)).setUp(m);
te.check(0, 0);
te.checkC(1, 0);
te.checkC(0, 1);
te.checkC(1, 1);
te.checkC(0, 0);
}
use of de.neemann.digital.draw.elements.Circuit in project Digital by hneemann.
the class TestExport method export.
private static ByteArrayOutputStream export(String file, ExportFactory creator) throws NodeException, PinException, IOException, ElementNotFoundException {
Circuit circuit = new ToBreakRunner(file).getCircuit();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
new Export(circuit, creator).export(baos);
return baos;
}
use of de.neemann.digital.draw.elements.Circuit in project Digital by hneemann.
the class TestInGUI method testMoveSelectedComponent.
public void testMoveSelectedComponent() {
new GuiTester().mouseMove(110, 110).add(new GuiTester.WindowCheck<>(Main.class, (gt, main) -> {
final CircuitComponent cc = main.getCircuitComponent();
final VisualElement ve = new VisualElement(And.DESCRIPTION.getName()).setShapeFactory(cc.getLibrary().getShapeFactory());
cc.setPartToInsert(ve);
})).mouseClick(InputEvent.BUTTON1_MASK).mouseMove(100, 100).mouseClick(InputEvent.BUTTON1_MASK).mouseMove(400, 400).mouseClick(InputEvent.BUTTON1_MASK).add(new GuiTester.WindowCheck<>(Main.class, (gt, main) -> {
final Circuit c = main.getCircuitComponent().getCircuit();
assertEquals(1, c.getElements().size());
final Vector pos = c.getElements().get(0).getPos();
assertTrue(pos.x > 300);
assertTrue(pos.y > 300);
})).execute();
}
use of de.neemann.digital.draw.elements.Circuit in project Digital by hneemann.
the class TestInGUI method testTreeView.
public void testTreeView() {
new GuiTester().delay(500).press("F5").mouseMove(100, 100).mouseClick(InputEvent.BUTTON1_MASK).mouseMove(400, 200).mouseClick(InputEvent.BUTTON1_MASK).delay(500).add(new GuiTester.WindowCheck<>(Main.class, (gt, main) -> {
Circuit c = main.getCircuitComponent().getCircuit();
assertEquals(1, c.getElements().size());
})).execute();
}
use of de.neemann.digital.draw.elements.Circuit in project Digital by hneemann.
the class GuiTester method execute.
/**
* executes the test
*/
public void execute() {
if (isDisplay()) {
try {
SwingUtilities.invokeAndWait(() -> {
if (filename != null) {
File file = new File(Resources.getRoot(), filename);
main = new Main.MainBuilder().setFileToOpen(file).build();
if (displayName != null)
SwingUtilities.invokeLater(() -> main.setTitle(displayName + " - Digital"));
} else
main = new Main.MainBuilder().setCircuit(new Circuit()).build();
main.setVisible(true);
});
Thread.sleep(500);
try {
robot = new Robot();
robot.setAutoWaitForIdle(true);
int step = 0;
for (Runnable r : runnableList) {
if (step > 0) {
System.err.print("-");
Thread.sleep(SLEEP_TIME);
}
step++;
System.err.print(step);
r.run(this);
}
} finally {
SwingUtilities.invokeAndWait(() -> main.dispose());
}
System.err.println();
} catch (Exception e) {
e.printStackTrace();
fail();
}
}
}
Aggregations