use of com.thecoderscorner.menu.editorui.controller.MenuEditorController in project tcMenu by davetcc.
the class MenuEditorTestCases method onStart.
@Start
public void onStart(Stage stage) throws Exception {
dirHelper.initialise();
dirHelper.createSketch(TCMENU_DIR, "exampleSketch1", true);
dirHelper.createSketch(TCMENU_DIR, "exampleSketch2", true);
var sketch1 = dirHelper.createSketch(SKETCHES_DIR, "sketches1", true);
var sketch2 = dirHelper.createSketch(SKETCHES_DIR, "sketches2", true);
dirHelper.createSketch(SKETCHES_DIR, "sketchesIgnore", false);
// load the main window FXML
FXMLLoader loader = new FXMLLoader(getClass().getResource("/ui/menuEditor.fxml"));
Pane myPane = loader.load();
// we need to mock a few things around the edges to make testing easier.
editorProjectUI = mock(CurrentProjectEditorUI.class);
when(editorProjectUI.createPanelForMenuItem(any(), any(), any(), any())).thenReturn(Optional.empty());
persistor = mock(ProjectPersistor.class);
installer = mock(ArduinoLibraryInstaller.class);
simulatedCodeManager = mock(CodePluginManager.class);
when(simulatedCodeManager.getLoadedPlugins()).thenReturn(Collections.singletonList(generateCodePluginConfig()));
setUpInstallerLibVersions();
// create a basic project, that has a few menu items in it.
project = new CurrentEditorProject(editorProjectUI, persistor, mock(ConfigurationStorage.class));
ConfigurationStorage storage = mock(ConfigurationStorage.class);
when(storage.loadRecents()).thenReturn(List.of(sketch1.orElseThrow(), sketch2.orElseThrow(), "filesDoesNotExistRemove.emf"));
when(storage.getRegisteredKey()).thenReturn("UnitTesterII");
when(storage.isUsingArduinoIDE()).thenReturn(true);
when(storage.getArduinoOverrideDirectory()).thenReturn(Optional.empty());
// both versions same, do not invoke splash screen.
when(storage.getVersion()).thenReturn("1.1.1");
when(storage.getLastRunVersion()).thenReturn(new VersionInfo("1.1.1"));
// set up the controller and stage..
MenuEditorController controller = loader.getController();
libDetector = mock(LibraryVersionDetector.class);
when(libDetector.getReleaseType()).thenReturn(ReleaseType.STABLE);
controller.initialise(project, installer, editorProjectUI, simulatedCodeManager, storage, libDetector);
this.stage = stage;
when(libDetector.availableVersionsAreValid(anyBoolean())).thenReturn(true);
Scene myScene = new Scene(myPane);
stage.setScene(myScene);
stage.show();
}
Aggregations