Search in sources :

Example 26 with Shape

use of net.sf.latexdraw.model.api.shape.Shape in project latexdraw by arnobl.

the class PolymorphShapeTest method testLoadDbleBorderableParams.

@ParameterizedTest
@MethodSource("net.sf.latexdraw.data.ShapeSupplier#getDiversifiedShapes")
default void testLoadDbleBorderableParams(final Shape sh) {
    assumeTrue(sh.isDbleBorderable());
    final Shape s2 = produceOutputShapeFrom(sh);
    CompareShapeMatcher.INST.assertEqualShapeDbleBorder(sh, s2);
}
Also used : Shape(net.sf.latexdraw.model.api.shape.Shape) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 27 with Shape

use of net.sf.latexdraw.model.api.shape.Shape in project latexdraw by arnobl.

the class PolymorphShapeTest method testLoadFillParams.

@ParameterizedTest
@MethodSource("net.sf.latexdraw.data.ShapeSupplier#getDiversifiedShapes")
default void testLoadFillParams(final Shape sh) {
    assumeTrue(sh.isFillable());
    final Shape s2 = produceOutputShapeFrom(sh);
    CompareShapeMatcher.INST.assertEqualShapeFill(sh, s2);
}
Also used : Shape(net.sf.latexdraw.model.api.shape.Shape) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 28 with Shape

use of net.sf.latexdraw.model.api.shape.Shape in project latexdraw by arnobl.

the class PolymorphShapeTest method testLoadShadowParams.

@ParameterizedTest
@MethodSource("net.sf.latexdraw.data.ShapeSupplier#getDiversifiedShapes")
default void testLoadShadowParams(final Shape sh) {
    assumeTrue(sh.isShadowable());
    final Shape s2 = produceOutputShapeFrom(sh);
    CompareShapeMatcher.INST.assertEqualShapeShadow(sh, s2);
}
Also used : Shape(net.sf.latexdraw.model.api.shape.Shape) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 29 with Shape

use of net.sf.latexdraw.model.api.shape.Shape in project latexdraw by arnobl.

the class PolymorphShapeTest method testLoadSaveShapeParams.

@ParameterizedTest
@MethodSource("net.sf.latexdraw.data.ShapeSupplier#getDiversifiedShapes")
default void testLoadSaveShapeParams(final Shape sh) {
    assumeTrue(sh.isBordersMovable());
    final Shape s2 = produceOutputShapeFrom(sh);
    CompareShapeMatcher.INST.assertEqualShapeBorderMov(sh, s2);
}
Also used : Shape(net.sf.latexdraw.model.api.shape.Shape) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 30 with Shape

use of net.sf.latexdraw.model.api.shape.Shape in project latexdraw by arnobl.

the class TestPSTBase method produceOutputShapeFrom.

@Override
public T produceOutputShapeFrom(final T sh) {
    final String view = factory.createView(sh).orElseThrow().getCode(ShapeFactory.INST.createPoint(), Shape.PPC);
    final net.sf.latexdraw.parser.pst.PSTLexer lexer = new net.sf.latexdraw.parser.pst.PSTLexer(CharStreams.fromString(view));
    final net.sf.latexdraw.parser.pst.PSTParser parser = new net.sf.latexdraw.parser.pst.PSTParser(new CommonTokenStream(lexer));
    final TestPSTParser.ErrorPSTLatexdrawListener listener = new TestPSTParser.ErrorPSTLatexdrawListener();
    parser.addParseListener(listener);
    parser.pstCode(new PSTContext());
    parser.getInterpreter().clearDFA();
    lexer.getInterpreter().clearDFA();
    new ATNDeserializer().deserialize(net.sf.latexdraw.parser.pst.PSTLexer._serializedATN.toCharArray());
    final List<Shape> shapes = listener.flatShapes();
    assertEquals(1, shapes.size());
    return (T) shapes.get(0);
}
Also used : ATNDeserializer(org.antlr.v4.runtime.atn.ATNDeserializer) CommonTokenStream(org.antlr.v4.runtime.CommonTokenStream) Shape(net.sf.latexdraw.model.api.shape.Shape) TestPSTParser(net.sf.latexdraw.parser.pst.TestPSTParser) PSTContext(net.sf.latexdraw.parser.pst.PSTContext) TestPSTParser(net.sf.latexdraw.parser.pst.TestPSTParser)

Aggregations

Shape (net.sf.latexdraw.model.api.shape.Shape)75 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)43 MethodSource (org.junit.jupiter.params.provider.MethodSource)41 Test (org.junit.Test)12 Point (net.sf.latexdraw.model.api.shape.Point)8 PositionShape (net.sf.latexdraw.model.api.shape.PositionShape)7 HelperTest (net.sf.latexdraw.HelperTest)6 ShapeFactory (net.sf.latexdraw.model.ShapeFactory)6 Circle (net.sf.latexdraw.model.api.shape.Circle)6 RectangularShape (net.sf.latexdraw.model.api.shape.RectangularShape)6 NotNull (org.jetbrains.annotations.NotNull)6 Click (io.github.interacto.jfx.interaction.library.Click)5 ArrayList (java.util.ArrayList)5 Objects (java.util.Objects)5 MathUtils (net.sf.latexdraw.model.MathUtils)5 Rectangle (net.sf.latexdraw.model.api.shape.Rectangle)5 Inject (net.sf.latexdraw.util.Inject)5 CommandsRegistry (io.github.interacto.command.CommandsRegistry)3 Redo (io.github.interacto.command.library.Redo)3 Undo (io.github.interacto.command.library.Undo)3