use of net.sf.latexdraw.util.Injector in project latexdraw by arnobl.
the class TestCodeInserter method setUp.
@Before
public void setUp() throws NoSuchFieldException, IllegalAccessException {
final Injector injector = createInjector();
final LaTeXDraw ld = Mockito.mock(LaTeXDraw.class);
final Field field = LaTeXDraw.class.getDeclaredField("instance");
field.setAccessible(true);
field.set(null, ld);
Mockito.when(LaTeXDraw.getInstance().getInjector()).thenReturn(injector);
Mockito.when(LaTeXDraw.getInstance().getInstanceCallBack()).thenReturn(cl -> injector.getInstance(cl));
drawing = LaTeXDraw.getInstance().getInjector().getInstance(IDrawing.class);
Platform.runLater(() -> {
inserter = LaTeXDraw.getInstance().getInjector().getInstance(CodeInserter.class);
try {
FxToolkit.registerStage(() -> inserter.getInsertCodeDialogue().orElse(null));
WaitForAsyncUtils.waitForFxEvents();
} catch (final TimeoutException ex) {
fail(ex.getMessage());
}
inserter.setActivated(true);
WaitForAsyncUtils.waitForFxEvents();
inserter.getInsertCodeDialogue().ifPresent(stage -> {
stage.show();
stage.toFront();
});
});
WaitForAsyncUtils.waitForFxEvents();
}
use of net.sf.latexdraw.util.Injector in project latexdraw by arnobl.
the class TestDrawingProperties method setUp.
@Before
public void setUp() {
final Injector injector = new Injector() {
@Override
protected void configure() throws IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException {
bindAsEagerSingleton(Canvas.class);
bindAsEagerSingleton(PSTCodeGenerator.class);
bindWithCommand(IDrawing.class, Canvas.class, canvas -> canvas.getDrawing());
bindWithCommand(ViewsSynchroniserHandler.class, Canvas.class, canvas -> canvas);
}
};
gen = injector.getInstance(PSTCodeGenerator.class);
drawing = injector.getInstance(IDrawing.class);
drawing.addShape(ShapeFactory.INST.createCircle());
}