use of net.sf.latexdraw.LaTeXDraw 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.LaTeXDraw in project latexdraw by arnobl.
the class TestExporter method setUp.
@Override
@Before
public void setUp() {
super.setUp();
exporter = (Exporter) injectorFactory.call(Exporter.class);
hand.setActivated(true);
when(pencil.isActivated()).thenReturn(false);
WaitForAsyncUtils.waitForFxEvents();
final TemplateManager template = (TemplateManager) injectorFactory.call(TemplateManager.class);
template.templatePane = new FlowPane();
final StatusBarController status = (StatusBarController) injectorFactory.call(StatusBarController.class);
Mockito.when(status.getLabel()).thenReturn(new Label());
Mockito.when(status.getProgressBar()).thenReturn(new ProgressBar());
chooser = Mockito.mock(FileChooser.class);
Mockito.when(chooser.getExtensionFilters()).thenReturn(FXCollections.observableArrayList());
try {
Mockito.when(chooser.showOpenDialog(Mockito.any())).thenReturn(tmp.newFile());
Mockito.when(chooser.showSaveDialog(Mockito.any())).thenReturn(tmp.newFile());
Field field = Exporter.class.getDeclaredField("fileChooserExport");
field.setAccessible(true);
field.set(exporter, chooser);
final LaTeXDraw ld = Mockito.mock(LaTeXDraw.class);
field = LaTeXDraw.class.getDeclaredField("instance");
field.setAccessible(true);
field.set(null, ld);
} catch (final IllegalAccessException | NoSuchFieldException | IOException ex) {
fail(ex.getMessage());
}
}
Aggregations