SimpleMissionItemTest.h 3.05 KB
Newer Older
1 2
/****************************************************************************
 *
Gus Grubba's avatar
Gus Grubba committed
3
 * (c) 2009-2020 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
4 5 6 7 8 9
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 ****************************************************************************/

10
#pragma once
11

12 13
#include "VisualMissionItemTest.h"
#include "SimpleMissionItem.h"
14 15

/// Unit test for SimpleMissionItem
16
class SimpleMissionItemTest : public VisualMissionItemTest
17 18 19 20 21
{
    Q_OBJECT
    
public:
    SimpleMissionItemTest(void);
Don Gagne's avatar
Don Gagne committed
22 23 24 25

    void init(void) override;
    void cleanup(void) override;

26 27 28 29
private slots:
    void _testSignals(void);
    void _testEditorFacts(void);
    void _testDefaultValues(void);
30 31
    void _testCameraSectionDirty(void);
    void _testSpeedSectionDirty(void);
32 33
    void _testCameraSection(void);
    void _testSpeedSection(void);
34
    void _testAltitudePropogation(void);
35

36
private:
37 38
    enum {
        commandChangedIndex = 0,
39
        altitudeModeChangedIndex,
40 41 42 43 44 45 46 47 48
        friendlyEditAllowedChangedIndex,
        headingDegreesChangedIndex,
        rawEditChangedIndex,
        cameraSectionChangedIndex,
        speedSectionChangedIndex,
        maxSignalIndex,
    };

    enum {
49
        commandChangedMask =                        1 << commandChangedIndex,
50
        altitudeModeChangedMask =                  1 << altitudeModeChangedIndex,
51 52 53 54 55
        friendlyEditAllowedChangedMask =            1 << friendlyEditAllowedChangedIndex,
        headingDegreesChangedMask =                 1 << headingDegreesChangedIndex,
        rawEditChangedMask =                        1 << rawEditChangedIndex,
        cameraSectionChangedMask =                  1 << cameraSectionChangedIndex,
        speedSectionChangedMask =                   1 << speedSectionChangedIndex,
56 57 58 59
    };

    static const size_t cSimpleItemSignals = maxSignalIndex;
    const char*         rgSimpleItemSignals[cSimpleItemSignals];
60 61 62 63 64 65 66 67 68 69 70 71

    typedef struct {
        MAV_CMD        command;
        MAV_FRAME      frame;
    } ItemInfo_t;
    
    typedef struct {
        const char* name;
        double      value;
    } FactValue_t;
    
    typedef struct {
72 73 74
        size_t                          cFactValues;
        const FactValue_t*              rgFactValues;
        double                          altValue;
75
        QGroundControlQmlGlobal::AltitudeMode altMode;
76 77
    } ItemExpected_t;

78 79 80
    SimpleMissionItem*  _simpleItem;
    MultiSignalSpy*     _spySimpleItem;
    MultiSignalSpy*     _spyVisualItem;
Don Gagne's avatar
Don Gagne committed
81

82 83 84 85 86 87 88 89 90 91 92
    static const ItemInfo_t     _rgItemInfo[];
    static const ItemExpected_t _rgItemExpected[];
    static const FactValue_t    _rgFactValuesWaypoint[];
    static const FactValue_t    _rgFactValuesLoiterUnlim[];
    static const FactValue_t    _rgFactValuesLoiterTurns[];
    static const FactValue_t    _rgFactValuesLoiterTime[];
    static const FactValue_t    _rgFactValuesLand[];
    static const FactValue_t    _rgFactValuesTakeoff[];
    static const FactValue_t    _rgFactValuesConditionDelay[];
    static const FactValue_t    _rgFactValuesDoJump[];
};