| 1 | /* |
| 2 | * Copyright (C) 2019 James Turner |
| 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_HOLD_CTL_UNIT_TESTS_HXX |
| 22 | #define _FG_HOLD_CTL_UNIT_TESTS_HXX |
| 23 | |
| 24 | |
| 25 | #include <cppunit/extensions/HelperMacros.h> |
| 26 | #include <cppunit/TestFixture.h> |
| 27 | |
| 28 | #include <memory> |
| 29 | |
| 30 | #include <simgear/props/props.hxx> |
| 31 | |
| 32 | class SGGeod; |
| 33 | class GPS; |
| 34 | |
| 35 | // The flight plan unit tests. |
| 36 | class HoldControllerTests : public CppUnit::TestFixture |
| 37 | { |
| 38 | // Set up the test suite. |
| 39 | CPPUNIT_TEST_SUITE(HoldControllerTests); |
| 40 | CPPUNIT_TEST(testHoldEntryDirect); |
| 41 | CPPUNIT_TEST(testHoldEntryTeardrop); |
| 42 | CPPUNIT_TEST(testHoldEntryParallel); |
| 43 | CPPUNIT_TEST(testLeftHoldEntryDirect); |
| 44 | CPPUNIT_TEST(testLeftHoldEntryTeardrop); |
| 45 | CPPUNIT_TEST(testLeftHoldEntryParallel); |
| 46 | CPPUNIT_TEST(testHoldNotEntered); |
| 47 | CPPUNIT_TEST(testHoldEntryOffCourse); |
| 48 | |
| 49 | CPPUNIT_TEST_SUITE_END(); |
| 50 | |
| 51 | void setPositionAndStabilise(const SGGeod& g); |
| 52 | |
| 53 | GPS* setupStandardGPS(SGPropertyNode_ptr config = {}, |
| 54 | const std::string name = "gps", const int index = 0); |
| 55 | void setupRouteManager(); |
| 56 | |
| 57 | public: |
| 58 | // Set up function for each test. |
| 59 | void setUp(); |
| 60 | |
| 61 | // Clean up after each test. |
| 62 | void tearDown(); |
| 63 | |
| 64 | // The tests. |
| 65 | void testHoldEntryDirect(); |
| 66 | void testHoldEntryTeardrop(); |
| 67 | void testHoldEntryParallel(); |
| 68 | void testLeftHoldEntryDirect(); |
| 69 | void testLeftHoldEntryTeardrop(); |
| 70 | void testLeftHoldEntryParallel(); |
| 71 | void testHoldNotEntered(); |
| 72 | void testHoldEntryOffCourse(); |
| 73 | private: |
| 74 | GPS* m_gps = nullptr; |
| 75 | SGPropertyNode_ptr m_gpsNode; |
| 76 | }; |
| 77 | |
| 78 | #endif // _FG_HOLD_CTL_UNIT_TESTS_HXX |