From 870dbc04f5d5ca934a923eba8818c0837e70b941 Mon Sep 17 00:00:00 2001 From: James Turner Date: Wed, 21 Jul 2021 10:59:08 +0100 Subject: [PATCH] Test infrastrucutre tweaks --- test_suite/FGTestApi/testGlobals.cxx | 1 + .../unit_tests/AI/test_AIFlightPlan.cxx | 8 +++---- test_suite/unit_tests/AI/test_groundnet.cxx | 2 +- .../unit_tests/Airports/test_airport.cxx | 7 +++--- .../unit_tests/Main/test_timeManager.cxx | 23 ++++++------------- 5 files changed, 17 insertions(+), 24 deletions(-) diff --git a/test_suite/FGTestApi/testGlobals.cxx b/test_suite/FGTestApi/testGlobals.cxx index 44a8c26ab..dbe0003b6 100644 --- a/test_suite/FGTestApi/testGlobals.cxx +++ b/test_suite/FGTestApi/testGlobals.cxx @@ -70,6 +70,7 @@ void initTestGlobals(const std::string& testName) fgSetDefaults(); auto t = globals->add_new_subsystem(SGSubsystemMgr::INIT); + t->bind(); t->init(); // establish mag-var data /** diff --git a/test_suite/unit_tests/AI/test_AIFlightPlan.cxx b/test_suite/unit_tests/AI/test_AIFlightPlan.cxx index 2995a906c..232332cb4 100644 --- a/test_suite/unit_tests/AI/test_AIFlightPlan.cxx +++ b/test_suite/unit_tests/AI/test_AIFlightPlan.cxx @@ -293,15 +293,15 @@ void AIFlightPlanTests::testAIFlightPlanLoadXML() onGroundWP - - + 57 + 3 10 1 someWP - - + 57 + 4 200 8000 diff --git a/test_suite/unit_tests/AI/test_groundnet.cxx b/test_suite/unit_tests/AI/test_groundnet.cxx index d5ae731cc..cab52bb61 100644 --- a/test_suite/unit_tests/AI/test_groundnet.cxx +++ b/test_suite/unit_tests/AI/test_groundnet.cxx @@ -94,7 +94,7 @@ void GroundnetTests::testShortestRoute() FGTaxiNodeRef end = network->findNearestNodeOnRunway(runway->threshold()); FGTaxiRoute route = network->findShortestRoute(startParking, end); CPPUNIT_ASSERT_EQUAL(true, network->exists()); - CPPUNIT_ASSERT_EQUAL(25, route.size()); + CPPUNIT_ASSERT_EQUAL(29, route.size()); } /** diff --git a/test_suite/unit_tests/Airports/test_airport.cxx b/test_suite/unit_tests/Airports/test_airport.cxx index 111483a56..d31d321f4 100644 --- a/test_suite/unit_tests/Airports/test_airport.cxx +++ b/test_suite/unit_tests/Airports/test_airport.cxx @@ -51,15 +51,16 @@ ///////////////////////////////////////////////////////////////////////////// // Set up function for each test. -void AirportTests::setUp() { - FGTestApi::setUp::initTestGlobals("timeManager"); - FGTestApi::setUp::initTestGlobals("Traffic"); +void AirportTests::setUp() +{ + FGTestApi::setUp::initTestGlobals("Airports"); FGTestApi::setUp::initNavDataCache(); } // Clean up after each test. void AirportTests::tearDown() { + FGTestApi::tearDown::shutdownTestGlobals(); } /** diff --git a/test_suite/unit_tests/Main/test_timeManager.cxx b/test_suite/unit_tests/Main/test_timeManager.cxx index ee9f38637..34d4124d6 100644 --- a/test_suite/unit_tests/Main/test_timeManager.cxx +++ b/test_suite/unit_tests/Main/test_timeManager.cxx @@ -54,7 +54,7 @@ void TimeManagerTests::tearDown() void TimeManagerTests::testBasic() { - auto timeManager = new TimeManager; + auto timeManager = globals->get_subsystem(); // set standard values fgSetBool("/sim/freeze", false); @@ -82,15 +82,13 @@ void TimeManagerTests::testBasic() void TimeManagerTests::testFreezeUnfreeze() { - auto timeManager = new TimeManager; + auto timeManager = globals->get_subsystem(); // set standard values fgSetBool("/sim/freeze/clock", false); fgSetBool("/sim/sceneryloaded", true); fgSetDouble("/sim/model-hz", 120.0); - timeManager->bind(); - timeManager->init(); timeManager->postinit(); double simDt, realDt; @@ -122,19 +120,17 @@ void TimeManagerTests::testFreezeUnfreeze() void TimeManagerTests::testTimeZones() { + auto timeManager = globals->get_subsystem(); + auto vabb = fgFindAirportID("VABB"); FGTestApi::setPositionAndStabilise(vabb->geod()); - auto timeManager = new TimeManager; - // set standard values fgSetBool("/sim/freeze", false); fgSetBool("/sim/sceneryloaded", true); fgSetDouble("/sim/model-hz", 120.0); - timeManager->bind(); - timeManager->init(); timeManager->postinit(); // fake Unix time by setting this; it will then @@ -172,12 +168,11 @@ void TimeManagerTests::testTimeZones() void TimeManagerTests::testETCTimeZones() { + auto timeManager = globals->get_subsystem(); + auto phto = fgFindAirportID("PHTO"); FGTestApi::setPositionAndStabilise(phto->geod()); - auto timeManager = new TimeManager; - timeManager->bind(); - timeManager->init(); timeManager->postinit(); // fake Unix time by setting this; it will then @@ -185,8 +180,6 @@ void TimeManagerTests::testETCTimeZones() const auto testDate = 314611200L; fgSetInt("/sim/time/cur-time-override", testDate); - globals->add_subsystem("time", timeManager, SGSubsystemMgr::INIT); - FGTestApi::setPositionAndStabilise(phto->geod()); timeManager->reposition(); timeManager->update(0.0); @@ -219,15 +212,13 @@ void TimeManagerTests::testSpecifyTimeOffset() // to define sun position return; - auto timeManager = new TimeManager; + auto timeManager = globals->get_subsystem(); // set standard values fgSetBool("/sim/freeze", false); fgSetBool("/sim/sceneryloaded", true); fgSetDouble("/sim/model-hz", 120.0); - timeManager->bind(); - timeManager->init(); timeManager->postinit(); const auto testDate = 314611200L;