Search in sources :

Example 11 with Circuit

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);
}
Also used : ElementLibrary(de.neemann.digital.draw.library.ElementLibrary) Variable(de.neemann.digital.analyse.expression.Variable) Expression(de.neemann.digital.analyse.expression.Expression) ShapeFactory(de.neemann.digital.draw.shapes.ShapeFactory) Circuit(de.neemann.digital.draw.elements.Circuit) TestExecuter(de.neemann.digital.TestExecuter) ModelCreator(de.neemann.digital.draw.model.ModelCreator)

Example 12 with Circuit

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;
}
Also used : Circuit(de.neemann.digital.draw.elements.Circuit) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Example 13 with Circuit

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();
}
Also used : VisualElement(de.neemann.digital.draw.elements.VisualElement) Circuit(de.neemann.digital.draw.elements.Circuit) Vector(de.neemann.digital.draw.graphics.Vector)

Example 14 with Circuit

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();
}
Also used : Circuit(de.neemann.digital.draw.elements.Circuit)

Example 15 with Circuit

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();
        }
    }
}
Also used : Circuit(de.neemann.digital.draw.elements.Circuit) File(java.io.File) Main(de.neemann.digital.gui.Main) IOException(java.io.IOException)

Aggregations

Circuit (de.neemann.digital.draw.elements.Circuit)26 ElementLibrary (de.neemann.digital.draw.library.ElementLibrary)9 ShapeFactory (de.neemann.digital.draw.shapes.ShapeFactory)8 Vector (de.neemann.digital.draw.graphics.Vector)7 ModelCreator (de.neemann.digital.draw.model.ModelCreator)7 Expression (de.neemann.digital.analyse.expression.Expression)6 VisualElement (de.neemann.digital.draw.elements.VisualElement)6 File (java.io.File)6 TestExecuter (de.neemann.digital.TestExecuter)5 Wire (de.neemann.digital.draw.elements.Wire)5 Variable (de.neemann.digital.analyse.expression.Variable)4 IOException (java.io.IOException)4 ElementAttributes (de.neemann.digital.core.element.ElementAttributes)3 Main (de.neemann.digital.gui.Main)3 CircuitBuilder (de.neemann.digital.builder.circuit.CircuitBuilder)2 Model (de.neemann.digital.core.Model)2 ExpressionListenerStore (de.neemann.digital.gui.components.table.ExpressionListenerStore)2 ToBreakRunner (de.neemann.digital.integration.ToBreakRunner)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 ModelAnalyser (de.neemann.digital.analyse.ModelAnalyser)1