SimpleMissionItemTest.h 2.87 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 34
    void _testCameraSection(void);
    void _testSpeedSection(void);

35
private:
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
    enum {
        commandChangedIndex = 0,
        frameChangedIndex,
        friendlyEditAllowedChangedIndex,
        headingDegreesChangedIndex,
        rawEditChangedIndex,
        cameraSectionChangedIndex,
        speedSectionChangedIndex,
        maxSignalIndex,
    };

    enum {
        commandChangedMask =                1 << commandChangedIndex,
        frameChangedMask =                  1 << frameChangedIndex,
        friendlyEditAllowedChangedMask =    1 << friendlyEditAllowedChangedIndex,
        headingDegreesChangedMask =         1 << headingDegreesChangedIndex,
        rawEditChangedMask =                1 << rawEditChangedIndex,
        cameraSectionChangedMask =          1 << cameraSectionChangedIndex,
        speedSectionChangedMask =           1 << speedSectionChangedIndex
    };

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

    typedef struct {
        MAV_CMD        command;
        MAV_FRAME      frame;
    } ItemInfo_t;
    
    typedef struct {
        const char* name;
        double      value;
    } FactValue_t;
    
    typedef struct {
        size_t              cFactValues;
        const FactValue_t*  rgFactValues;
        bool                relativeAltCheckbox;
    } ItemExpected_t;

76 77 78
    SimpleMissionItem*  _simpleItem;
    MultiSignalSpy*     _spySimpleItem;
    MultiSignalSpy*     _spyVisualItem;
Don Gagne's avatar
Don Gagne committed
79

80 81 82 83 84 85 86 87 88 89 90
    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[];
};