38#include <system_error>
40namespace fs = std::filesystem;
62 m_tempDir( fs::temp_directory_path() /
"kicad_settings_manager_test" )
77 wxString
Path(
const std::string& aName )
const
79 return wxString( (
m_tempDir / aName ).
string() );
153 fs::path themePath = m_tempDir /
"theme.json";
155 auto readFile = [](
const fs::path& aPath )
157 std::ifstream in( aPath );
158 std::stringstream buffer;
159 buffer << in.rdbuf();
166 nlohmann::json js = nlohmann::json::parse(
readFile( themePath ) );
168 js.erase(
"gerbview" );
170 std::ofstream out( themePath );
171 out << std::setw( 2 ) << js << std::endl;
175 std::string before =
readFile( themePath );
180 BOOST_CHECK( !cfg.
SaveToFile( wxEmptyString ) );
Color settings are a bit different than most of the settings objects in that there can be more than o...
FLUSH_TEST_SETTINGS(const wxString &aFullPath)
virtual bool LoadFromFile(const wxString &aDirectory="")
Loads the backing file from disk and then calls Load()
std::vector< PARAM_BASE * > m_params
The list of parameters (owned by this object)
JSON_SETTINGS(const wxString &aFilename, SETTINGS_LOC aLocation, int aSchemaVersion)
virtual bool SaveToFile(const wxString &aDirectory="", bool aForce=false)
Calls Store() and then writes the contents of the JSON document to a file.
T * RegisterSettings(T *aSettings, bool aLoadNow=true)
Take ownership of the pointer passed in.
COMMON_SETTINGS * GetCommonSettings() const
Retrieve the common settings shared by all applications.
void FlushAndRelease(JSON_SETTINGS *aSettings, bool aSave=true)
If the given settings object is registered, save it to disk and unregister it.
static bool readFile(const wxString &aFileName, wxString &aOut, size_t aLimit=0)
Read a file into aOut.
wxString Path(const std::string &aName) const
~SETTINGS_MANAGER_FIXTURE()
SETTINGS_MANAGER_FIXTURE()
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(LoadFlushesDirtySettings)
BOOST_CHECK_EQUAL(result, "25.4")