mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
467cee749b
* Rewrite of the `Base.getSettingsFolder()` and `Platform.getSettingsFolder()` Rewrote both function so they fit into a single file, negating the need for hopping around when looking into what this functionality does. Also rewrote it so it is no longer generates random awt windows through the `Messages` class * Fixed issue with missing / * Added both options for overrides - Added the previous settings override in base again - Added a system property to override the settings folder within tests * Add support for portable settings detection Introduces logic to detect a preferences.txt file in the same folder as the running executable or jar. If found, settings are loaded from this location, improving portability and allowing users to override default settings without modifying system directories.
41 lines
1.1 KiB
Java
41 lines
1.1 KiB
Java
import org.junit.jupiter.api.Test;
|
|
import processing.utils.Settings;
|
|
|
|
import java.io.IOException;
|
|
import java.nio.file.Files;
|
|
|
|
public class SettingsTest {
|
|
|
|
/**
|
|
* Requesting the settings folder should create it if it doesn't exist
|
|
*/
|
|
@Test
|
|
public void testSettingsFolder() {
|
|
try {
|
|
var folder = Settings.getFolder();
|
|
assert (folder.exists());
|
|
} catch (Settings.SettingsFolderException e) {
|
|
assert (false);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Overriding the settings folder via system property should work
|
|
*/
|
|
@Test
|
|
public void testOverrideFolder() throws IOException {
|
|
var settings = Files.createTempDirectory("settings_test");
|
|
System.setProperty("processing.settings.folder", settings.toString());
|
|
|
|
try {
|
|
var folder = Settings.getFolder();
|
|
assert (folder.toPath().toString().equals(settings.toString()));
|
|
} catch (Settings.SettingsFolderException e) {
|
|
assert (false);
|
|
} finally {
|
|
System.clearProperty("processing.settings.folder");
|
|
Files.deleteIfExists(settings);
|
|
}
|
|
}
|
|
}
|