Search in sources :

Example 1 with MenuEditorController

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();
}
Also used : LibraryVersionDetector(com.thecoderscorner.menu.editorui.generator.LibraryVersionDetector) MenuEditorController(com.thecoderscorner.menu.editorui.controller.MenuEditorController) Scene(javafx.scene.Scene) FXMLLoader(javafx.fxml.FXMLLoader) Pane(javafx.scene.layout.Pane) VersionInfo(com.thecoderscorner.menu.persist.VersionInfo) ConfigurationStorage(com.thecoderscorner.menu.editorui.storage.ConfigurationStorage) CurrentProjectEditorUI(com.thecoderscorner.menu.editorui.uimodel.CurrentProjectEditorUI) ArduinoLibraryInstaller(com.thecoderscorner.menu.editorui.generator.arduino.ArduinoLibraryInstaller) CodePluginManager(com.thecoderscorner.menu.editorui.generator.plugin.CodePluginManager) Start(org.testfx.framework.junit5.Start)

Aggregations

MenuEditorController (com.thecoderscorner.menu.editorui.controller.MenuEditorController)1 LibraryVersionDetector (com.thecoderscorner.menu.editorui.generator.LibraryVersionDetector)1 ArduinoLibraryInstaller (com.thecoderscorner.menu.editorui.generator.arduino.ArduinoLibraryInstaller)1 CodePluginManager (com.thecoderscorner.menu.editorui.generator.plugin.CodePluginManager)1 ConfigurationStorage (com.thecoderscorner.menu.editorui.storage.ConfigurationStorage)1 CurrentProjectEditorUI (com.thecoderscorner.menu.editorui.uimodel.CurrentProjectEditorUI)1 VersionInfo (com.thecoderscorner.menu.persist.VersionInfo)1 FXMLLoader (javafx.fxml.FXMLLoader)1 Scene (javafx.scene.Scene)1 Pane (javafx.scene.layout.Pane)1 Start (org.testfx.framework.junit5.Start)1