feat(core): allow to disable or reset preferences programmatically
Description
When testing a feature, especially in GUI test, preferences can interfere with the test. It would be nice to add a way to reset or disable preferences would make tests more reliable.
Functional specifications
The GUI tests don't use user preferences anymore.
Technical specifications
Actually, a method already exists to disable preferences: Preferences::set_enabled(false)
. One only have to call this method in Tester::init
. This works fine in SightViewer, however it makes SightCalibrator crash badly. This crash must be addressed for this feature to work.
SightCalibrator crash is actually related to an "infinite" loop (technically not infinite, but has 2⁶⁴*2⁶⁴ iterations, which is pretty big) in SChessboardReprojection::updateChessboardSize
: by default, if preferences are disabled, width and height are both set to 0, and the loops iterate from 0 to width-1.
Of course, we could simply provide a sane default in this method, but this only heals the symptom: the whole point is that set_enabled(false)
doesn't quite do what we want. We still want preferences, as some applications rely on them (via SPreferencesConfiguration), however what we really want is to ignore any preferences saved in a file, and not overwrite the new preferences in a file. Therefore, I'll create a new method Preferences::ignoreFilesystem
, which allows to completely ignore preferences file, both in load and save, while still making preferences usable.
Test plan
Manual testing. Run SightViewer in fullscreen, then close it. Run sightviewerguitest, it shouldn't run in fullscreen. Run SightViewer, it should still be in fullscreen.