1
0
Fork 0

Test infrastrucutre tweaks

This commit is contained in:
James Turner 2021-07-21 10:59:08 +01:00
parent 12f18b325b
commit 870dbc04f5
5 changed files with 17 additions and 24 deletions

View file

@ -70,6 +70,7 @@ void initTestGlobals(const std::string& testName)
fgSetDefaults(); fgSetDefaults();
auto t = globals->add_new_subsystem<TimeManager>(SGSubsystemMgr::INIT); auto t = globals->add_new_subsystem<TimeManager>(SGSubsystemMgr::INIT);
t->bind();
t->init(); // establish mag-var data t->init(); // establish mag-var data
/** /**

View file

@ -293,15 +293,15 @@ void AIFlightPlanTests::testAIFlightPlanLoadXML()
<flightplan> <flightplan>
<wp> <wp>
<name>onGroundWP</name> <name>onGroundWP</name>
<lat></lat> <lat>57</lat>
<lon></lon> <lon>3</lon>
<ktas>10</ktas> <ktas>10</ktas>
<on-ground>1</on-ground> <on-ground>1</on-ground>
</wp> </wp>
<wp> <wp>
<name>someWP</name> <name>someWP</name>
<lat></lat> <lat>57</lat>
<lon></lon> <lon>4</lon>
<ktas>200</ktas> <ktas>200</ktas>
<alt>8000</alt> <alt>8000</alt>
</wp> </wp>

View file

@ -94,7 +94,7 @@ void GroundnetTests::testShortestRoute()
FGTaxiNodeRef end = network->findNearestNodeOnRunway(runway->threshold()); FGTaxiNodeRef end = network->findNearestNodeOnRunway(runway->threshold());
FGTaxiRoute route = network->findShortestRoute(startParking, end); FGTaxiRoute route = network->findShortestRoute(startParking, end);
CPPUNIT_ASSERT_EQUAL(true, network->exists()); CPPUNIT_ASSERT_EQUAL(true, network->exists());
CPPUNIT_ASSERT_EQUAL(25, route.size()); CPPUNIT_ASSERT_EQUAL(29, route.size());
} }
/** /**

View file

@ -51,15 +51,16 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Set up function for each test. // Set up function for each test.
void AirportTests::setUp() { void AirportTests::setUp()
FGTestApi::setUp::initTestGlobals("timeManager"); {
FGTestApi::setUp::initTestGlobals("Traffic"); FGTestApi::setUp::initTestGlobals("Airports");
FGTestApi::setUp::initNavDataCache(); FGTestApi::setUp::initNavDataCache();
} }
// Clean up after each test. // Clean up after each test.
void AirportTests::tearDown() void AirportTests::tearDown()
{ {
FGTestApi::tearDown::shutdownTestGlobals();
} }
/** /**

View file

@ -54,7 +54,7 @@ void TimeManagerTests::tearDown()
void TimeManagerTests::testBasic() void TimeManagerTests::testBasic()
{ {
auto timeManager = new TimeManager; auto timeManager = globals->get_subsystem<TimeManager>();
// set standard values // set standard values
fgSetBool("/sim/freeze", false); fgSetBool("/sim/freeze", false);
@ -82,15 +82,13 @@ void TimeManagerTests::testBasic()
void TimeManagerTests::testFreezeUnfreeze() void TimeManagerTests::testFreezeUnfreeze()
{ {
auto timeManager = new TimeManager; auto timeManager = globals->get_subsystem<TimeManager>();
// set standard values // set standard values
fgSetBool("/sim/freeze/clock", false); fgSetBool("/sim/freeze/clock", false);
fgSetBool("/sim/sceneryloaded", true); fgSetBool("/sim/sceneryloaded", true);
fgSetDouble("/sim/model-hz", 120.0); fgSetDouble("/sim/model-hz", 120.0);
timeManager->bind();
timeManager->init();
timeManager->postinit(); timeManager->postinit();
double simDt, realDt; double simDt, realDt;
@ -122,19 +120,17 @@ void TimeManagerTests::testFreezeUnfreeze()
void TimeManagerTests::testTimeZones() void TimeManagerTests::testTimeZones()
{ {
auto timeManager = globals->get_subsystem<TimeManager>();
auto vabb = fgFindAirportID("VABB"); auto vabb = fgFindAirportID("VABB");
FGTestApi::setPositionAndStabilise(vabb->geod()); FGTestApi::setPositionAndStabilise(vabb->geod());
auto timeManager = new TimeManager;
// set standard values // set standard values
fgSetBool("/sim/freeze", false); fgSetBool("/sim/freeze", false);
fgSetBool("/sim/sceneryloaded", true); fgSetBool("/sim/sceneryloaded", true);
fgSetDouble("/sim/model-hz", 120.0); fgSetDouble("/sim/model-hz", 120.0);
timeManager->bind();
timeManager->init();
timeManager->postinit(); timeManager->postinit();
// fake Unix time by setting this; it will then // fake Unix time by setting this; it will then
@ -172,12 +168,11 @@ void TimeManagerTests::testTimeZones()
void TimeManagerTests::testETCTimeZones() void TimeManagerTests::testETCTimeZones()
{ {
auto timeManager = globals->get_subsystem<TimeManager>();
auto phto = fgFindAirportID("PHTO"); auto phto = fgFindAirportID("PHTO");
FGTestApi::setPositionAndStabilise(phto->geod()); FGTestApi::setPositionAndStabilise(phto->geod());
auto timeManager = new TimeManager;
timeManager->bind();
timeManager->init();
timeManager->postinit(); timeManager->postinit();
// fake Unix time by setting this; it will then // fake Unix time by setting this; it will then
@ -185,8 +180,6 @@ void TimeManagerTests::testETCTimeZones()
const auto testDate = 314611200L; const auto testDate = 314611200L;
fgSetInt("/sim/time/cur-time-override", testDate); fgSetInt("/sim/time/cur-time-override", testDate);
globals->add_subsystem("time", timeManager, SGSubsystemMgr::INIT);
FGTestApi::setPositionAndStabilise(phto->geod()); FGTestApi::setPositionAndStabilise(phto->geod());
timeManager->reposition(); timeManager->reposition();
timeManager->update(0.0); timeManager->update(0.0);
@ -219,15 +212,13 @@ void TimeManagerTests::testSpecifyTimeOffset()
// to define sun position // to define sun position
return; return;
auto timeManager = new TimeManager; auto timeManager = globals->get_subsystem<TimeManager>();
// set standard values // set standard values
fgSetBool("/sim/freeze", false); fgSetBool("/sim/freeze", false);
fgSetBool("/sim/sceneryloaded", true); fgSetBool("/sim/sceneryloaded", true);
fgSetDouble("/sim/model-hz", 120.0); fgSetDouble("/sim/model-hz", 120.0);
timeManager->bind();
timeManager->init();
timeManager->postinit(); timeManager->postinit();
const auto testDate = 314611200L; const auto testDate = 314611200L;