diff --git a/src/Airports/airport.hxx b/src/Airports/airport.hxx index 160463b8b..2235ef8b7 100644 --- a/src/Airports/airport.hxx +++ b/src/Airports/airport.hxx @@ -322,7 +322,8 @@ class FGAirport : public FGPositioned // helper to allow testing without needing a full Airports hierarchy // only for use by the test-suite, not available outside of it. void testSuiteInjectGroundnetXML(const SGPath& path); - + + void testSuiteInjectProceduresXML(const SGPath& path); private: static flightgear::AirportCache airportCache; diff --git a/test_suite/FGTestApi/testApis.cxx b/test_suite/FGTestApi/testApis.cxx index 44cec3e0e..3056935d7 100644 --- a/test_suite/FGTestApi/testApis.cxx +++ b/test_suite/FGTestApi/testApis.cxx @@ -6,6 +6,7 @@ #include #include #include +#include void FGAirport::testSuiteInjectGroundnetXML(const SGPath& path) { @@ -14,3 +15,16 @@ void FGAirport::testSuiteInjectGroundnetXML(const SGPath& path) _groundNetwork->init(); } +void FGAirport::testSuiteInjectProceduresXML(const SGPath& path) +{ + if (mProceduresLoaded) { + SG_LOG(SG_GENERAL, SG_ALERT, "Procedures already loaded for" << ident()); + mSIDs.clear(); + mSTARs.clear(); + mApproaches.clear(); + } + + mProceduresLoaded = true; + flightgear::RouteBase::loadAirportProcedures(path, const_cast(this)); +} + diff --git a/test_suite/test_data/EDTY.procedures.xml b/test_suite/test_data/EDTY.procedures.xml new file mode 100644 index 000000000..2ca13613c --- /dev/null +++ b/test_suite/test_data/EDTY.procedures.xml @@ -0,0 +1,98 @@ + + + CF28 + Normal + 49.085211 + 10.104772 + 0 + 5000 + 0 + above + Fly-by + 25 + Auto + + + ESUVA + Normal + 49.087931 + 10.079558 + 0 + 5000 + 0 + at + Fly-by + 25 + Auto + + + RW28 + Runway + 49.117467 + 9.792336 + 0 + 1363 + 0 + at + Fly-by + 25 + Auto + + + TY021 + Normal + 49.131786 + 9.650253 + 0 + 4000 + 0 + above + Fly-over + 25 + Auto + + + DKB + Normal + 49.142753 + 10.238306 + 0 + 5000 + 0 + at + Fly-by + 25 + Right + + + + DKB + Normal + 49.142753 + 10.238306 + 0 + 0 + 0 + at + Fly-by + 25 + Auto + + + DKB + DmeIntc + 49.142753 + 10.238306 + 0 + 5000 + 0 + above + 0 + 214 + Fly-by + 25 + 4.0 + Auto + + + diff --git a/test_suite/unit_tests/Navaids/test_flightplan.cxx b/test_suite/unit_tests/Navaids/test_flightplan.cxx index 5695c9b48..d193a7751 100644 --- a/test_suite/unit_tests/Navaids/test_flightplan.cxx +++ b/test_suite/unit_tests/Navaids/test_flightplan.cxx @@ -1,3 +1,25 @@ +/* + * Copyright (C) 2020 James Turner + * + * This file is part of the program FlightGear. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "config.h" + + #include "test_flightplan.hxx" #include @@ -1103,3 +1125,26 @@ void FlightplanTests::testCloningProcedures() { CPPUNIT_ASSERT_EQUAL(fp2->star()->ident(), "EEL1A"s); CPPUNIT_ASSERT_EQUAL(fp2->starTransition()->ident(), "BEDUM"s); } + + +void FlightplanTests::testBug2616() +{ + auto edty = FGAirport::findByIdent("EDTY"s); + edty->testSuiteInjectProceduresXML(SGPath::fromUtf8(FG_TEST_SUITE_DATA) / "EDTY.procedures.xml"); + + auto ils28Approach = edty->findApproachWithIdent("ILS28"s); + CPPUNIT_ASSERT(ils28Approach); + + FlightPlanRef fp1 = makeTestFP("EDDS"s, "25"s, "EDTY"s, "28"s, + ""s); + + + + fp1->setApproach(ils28Approach); + + CPPUNIT_ASSERT(fp1->destinationRunway()->ident() == "28"s); + CPPUNIT_ASSERT(fp1->approach()->ident() == "ILS28"s); + + fp1->activate(); + CPPUNIT_ASSERT(fp1->isActive()); +} diff --git a/test_suite/unit_tests/Navaids/test_flightplan.hxx b/test_suite/unit_tests/Navaids/test_flightplan.hxx index f9db5f38a..ef0d4989b 100644 --- a/test_suite/unit_tests/Navaids/test_flightplan.hxx +++ b/test_suite/unit_tests/Navaids/test_flightplan.hxx @@ -53,7 +53,8 @@ class FlightplanTests : public CppUnit::TestFixture CPPUNIT_TEST(testCloningBasic); CPPUNIT_TEST(testCloningFGFP); CPPUNIT_TEST(testCloningProcedures); - + CPPUNIT_TEST(testBug2616); + // CPPUNIT_TEST(testParseICAORoute); // CPPUNIT_TEST(testParseICANLowLevelRoute); CPPUNIT_TEST_SUITE_END(); @@ -90,6 +91,7 @@ public: void testCloningBasic(); void testCloningFGFP(); void testCloningProcedures(); + void testBug2616(); }; #endif // FG_FLIGHTPLAN_UNIT_TESTS_HXX diff --git a/test_suite/unit_tests/Navaids/test_routeManager.cxx b/test_suite/unit_tests/Navaids/test_routeManager.cxx index eb511c171..f4f099aa7 100644 --- a/test_suite/unit_tests/Navaids/test_routeManager.cxx +++ b/test_suite/unit_tests/Navaids/test_routeManager.cxx @@ -1,3 +1,5 @@ +#include "config.h" + #include "test_routeManager.hxx" #include @@ -950,3 +952,29 @@ void RouteManagerTests::testCommandAPI() auto d = SGGeodesy::distanceNm(waldaVOR->geod(), waldaWpt->position()); CPPUNIT_ASSERT_DOUBLES_EQUAL(10.0, d, 0.1); } + +void RouteManagerTests::testRMBug2616() +{ + auto edty = FGAirport::findByIdent("EDTY"s); + edty->testSuiteInjectProceduresXML(SGPath::fromUtf8(FG_TEST_SUITE_DATA) / "EDTY.procedures.xml"); + + auto ils28Approach = edty->findApproachWithIdent("ILS28"s); + CPPUNIT_ASSERT(ils28Approach); + + auto rm = globals->get_subsystem(); + auto f = rm->flightPlan(); + f->clearLegs(); + + auto edds = FGAirport::findByIdent("EDDS"); + f->setDeparture(edds->getRunwayByIdent("25")); + f->setDestination(edty->getRunwayByIdent("28")); + f->setApproach(ils28Approach); + + CPPUNIT_ASSERT(f->destinationRunway()->ident() == "28"s); + CPPUNIT_ASSERT(f->approach()->ident() == "ILS28"s); + + + rm->activate(); + CPPUNIT_ASSERT(f->isActive()); +} + diff --git a/test_suite/unit_tests/Navaids/test_routeManager.hxx b/test_suite/unit_tests/Navaids/test_routeManager.hxx index efcd64629..2f3442e0b 100644 --- a/test_suite/unit_tests/Navaids/test_routeManager.hxx +++ b/test_suite/unit_tests/Navaids/test_routeManager.hxx @@ -46,6 +46,7 @@ class RouteManagerTests : public CppUnit::TestFixture CPPUNIT_TEST(testRouteWithApproachProcedures); CPPUNIT_TEST(testsSelectNavaid); CPPUNIT_TEST(testCommandAPI); + CPPUNIT_TEST(testRMBug2616); CPPUNIT_TEST(testsSelectWaypoint); CPPUNIT_TEST_SUITE_END(); @@ -76,7 +77,8 @@ public: void testsSelectNavaid(); void testCommandAPI(); void testsSelectWaypoint(); - + void testRMBug2616(); + private: GPS* m_gps = nullptr; };