Skip to content

Commit

Permalink
Fix: Testing on presets-overhaul branch
Browse files Browse the repository at this point in the history
  • Loading branch information
SonarSonic committed Feb 8, 2024
1 parent 3977e6a commit 8f0bb61
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
9 changes: 5 additions & 4 deletions src/main/java/drawingbot/files/json/AbstractPresetLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import drawingbot.javafx.GenericPreset;
import drawingbot.javafx.preferences.DBPreferences;
import drawingbot.registry.MasterRegistry;
import javafx.application.Platform;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.collections.FXCollections;
Expand Down Expand Up @@ -118,7 +119,7 @@ public void addPreset(GenericPreset<DATA> preset) {

if(!isLoading()){
markDirty();
sendListenerEvent(listener -> listener.onPresetAdded(preset));
Platform.runLater(() -> sendListenerEvent(listener -> listener.onPresetAdded(preset)));
}
}

Expand All @@ -139,7 +140,7 @@ public void removePreset(GenericPreset<DATA> preset) {

if(!isLoading()){
markDirty();
sendListenerEvent(listener -> listener.onPresetRemoved(preset));
Platform.runLater(() -> sendListenerEvent(listener -> listener.onPresetRemoved(preset)));
}

}
Expand Down Expand Up @@ -185,8 +186,8 @@ public GenericPreset<DATA> editPreset(GenericPreset<DATA> oldPreset, GenericPres
}

//Send out listener events and mark the presets as dirty
sendListenerEvent(listener -> listener.onPresetEdited(editPreset));
markDirty();
Platform.runLater(() -> sendListenerEvent(listener -> listener.onPresetEdited(editPreset)));
return result;
}

Expand Down Expand Up @@ -298,7 +299,7 @@ public void markDirty() {
JsonLoaderManager.INSTANCE.markDirty(this);

//run later to prevent json update happen before services have been created
sendListenerEvent(Listener::onMarkDirty);
Platform.runLater(() -> sendListenerEvent(Listener::onMarkDirty));
}
}

Expand Down
7 changes: 5 additions & 2 deletions src/test/java/drawingbot/JUnitDBV3ClassRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import drawingbot.files.json.JsonLoaderManager;
import drawingbot.javafx.preferences.DBPreferences;
import drawingbot.javafx.util.JFXUtils;
import javafx.application.Platform;
import org.junit.Assert;
import org.junit.runners.BlockJUnit4ClassRunner;
Expand All @@ -25,8 +26,10 @@ public JUnitDBV3ClassRunner(final Class<?> clazz) throws InitializationError{

public static boolean setupTestDBV3Free(){
TestUtils.lazySetupDirectories();
DBPreferences.INSTANCE.autoRunPFM.set(false);
JsonLoaderManager.loadDefaultPresetContainerJSON("pfm_unit_test.json");
JFXUtils.runNow(() -> {
DBPreferences.INSTANCE.autoRunPFM.set(false);
JsonLoaderManager.loadDefaultPresetContainerJSON("pfm_unit_test.json");
});

//Load the default test image
TestUtils.loadDefaultTestImage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public static void testCanvas(String testID, PFMFactory<?> factory, List<String>

//Reset the canvas to default settings
JFXUtils.runNow(() -> {
Register.PRESET_LOADER_DRAWING_AREA.getDefaultManager().tryApplyPreset(DrawingBotV3.context(), Register.PRESET_LOADER_DRAWING_AREA.getDefaultPreset());
Register.PRESET_LOADER_DRAWING_AREA.getDefaultPreset().applyPreset(DrawingBotV3.context());
});
}
}
Expand Down

0 comments on commit 8f0bb61

Please sign in to comment.