Migration test runs successfully now.
This commit is contained in:
parent
ac38f29ae3
commit
cf56ef1913
3 changed files with 4 additions and 7 deletions
|
@ -774,7 +774,7 @@ static void tryAutosaveMigration(const SGPath& userDataPath, SGPropertyNode* pro
|
||||||
|
|
||||||
// Load user settings from the autosave file (normally in $FG_HOME)
|
// Load user settings from the autosave file (normally in $FG_HOME)
|
||||||
void
|
void
|
||||||
FGGlobals::loadUserSettings(SGPath userDataPath)
|
FGGlobals::loadUserSettings(SGPath userDataPath, bool tryMigrate)
|
||||||
{
|
{
|
||||||
if (userDataPath.isNull()) {
|
if (userDataPath.isNull()) {
|
||||||
userDataPath = get_fg_home();
|
userDataPath = get_fg_home();
|
||||||
|
@ -794,10 +794,8 @@ FGGlobals::loadUserSettings(SGPath userDataPath)
|
||||||
SG_LOG(SG_INPUT, SG_WARN, "failed to read user settings:" << e.getMessage()
|
SG_LOG(SG_INPUT, SG_WARN, "failed to read user settings:" << e.getMessage()
|
||||||
<< "(from " << e.getOrigin() << ")");
|
<< "(from " << e.getOrigin() << ")");
|
||||||
}
|
}
|
||||||
} else {
|
} else if (tryMigrate) {
|
||||||
#if 0
|
|
||||||
tryAutosaveMigration(userDataPath, &autosave);
|
tryAutosaveMigration(userDataPath, &autosave);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
copyProperties(&autosave, globals->get_props());
|
copyProperties(&autosave, globals->get_props());
|
||||||
}
|
}
|
||||||
|
|
|
@ -385,7 +385,7 @@ public:
|
||||||
* Load user settings from the autosave file under 'userDataPath',
|
* Load user settings from the autosave file under 'userDataPath',
|
||||||
* which defaults to $FG_HOME.
|
* which defaults to $FG_HOME.
|
||||||
*/
|
*/
|
||||||
void loadUserSettings(SGPath userDatapath = SGPath());
|
void loadUserSettings(SGPath userDatapath = SGPath(), bool tryMigrate = false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save user settings to the autosave file under 'userDataPath', which
|
* Save user settings to the autosave file under 'userDataPath', which
|
||||||
|
|
|
@ -98,7 +98,6 @@ void writeLegacyAutosave2(SGPath userData, int majorVersion, int minorVersion)
|
||||||
of.close();
|
of.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void testMigration()
|
void testMigration()
|
||||||
{
|
{
|
||||||
fgtest::initTestGlobals("autosaveMigration");
|
fgtest::initTestGlobals("autosaveMigration");
|
||||||
|
@ -141,7 +140,7 @@ void testMigration()
|
||||||
blacklist->addChild("path")->setStringValue("/sim[0]/gui");
|
blacklist->addChild("path")->setStringValue("/sim[0]/gui");
|
||||||
|
|
||||||
// execute method under test
|
// execute method under test
|
||||||
globals->loadUserSettings(testUserDataPath);
|
globals->loadUserSettings(testUserDataPath, true /* try migration */);
|
||||||
|
|
||||||
SG_CHECK_EQUAL(globals->get_props()->getNode("sim")->getChildren("presets").size(), 2);
|
SG_CHECK_EQUAL(globals->get_props()->getNode("sim")->getChildren("presets").size(), 2);
|
||||||
SG_CHECK_EQUAL(globals->get_props()->getNode("sim")->getChildren("gui").size(), 0);
|
SG_CHECK_EQUAL(globals->get_props()->getNode("sim")->getChildren("gui").size(), 0);
|
||||||
|
|
Loading…
Reference in a new issue