Add tests cases around bug 2616
Can't reproduce this, but capturing in a unit-test just to make sure. SF-Ticket: https://sourceforge.net/p/flightgear/codetickets/2616/
This commit is contained in:
parent
985abe8d43
commit
45d969f319
7 changed files with 193 additions and 3 deletions
|
@ -323,6 +323,7 @@ class FGAirport : public FGPositioned
|
|||
// 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;
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include <Airports/groundnetwork.hxx>
|
||||
#include <Airports/airport.hxx>
|
||||
#include <Airports/xmlloader.hxx>
|
||||
#include <Navaids/procedure.hxx>
|
||||
|
||||
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<FGAirport*>(this));
|
||||
}
|
||||
|
||||
|
|
98
test_suite/test_data/EDTY.procedures.xml
Normal file
98
test_suite/test_data/EDTY.procedures.xml
Normal file
|
@ -0,0 +1,98 @@
|
|||
<Approach Name="ILS28">
|
||||
<App_Waypoint ID="1">
|
||||
<Name>CF28</Name>
|
||||
<Type>Normal</Type>
|
||||
<Latitude>49.085211</Latitude>
|
||||
<Longitude>10.104772</Longitude>
|
||||
<Speed>0</Speed>
|
||||
<Altitude>5000</Altitude>
|
||||
<AltitudeCons>0</AltitudeCons>
|
||||
<AltitudeRestriction>above</AltitudeRestriction>
|
||||
<Flytype>Fly-by</Flytype>
|
||||
<BankLimit>25</BankLimit>
|
||||
<Sp_Turn>Auto</Sp_Turn>
|
||||
</App_Waypoint>
|
||||
<App_Waypoint ID="2">
|
||||
<Name>ESUVA</Name>
|
||||
<Type>Normal</Type>
|
||||
<Latitude>49.087931</Latitude>
|
||||
<Longitude>10.079558</Longitude>
|
||||
<Speed>0</Speed>
|
||||
<Altitude>5000</Altitude>
|
||||
<AltitudeCons>0</AltitudeCons>
|
||||
<AltitudeRestriction>at</AltitudeRestriction>
|
||||
<Flytype>Fly-by</Flytype>
|
||||
<BankLimit>25</BankLimit>
|
||||
<Sp_Turn>Auto</Sp_Turn>
|
||||
</App_Waypoint>
|
||||
<App_Waypoint ID="3">
|
||||
<Name>RW28</Name>
|
||||
<Type>Runway</Type>
|
||||
<Latitude>49.117467</Latitude>
|
||||
<Longitude>9.792336</Longitude>
|
||||
<Speed>0</Speed>
|
||||
<Altitude>1363</Altitude>
|
||||
<AltitudeCons>0</AltitudeCons>
|
||||
<AltitudeRestriction>at</AltitudeRestriction>
|
||||
<Flytype>Fly-by</Flytype>
|
||||
<BankLimit>25</BankLimit>
|
||||
<Sp_Turn>Auto</Sp_Turn>
|
||||
</App_Waypoint>
|
||||
<App_Waypoint ID="4">
|
||||
<Name>TY021</Name>
|
||||
<Type>Normal</Type>
|
||||
<Latitude>49.131786</Latitude>
|
||||
<Longitude>9.650253</Longitude>
|
||||
<Speed>0</Speed>
|
||||
<Altitude>4000</Altitude>
|
||||
<AltitudeCons>0</AltitudeCons>
|
||||
<AltitudeRestriction>above</AltitudeRestriction>
|
||||
<Flytype>Fly-over</Flytype>
|
||||
<BankLimit>25</BankLimit>
|
||||
<Sp_Turn>Auto</Sp_Turn>
|
||||
</App_Waypoint>
|
||||
<App_Waypoint ID="5">
|
||||
<Name>DKB</Name>
|
||||
<Type>Normal</Type>
|
||||
<Latitude>49.142753</Latitude>
|
||||
<Longitude>10.238306</Longitude>
|
||||
<Speed>0</Speed>
|
||||
<Altitude>5000</Altitude>
|
||||
<AltitudeCons>0</AltitudeCons>
|
||||
<AltitudeRestriction>at</AltitudeRestriction>
|
||||
<Flytype>Fly-by</Flytype>
|
||||
<BankLimit>25</BankLimit>
|
||||
<Sp_Turn>Right</Sp_Turn>
|
||||
</App_Waypoint>
|
||||
<App_Transition Name="DKB">
|
||||
<AppTr_Waypoint ID="1">
|
||||
<Name>DKB</Name>
|
||||
<Type>Normal</Type>
|
||||
<Latitude>49.142753</Latitude>
|
||||
<Longitude>10.238306</Longitude>
|
||||
<Speed>0</Speed>
|
||||
<Altitude>0</Altitude>
|
||||
<AltitudeCons>0</AltitudeCons>
|
||||
<AltitudeRestriction>at</AltitudeRestriction>
|
||||
<Flytype>Fly-by</Flytype>
|
||||
<BankLimit>25</BankLimit>
|
||||
<Sp_Turn>Auto</Sp_Turn>
|
||||
</AppTr_Waypoint>
|
||||
<AppTr_Waypoint ID="2">
|
||||
<Name>DKB</Name>
|
||||
<Type>DmeIntc</Type>
|
||||
<Latitude>49.142753</Latitude>
|
||||
<Longitude>10.238306</Longitude>
|
||||
<Speed>0</Speed>
|
||||
<Altitude>5000</Altitude>
|
||||
<AltitudeCons>0</AltitudeCons>
|
||||
<AltitudeRestriction>above</AltitudeRestriction>
|
||||
<Hdg_Crs>0</Hdg_Crs>
|
||||
<Hdg_Crs_value>214</Hdg_Crs_value>
|
||||
<Flytype>Fly-by</Flytype>
|
||||
<BankLimit>25</BankLimit>
|
||||
<DMEtoIntercept>4.0</DMEtoIntercept>
|
||||
<Sp_Turn>Auto</Sp_Turn>
|
||||
</AppTr_Waypoint>
|
||||
</App_Transition>
|
||||
</Approach>
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
|
||||
#include "test_flightplan.hxx"
|
||||
|
||||
#include <algorithm>
|
||||
|
@ -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());
|
||||
}
|
||||
|
|
|
@ -53,6 +53,7 @@ class FlightplanTests : public CppUnit::TestFixture
|
|||
CPPUNIT_TEST(testCloningBasic);
|
||||
CPPUNIT_TEST(testCloningFGFP);
|
||||
CPPUNIT_TEST(testCloningProcedures);
|
||||
CPPUNIT_TEST(testBug2616);
|
||||
|
||||
// CPPUNIT_TEST(testParseICAORoute);
|
||||
// CPPUNIT_TEST(testParseICANLowLevelRoute);
|
||||
|
@ -90,6 +91,7 @@ public:
|
|||
void testCloningBasic();
|
||||
void testCloningFGFP();
|
||||
void testCloningProcedures();
|
||||
void testBug2616();
|
||||
};
|
||||
|
||||
#endif // FG_FLIGHTPLAN_UNIT_TESTS_HXX
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#include "config.h"
|
||||
|
||||
#include "test_routeManager.hxx"
|
||||
|
||||
#include <memory>
|
||||
|
@ -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<FGRouteMgr>();
|
||||
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());
|
||||
}
|
||||
|
||||
|
|
|
@ -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,6 +77,7 @@ public:
|
|||
void testsSelectNavaid();
|
||||
void testCommandAPI();
|
||||
void testsSelectWaypoint();
|
||||
void testRMBug2616();
|
||||
|
||||
private:
|
||||
GPS* m_gps = nullptr;
|
||||
|
|
Loading…
Reference in a new issue