| 1 |
/* |
| 2 |
* Copyright (C) 2018 Edward d'Auvergne |
| 3 |
* |
| 4 |
* This file is part of the program FlightGear. |
| 5 |
* |
| 6 |
* This program is free software: you can redistribute it and/or modify |
| 7 |
* it under the terms of the GNU General Public License as published by |
| 8 |
* the Free Software Foundation, either version 2 of the License, or |
| 9 |
* (at your option) any later version. |
| 10 |
* |
| 11 |
* This program is distributed in the hope that it will be useful, |
| 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 |
* GNU General Public License for more details. |
| 15 |
* |
| 16 |
* You should have received a copy of the GNU General Public License |
| 17 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 18 |
*/ |
| 19 |
|
| 20 |
|
| 21 |
#ifndef _FG_POSINIT_UNIT_TESTS_HXX |
| 22 |
#define _FG_POSINIT_UNIT_TESTS_HXX |
| 23 |
|
| 24 |
|
| 25 |
#include <cppunit/extensions/HelperMacros.h> |
| 26 |
#include <cppunit/TestFixture.h> |
| 27 |
#include "Airports/airport.hxx" |
| 28 |
|
| 29 |
|
| 30 |
// The unit tests of the FGNasalSys subsystem. |
| 31 |
class PosInitTests : public CppUnit::TestFixture |
| 32 |
{ |
| 33 |
// Set up the test suite. |
| 34 |
CPPUNIT_TEST_SUITE(PosInitTests); |
| 35 |
|
| 36 |
// Airport-based tests |
| 37 |
CPPUNIT_TEST(testAirportAltitudeOffsetStartup); |
| 38 |
CPPUNIT_TEST(testAirportAndMetarStartup); |
| 39 |
CPPUNIT_TEST(testAirportAndRunwayStartup); |
| 40 |
CPPUNIT_TEST(testAirportAndAvailableParkingStartup); |
| 41 |
CPPUNIT_TEST(testAirportAndParkingStartup); |
| 42 |
CPPUNIT_TEST(testAirportOnlyStartup); |
| 43 |
CPPUNIT_TEST(testAirportRunwayOffsetAltitudeStartup); |
| 44 |
CPPUNIT_TEST(testAirportRunwayOffsetGlideslopeStartup); |
| 45 |
CPPUNIT_TEST(testDefaultStartup); |
| 46 |
CPPUNIT_TEST(testRepositionAtParking); |
| 47 |
CPPUNIT_TEST(testParkAtOccupied); |
| 48 |
CPPUNIT_TEST(testParkInvalid); |
| 49 |
CPPUNIT_TEST(testAirportRunwayRepositionAirport); |
| 50 |
CPPUNIT_TEST(testParkNoAI); |
| 51 |
|
| 52 |
|
| 53 |
// Navaid tests |
| 54 |
CPPUNIT_TEST(testVOROnlyStartup); |
| 55 |
CPPUNIT_TEST(testVOROffsetAltitudeHeadingStartup); |
| 56 |
CPPUNIT_TEST(testFixOnlyStartup); |
| 57 |
CPPUNIT_TEST(testFixOffsetAltitudeHeadingStartup); |
| 58 |
CPPUNIT_TEST(testNDBOnlyStartup); |
| 59 |
CPPUNIT_TEST(testNDBOffsetAltitudeHeadingStartup); |
| 60 |
|
| 61 |
CPPUNIT_TEST(testLatLonStartup); |
| 62 |
//CPPUNIT_TEST(testLatLonOffsetStartup); This is not yet supported. |
| 63 |
|
| 64 |
// Carrier tests |
| 65 |
// We are not able to test the carrier code thoroughly as it depends |
| 66 |
// heavily on finalizePosition(), which requires that the carrier model |
| 67 |
// itself be loaded into the scenegraph. |
| 68 |
CPPUNIT_TEST(testCarrierStartup); |
| 69 |
|
| 70 |
// Reposition tests |
| 71 |
CPPUNIT_TEST(testAirportRepositionAirport); |
| 72 |
CPPUNIT_TEST(testRepositionAtSameParking); |
| 73 |
CPPUNIT_TEST(testRepositionAtOccupied); |
| 74 |
CPPUNIT_TEST(testRepositionAtInvalid); |
| 75 |
|
| 76 |
// MP tests |
| 77 |
CPPUNIT_TEST(testMPRunwayStart); |
| 78 |
CPPUNIT_TEST(testMPRunwayStartNoGroundnet); |
| 79 |
|
| 80 |
CPPUNIT_TEST_SUITE_END(); |
| 81 |
|
| 82 |
void simulateStartReposition(); |
| 83 |
void simulateFinalizePosition(); |
| 84 |
public: |
| 85 |
// Set up function for each test. |
| 86 |
void setUp(); |
| 87 |
|
| 88 |
// Clean up after each test. |
| 89 |
void tearDown(); |
| 90 |
|
| 91 |
// The tests. |
| 92 |
void testAirportAltitudeOffsetStartup(); |
| 93 |
void testAirportAndMetarStartup(); |
| 94 |
void testAirportAndAvailableParkingStartup(); |
| 95 |
void testAirportAndParkingStartup(); |
| 96 |
void testAirportAndRunwayStartup(); |
| 97 |
void testAirportOnlyStartup(); |
| 98 |
void testAirportRunwayOffsetAltitudeStartup(); |
| 99 |
void testAirportRunwayOffsetGlideslopeStartup(); |
| 100 |
void testDefaultStartup(); |
| 101 |
void testParkAtOccupied(); |
| 102 |
void testParkInvalid(); |
| 103 |
void testParkNoAI(); |
| 104 |
|
| 105 |
// Navaid tests |
| 106 |
void testVOROnlyStartup(); |
| 107 |
void testVOROffsetAltitudeHeadingStartup(); |
| 108 |
void testFixOnlyStartup(); |
| 109 |
void testFixOffsetAltitudeHeadingStartup(); |
| 110 |
void testNDBOnlyStartup(); |
| 111 |
void testNDBOffsetAltitudeHeadingStartup(); |
| 112 |
|
| 113 |
//Lat Lon tests |
| 114 |
void testLatLonStartup(); |
| 115 |
void testLatLonOffsetStartup(); |
| 116 |
|
| 117 |
//Carrier tests |
| 118 |
void testCarrierStartup(); |
| 119 |
|
| 120 |
//Reposition tests |
| 121 |
void testAirportRepositionAirport(); |
| 122 |
void testRepositionAtParking(); |
| 123 |
void testRepositionAtSameParking(); |
| 124 |
void testRepositionAtOccupied(); |
| 125 |
void testRepositionAtInvalid(); |
| 126 |
void testAirportRunwayRepositionAirport(); |
| 127 |
|
| 128 |
// MP tests |
| 129 |
void testMPRunwayStart(); |
| 130 |
void testMPRunwayStartNoGroundnet(); |
| 131 |
private: |
| 132 |
// Helper functions for tests. Return void as they use CPPUNIT_ASSERT |
| 133 |
void checkAlt(float value); |
| 134 |
void checkHeading(float value); |
| 135 |
void checkPosition(SGGeod expectedPos, float delta=1000.0); |
| 136 |
void checkClosestAirport(std::string icao); |
| 137 |
void checkStringProp(std::string property, std::string expected); |
| 138 |
void checkRunway(std::string expected); |
| 139 |
void checkOnGround(); |
| 140 |
void checkInAir(); |
| 141 |
}; |
| 142 |
|
| 143 |
#endif // _FG_POSINIT_UNIT_TESTS_HXX |