1
0
Fork 0

Add test case for LARPA2F procedure at Barcelona. Potential bug with (500) waypoint. Also, the test pilot decided to fly off on runway heading - my error, or his?

This commit is contained in:
legoboyvdlp R 2020-05-09 20:09:58 +01:00 committed by James Turner
parent bdf969e802
commit 67d5757133
2 changed files with 65 additions and 2 deletions

View file

@ -93,8 +93,8 @@ public:
} }
} }
} }
void arrivalChanged() override void arrivalChanged() override
{ {
// mimic the default delegate, inserting the STAR waypoints // mimic the default delegate, inserting the STAR waypoints
@ -569,6 +569,7 @@ void RNAVProcedureTests::testTransitionsSID()
CPPUNIT_ASSERT_EQUAL(7, fp->numLegs()); CPPUNIT_ASSERT_EQUAL(7, fp->numLegs());
auto wp = fp->legAtIndex(6); auto wp = fp->legAtIndex(6);
CPPUNIT_ASSERT_EQUAL(std::string{"CANDR"}, wp->waypoint()->ident()); CPPUNIT_ASSERT_EQUAL(std::string{"CANDR"}, wp->waypoint()->ident());
CPPUNIT_ASSERT(rm->activate());
} }
void RNAVProcedureTests::testTransitionsSTAR() void RNAVProcedureTests::testTransitionsSTAR()
@ -594,4 +595,63 @@ void RNAVProcedureTests::testTransitionsSTAR()
CPPUNIT_ASSERT_EQUAL(8, fp->numLegs()); CPPUNIT_ASSERT_EQUAL(8, fp->numLegs());
auto wp = fp->legAtIndex(1); auto wp = fp->legAtIndex(1);
CPPUNIT_ASSERT_EQUAL(std::string{"SEY"}, wp->waypoint()->ident()); CPPUNIT_ASSERT_EQUAL(std::string{"SEY"}, wp->waypoint()->ident());
CPPUNIT_ASSERT(rm->activate());
}
void RNAVProcedureTests::testLEBL_LARP2F()
{
auto lebl = FGAirport::findByIdent("LEBL");
auto sid = lebl->findSIDWithIdent("LARP2F.25L");
// procedures not loaded, abandon test
if (!sid)
return;
FGTestApi::setUp::logPositionToKML("procedure_LEBL-LARP2F");
auto rm = globals->get_subsystem<FGRouteMgr>();
auto fp = new FlightPlan;
auto testDelegate = new TestFPDelegate;
testDelegate->thePlan = fp;
fp->addDelegate(testDelegate);
rm->setFlightPlan(fp);
FGTestApi::setUp::populateFPWithNasal(fp, "LEBL", "25L", "LEIB", "06", "");
fp->setSID(sid);
// I don't know if this should pass or not!
// If its a bug, wrap next line in CPPUNIT_ASSERT_ASSERTION_FAIL
CPPUNIT_ASSERT_EQUAL(fp->legAtIndex(1)->waypoint()->position(), SGGeod::fromDeg(0, 0));
CPPUNIT_ASSERT_EQUAL(std::string{"LARPA"}, fp->legAtIndex(8)->waypoint()->ident());
double d = fp->legAtIndex(8)->distanceAlongRoute();
CPPUNIT_ASSERT_DOUBLES_EQUAL(47.7, d, 1.0); // ensure the route didn't blow up
FGTestApi::writeFlightPlanToKML(fp);
CPPUNIT_ASSERT(rm->activate());
FGRunwayRef departureRunway = fp->departureRunway();
setupStandardGPS();
FGTestApi::setPositionAndStabilise(departureRunway->threshold());
m_gpsNode->setStringValue("command", "leg");
auto pilot = SGSharedPtr<FGTestApi::TestPilot>(new FGTestApi::TestPilot);
pilot->resetAtPosition(globals->get_aircraft_position());
CPPUNIT_ASSERT_DOUBLES_EQUAL(departureRunway->headingDeg(), m_gpsNode->getDoubleValue("wp/leg-true-course-deg"), 0.5);
pilot->setCourseTrue(m_gpsNode->getDoubleValue("wp/leg-true-course-deg"));
pilot->setSpeedKts(220);
pilot->flyGPSCourse(m_gps);
FGTestApi::runForTime(20.0);
bool ok = FGTestApi::runForTimeWithCheck(180.0, [fp] () {
if (fp->currentIndex() == 1) {
return true;
}
return false;
});
CPPUNIT_ASSERT(ok);
FGTestApi::runForTime(180.0);
CPPUNIT_ASSERT_DOUBLES_EQUAL(199, m_gpsNode->getDoubleValue("wp/leg-true-course-deg"), 0.5);
} }

View file

@ -44,6 +44,8 @@ class RNAVProcedureTests : public CppUnit::TestFixture
CPPUNIT_TEST(testLFKC_AJO1R); CPPUNIT_TEST(testLFKC_AJO1R);
CPPUNIT_TEST(testTransitionsSID); CPPUNIT_TEST(testTransitionsSID);
CPPUNIT_TEST(testTransitionsSTAR); CPPUNIT_TEST(testTransitionsSTAR);
CPPUNIT_TEST(testLEBL_LARP2F);
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
void setPositionAndStabilise(const SGGeod& g); void setPositionAndStabilise(const SGGeod& g);
@ -68,6 +70,7 @@ public:
void testLFKC_AJO1R(); void testLFKC_AJO1R();
void testTransitionsSID(); void testTransitionsSID();
void testTransitionsSTAR(); void testTransitionsSTAR();
void testLEBL_LARP2F();
private: private:
GPS* m_gps = nullptr; GPS* m_gps = nullptr;
SGPropertyNode_ptr m_gpsNode; SGPropertyNode_ptr m_gpsNode;