SimpleMissionItemTest.h 3.2 KB
Newer Older
1 2 3 4 5 6 7 8 9
/****************************************************************************
 *
 *   (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
 *
 * 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
        friendlyEditAllowedChangedIndex,
        headingDegreesChangedIndex,
        rawEditChangedIndex,
        cameraSectionChangedIndex,
        speedSectionChangedIndex,
45
        coordinateHasRelativeAltitudeChangedIndex,
46 47 48 49
        maxSignalIndex,
    };

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

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

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

80 81 82
    SimpleMissionItem*  _simpleItem;
    MultiSignalSpy*     _spySimpleItem;
    MultiSignalSpy*     _spyVisualItem;
Don Gagne's avatar
Don Gagne committed
83

84 85 86 87 88 89 90 91 92 93 94
    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[];
};