diff --git a/test_suite/FGTestApi/testGlobals.cxx b/test_suite/FGTestApi/testGlobals.cxx index 687886631..5ee07e763 100644 --- a/test_suite/FGTestApi/testGlobals.cxx +++ b/test_suite/FGTestApi/testGlobals.cxx @@ -1,6 +1,7 @@ #include "config.h" #include "test_suite/dataStore.hxx" +#include #include "TestDataLogger.hxx" #include "testGlobals.hxx" @@ -67,8 +68,7 @@ void initTestGlobals(const std::string& testName) fgSetDefaults(); - std::unique_ptr t; - t.reset(new TimeManager); + auto t = globals->add_new_subsystem(SGSubsystemMgr::INIT); t->init(); // establish mag-var data /** @@ -369,6 +369,15 @@ bool runForTimeWithCheck(double t, RunCheck check) return false; } +void adjustSimulationWorldTime(time_t desiredUnixTime) +{ + int timeOffset = desiredUnixTime - time(nullptr); + globals->get_props()->setIntValue("/sim/time/cur-time-override", 0); + globals->get_props()->setIntValue("/sim/time/warp", timeOffset); + + globals->get_subsystem()->update(0.0); +} + void writeFlightPlanToKML(flightgear::FlightPlanRef fp) { if (!global_loggingToKML) diff --git a/test_suite/FGTestApi/testGlobals.hxx b/test_suite/FGTestApi/testGlobals.hxx index e48ac24e1..9e69dfd42 100644 --- a/test_suite/FGTestApi/testGlobals.hxx +++ b/test_suite/FGTestApi/testGlobals.hxx @@ -48,6 +48,11 @@ void setPositionAndStabilise(const SGGeod& g); void runForTime(double t); +/** + @brief set the simulation date/time clock to 'time' + */ +void adjustSimulationWorldTime(time_t time); + using RunCheck = std::function; bool runForTimeWithCheck(double t, RunCheck check);