SimpleMissionItemTest.h 2.89 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 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35

typedef struct {
    MAV_CMD        command;
    MAV_FRAME      frame;
} ItemInfo_t;

typedef struct {
    const char*                 name;
    QGCMAVLink::VehicleClass_t  vehicleClass;
    bool                        nanValue;
    int                         paramIndex;
} FactValue_t;

typedef struct {
    size_t                          cFactValues;
    const FactValue_t*              rgFactValues;
    double                          altValue;
    QGroundControlQmlGlobal::AltitudeMode altMode;
} ItemExpected_t;

36
class SimpleMissionItemTest : public VisualMissionItemTest
37 38 39 40 41
{
    Q_OBJECT
    
public:
    SimpleMissionItemTest(void);
Don Gagne's avatar
Don Gagne committed
42

43
    void init   (void) override;
Don Gagne's avatar
Don Gagne committed
44 45
    void cleanup(void) override;

46
private slots:
47 48 49 50 51 52 53 54
    void _testSignals               (void);
    void _testEditorFacts           (void);
    void _testDefaultValues         (void);
    void _testCameraSectionDirty    (void);
    void _testSpeedSectionDirty     (void);
    void _testCameraSection         (void);
    void _testSpeedSection          (void);
    void _testAltitudePropogation   (void);
55

56
private:
57 58
    enum {
        commandChangedIndex = 0,
59
        altitudeModeChangedIndex,
60 61 62 63 64 65 66 67 68
        friendlyEditAllowedChangedIndex,
        headingDegreesChangedIndex,
        rawEditChangedIndex,
        cameraSectionChangedIndex,
        speedSectionChangedIndex,
        maxSignalIndex,
    };

    enum {
69
        commandChangedMask =                        1 << commandChangedIndex,
70
        altitudeModeChangedMask =                  1 << altitudeModeChangedIndex,
71 72 73 74 75
        friendlyEditAllowedChangedMask =            1 << friendlyEditAllowedChangedIndex,
        headingDegreesChangedMask =                 1 << headingDegreesChangedIndex,
        rawEditChangedMask =                        1 << rawEditChangedIndex,
        cameraSectionChangedMask =                  1 << cameraSectionChangedIndex,
        speedSectionChangedMask =                   1 << speedSectionChangedIndex,
76 77 78 79
    };

    static const size_t cSimpleItemSignals = maxSignalIndex;
    const char*         rgSimpleItemSignals[cSimpleItemSignals];
80

81 82
    void _testEditorFactsWorker (QGCMAVLink::VehicleClass_t vehicleClass, QGCMAVLink::VehicleClass_t vtolMode, const ItemExpected_t* rgExpected);
    bool _classMatch            (QGCMAVLink::VehicleClass_t vehicleClass, QGCMAVLink::VehicleClass_t testClass);
83

84 85 86
    SimpleMissionItem*  _simpleItem;
    MultiSignalSpy*     _spySimpleItem;
    MultiSignalSpy*     _spyVisualItem;
87
};