From e8952b6c0f82bacafdd758d7358e605cfdb7e0d8 Mon Sep 17 00:00:00 2001 From: James Turner Date: Sun, 25 Apr 2021 18:57:36 +0100 Subject: [PATCH] Update tests for revised Subsystem API --- src/Viewer/viewmgr.cxx | 6 +----- test_suite/unit_tests/AI/test_AIManager.cxx | 2 +- test_suite/unit_tests/AI/test_submodels.cxx | 4 ++-- test_suite/unit_tests/AI/test_traffic.cxx | 10 +++++----- test_suite/unit_tests/Autopilot/testDigitalFilter.cxx | 2 +- test_suite/unit_tests/Autopilot/testPidController.cxx | 2 +- .../unit_tests/Instrumentation/test_commRadio.cxx | 2 +- test_suite/unit_tests/Instrumentation/test_gps.cxx | 7 +++++-- .../Instrumentation/test_hold_controller.cxx | 7 +++++-- .../Instrumentation/test_rnav_procedures.cxx | 7 +++++-- .../unit_tests/Instrumentation/test_transponder.cxx | 2 +- test_suite/unit_tests/Main/test_posinit.cxx | 10 +++++----- test_suite/unit_tests/Main/test_timeManager.cxx | 2 +- test_suite/unit_tests/Navaids/test_fpNasal.cxx | 2 +- test_suite/unit_tests/Navaids/test_routeManager.cxx | 10 +++++----- test_suite/unit_tests/general/test_Views.cxx | 8 ++++---- 16 files changed, 44 insertions(+), 39 deletions(-) diff --git a/src/Viewer/viewmgr.cxx b/src/Viewer/viewmgr.cxx index f39018bef..9cde5c426 100644 --- a/src/Viewer/viewmgr.cxx +++ b/src/Viewer/viewmgr.cxx @@ -177,17 +177,13 @@ FGViewMgr::update (double dt) // update the camera now osg::ref_ptr cameraGroup = flightgear::CameraGroup::getDefault(); - if (!cameraGroup) { - // attempting to diagnose the cause of FLIGHTGEAR-H9F - throw sg_exception("FGViewMgr::update: no camera group exists"); - } - if (cameraGroup) { cameraGroup->setCameraParameters(currentView->get_v_fov(), cameraGroup->getMasterAspectRatio()); cameraGroup->update(toOsg(currentView->getViewPosition()), toOsg(currentView->getViewOrientation())); } + SviewUpdate(dt); } diff --git a/test_suite/unit_tests/AI/test_AIManager.cxx b/test_suite/unit_tests/AI/test_AIManager.cxx index 1b0003532..7c0cc2dbe 100644 --- a/test_suite/unit_tests/AI/test_AIManager.cxx +++ b/test_suite/unit_tests/AI/test_AIManager.cxx @@ -45,7 +45,7 @@ void AIManagerTests::setUp() FGTestApi::setUp::initTestGlobals("AI"); FGTestApi::setUp::initNavDataCache(); - globals->add_new_subsystem(); + globals->add_new_subsystem(SGSubsystemMgr::GENERAL); auto props = globals->get_props(); props->setBoolValue("sim/ai/enabled", true); diff --git a/test_suite/unit_tests/AI/test_submodels.cxx b/test_suite/unit_tests/AI/test_submodels.cxx index 293156b94..80f99e2a2 100644 --- a/test_suite/unit_tests/AI/test_submodels.cxx +++ b/test_suite/unit_tests/AI/test_submodels.cxx @@ -49,8 +49,8 @@ void SubmodelsTests::setUp() props->setBoolValue("sim/ai/enabled", true); props->setStringValue("sim/submodels/path", "Aircraft/Test/submodels.xml"); - globals->add_new_subsystem(); - globals->add_new_subsystem(); + globals->add_new_subsystem(SGSubsystemMgr::GENERAL); + globals->add_new_subsystem(SGSubsystemMgr::GENERAL); globals->get_subsystem_mgr()->bind(); globals->get_subsystem_mgr()->init(); diff --git a/test_suite/unit_tests/AI/test_traffic.cxx b/test_suite/unit_tests/AI/test_traffic.cxx index febe2efe4..28cf52476 100644 --- a/test_suite/unit_tests/AI/test_traffic.cxx +++ b/test_suite/unit_tests/AI/test_traffic.cxx @@ -61,10 +61,10 @@ void TrafficTests::setUp() egph->testSuiteInjectGroundnetXML(SGPath::fromUtf8(FG_TEST_SUITE_DATA) / "EGPH.groundnet.xml"); - globals->add_new_subsystem(); - globals->add_new_subsystem(); - globals->add_new_subsystem(); - globals->add_new_subsystem(); + globals->add_new_subsystem(SGSubsystemMgr::GENERAL); + globals->add_new_subsystem(SGSubsystemMgr::GENERAL); + globals->add_new_subsystem(SGSubsystemMgr::GENERAL); + globals->add_new_subsystem(SGSubsystemMgr::GENERAL); globals->get_subsystem_mgr()->bind(); globals->get_subsystem_mgr()->init(); @@ -135,7 +135,7 @@ void TrafficTests::testTrafficManager() fgSetBool("/sim/traffic-manager/active", true); fgSetBool("/sim/terrasync/ai-data-update-now", false); - auto tfc = globals->add_new_subsystem(); + auto tfc = globals->add_new_subsystem(SGSubsystemMgr::GENERAL); // specify traffic files to read diff --git a/test_suite/unit_tests/Autopilot/testDigitalFilter.cxx b/test_suite/unit_tests/Autopilot/testDigitalFilter.cxx index 203636c79..cc337c12d 100644 --- a/test_suite/unit_tests/Autopilot/testDigitalFilter.cxx +++ b/test_suite/unit_tests/Autopilot/testDigitalFilter.cxx @@ -56,7 +56,7 @@ void DigitalFilterTests::testNoise() auto ap = new FGXMLAutopilot::Autopilot(globals->get_props(), config); - globals->add_subsystem("ap", ap); + globals->add_subsystem("ap", ap, SGSubsystemMgr::FDM); ap->bind(); ap->init(); diff --git a/test_suite/unit_tests/Autopilot/testPidController.cxx b/test_suite/unit_tests/Autopilot/testPidController.cxx index 401cd9bde..25608508c 100644 --- a/test_suite/unit_tests/Autopilot/testPidController.cxx +++ b/test_suite/unit_tests/Autopilot/testPidController.cxx @@ -86,7 +86,7 @@ void PidControllerTests::test() auto ap = new FGXMLAutopilot::Autopilot(globals->get_props(), config); - globals->add_subsystem("ap", ap); + globals->add_subsystem("ap", ap, SGSubsystemMgr::FDM); ap->bind(); ap->init(); diff --git a/test_suite/unit_tests/Instrumentation/test_commRadio.cxx b/test_suite/unit_tests/Instrumentation/test_commRadio.cxx index aef9aa228..587c5798d 100644 --- a/test_suite/unit_tests/Instrumentation/test_commRadio.cxx +++ b/test_suite/unit_tests/Instrumentation/test_commRadio.cxx @@ -51,7 +51,7 @@ SGSubsystemRef CommRadioTests::setupStandardRadio(const std::string& name, int i r->bind(); r->init(); - globals->add_subsystem("comm-radio", r); + globals->add_subsystem("comm-radio", r, SGSubsystemMgr::GENERAL); return r; } diff --git a/test_suite/unit_tests/Instrumentation/test_gps.cxx b/test_suite/unit_tests/Instrumentation/test_gps.cxx index 2d1450ec7..43d0239d7 100644 --- a/test_suite/unit_tests/Instrumentation/test_gps.cxx +++ b/test_suite/unit_tests/Instrumentation/test_gps.cxx @@ -73,7 +73,10 @@ void GPSTests::setUp() { FGTestApi::setUp::initTestGlobals("gps"); FGTestApi::setUp::initNavDataCache(); - + + globals->get_subsystem_mgr()->bind(); + globals->get_subsystem_mgr()->init(); + setupRouteManager(); } @@ -106,7 +109,7 @@ GPS* GPSTests::setupStandardGPS(SGPropertyNode_ptr config, void GPSTests::setupRouteManager() { - auto rm = globals->add_new_subsystem(); + auto rm = globals->add_new_subsystem(SGSubsystemMgr::GENERAL); rm->bind(); rm->init(); rm->postinit(); diff --git a/test_suite/unit_tests/Instrumentation/test_hold_controller.cxx b/test_suite/unit_tests/Instrumentation/test_hold_controller.cxx index 0e78ecce8..f6eb2b0d4 100644 --- a/test_suite/unit_tests/Instrumentation/test_hold_controller.cxx +++ b/test_suite/unit_tests/Instrumentation/test_hold_controller.cxx @@ -72,7 +72,10 @@ void HoldControllerTests::setUp() { FGTestApi::setUp::initTestGlobals("hold-ctl"); FGTestApi::setUp::initNavDataCache(); - + + globals->get_subsystem_mgr()->bind(); + globals->get_subsystem_mgr()->init(); + setupRouteManager(); } @@ -114,7 +117,7 @@ GPS* HoldControllerTests::setupStandardGPS(SGPropertyNode_ptr config, void HoldControllerTests::setupRouteManager() { - auto rm = globals->add_new_subsystem(); + auto rm = globals->add_new_subsystem(SGSubsystemMgr::GENERAL); rm->bind(); rm->init(); rm->postinit(); diff --git a/test_suite/unit_tests/Instrumentation/test_rnav_procedures.cxx b/test_suite/unit_tests/Instrumentation/test_rnav_procedures.cxx index 629c59f2e..1ddfccc57 100644 --- a/test_suite/unit_tests/Instrumentation/test_rnav_procedures.cxx +++ b/test_suite/unit_tests/Instrumentation/test_rnav_procedures.cxx @@ -134,7 +134,10 @@ void RNAVProcedureTests::setUp() { FGTestApi::setUp::initTestGlobals("rnav-procedures"); FGTestApi::setUp::initNavDataCache(); - + + globals->get_subsystem_mgr()->bind(); + globals->get_subsystem_mgr()->init(); + SGPath proceduresPath = SGPath::fromEnv("FG_PROCEDURES_PATH"); if (proceduresPath.exists()) { globals->append_fg_scenery(proceduresPath); @@ -173,7 +176,7 @@ GPS* RNAVProcedureTests::setupStandardGPS(SGPropertyNode_ptr config, void RNAVProcedureTests::setupRouteManager() { - auto rm = globals->add_new_subsystem(); + auto rm = globals->add_new_subsystem(SGSubsystemMgr::GENERAL); rm->bind(); rm->init(); rm->postinit(); diff --git a/test_suite/unit_tests/Instrumentation/test_transponder.cxx b/test_suite/unit_tests/Instrumentation/test_transponder.cxx index 7e5533f7e..042061260 100644 --- a/test_suite/unit_tests/Instrumentation/test_transponder.cxx +++ b/test_suite/unit_tests/Instrumentation/test_transponder.cxx @@ -40,7 +40,7 @@ SGSubsystemRef TransponderTests::setupStandardTransponder(const std::string& nam r->bind(); r->init(); - globals->add_subsystem("transponder", r); + globals->add_subsystem("transponder", r, SGSubsystemMgr::FDM); return r; } diff --git a/test_suite/unit_tests/Main/test_posinit.cxx b/test_suite/unit_tests/Main/test_posinit.cxx index ba7d598d1..b82c62a5a 100644 --- a/test_suite/unit_tests/Main/test_posinit.cxx +++ b/test_suite/unit_tests/Main/test_posinit.cxx @@ -60,11 +60,11 @@ void PosInitTests::setUp() apt->testSuiteInjectGroundnetXML(SGPath::fromUtf8(FG_TEST_SUITE_DATA) / "EDDF.groundnet.xml"); - - globals->add_new_subsystem(); - globals->add_new_subsystem(); - globals->add_new_subsystem(); - globals->add_new_subsystem(); + + globals->add_new_subsystem(SGSubsystemMgr::GENERAL); + globals->add_new_subsystem(SGSubsystemMgr::GENERAL); + globals->add_new_subsystem(SGSubsystemMgr::GENERAL); + globals->add_new_subsystem(SGSubsystemMgr::GENERAL); } diff --git a/test_suite/unit_tests/Main/test_timeManager.cxx b/test_suite/unit_tests/Main/test_timeManager.cxx index 2f309e988..ee9f38637 100644 --- a/test_suite/unit_tests/Main/test_timeManager.cxx +++ b/test_suite/unit_tests/Main/test_timeManager.cxx @@ -185,7 +185,7 @@ void TimeManagerTests::testETCTimeZones() const auto testDate = 314611200L; fgSetInt("/sim/time/cur-time-override", testDate); - globals->add_subsystem("time", timeManager); + globals->add_subsystem("time", timeManager, SGSubsystemMgr::INIT); FGTestApi::setPositionAndStabilise(phto->geod()); timeManager->reposition(); diff --git a/test_suite/unit_tests/Navaids/test_fpNasal.cxx b/test_suite/unit_tests/Navaids/test_fpNasal.cxx index f2cb07fea..0a87eca66 100644 --- a/test_suite/unit_tests/Navaids/test_fpNasal.cxx +++ b/test_suite/unit_tests/Navaids/test_fpNasal.cxx @@ -34,7 +34,7 @@ void FPNasalTests::setUp() } // flightplan() acces needs the route manager - globals->add_new_subsystem(); + globals->add_new_subsystem(SGSubsystemMgr::GENERAL); globals->get_subsystem_mgr()->bind(); globals->get_subsystem_mgr()->init(); diff --git a/test_suite/unit_tests/Navaids/test_routeManager.cxx b/test_suite/unit_tests/Navaids/test_routeManager.cxx index 4e80b39f8..3ae5a2021 100644 --- a/test_suite/unit_tests/Navaids/test_routeManager.cxx +++ b/test_suite/unit_tests/Navaids/test_routeManager.cxx @@ -47,11 +47,11 @@ void RouteManagerTests::setUp() static_haveProcedures = true; globals->append_fg_scenery(proceduresPath); } - - globals->add_new_subsystem(); - -// setup the default GPS, which is needed for waypoint -// sequencing to work + + globals->add_new_subsystem(SGSubsystemMgr::FDM); + + // setup the default GPS, which is needed for waypoint + // sequencing to work SGPropertyNode_ptr configNode(new SGPropertyNode); configNode->setStringValue("name", "gps"); configNode->setIntValue("number", 0); diff --git a/test_suite/unit_tests/general/test_Views.cxx b/test_suite/unit_tests/general/test_Views.cxx index c7f1f199c..932620bfd 100644 --- a/test_suite/unit_tests/general/test_Views.cxx +++ b/test_suite/unit_tests/general/test_Views.cxx @@ -49,7 +49,7 @@ void ViewsTests::tearDown() void ViewsTests::testBasic() { - auto vm = globals->add_new_subsystem(); + auto vm = globals->add_new_subsystem(SGSubsystemMgr::DISPLAY); CPPUNIT_ASSERT_EQUAL(static_cast(nullptr), vm->get_current_view()); @@ -84,9 +84,9 @@ void ViewsTests::testBasic() fgSetInt("/sim/current-view/view-number", 0); - vm->bind(); - vm->init(); - vm->postinit(); + globals->get_subsystem_mgr()->bind(); + globals->get_subsystem_mgr()->init(); + globals->get_subsystem_mgr()->postinit(); auto c = vm->get_current_view(); CPPUNIT_ASSERT(c);