VisualMissionItemTest.cc 4.01 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
/****************************************************************************
 *
 *   (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.
 *
 ****************************************************************************/

#include "VisualMissionItemTest.h"
#include "SimpleMissionItem.h"
#include "QGCApplication.h"

VisualMissionItemTest::VisualMissionItemTest(void)
    : _offlineVehicle(NULL)
{
    
}

void VisualMissionItemTest::init(void)
{
    UnitTest::init();
    _offlineVehicle = new Vehicle(MAV_AUTOPILOT_PX4,
                                  MAV_TYPE_QUADROTOR,
                                  qgcApp()->toolbox()->firmwarePluginManager(),
                                  this);

    rgVisualItemSignals[altDifferenceChangedIndex] =                        SIGNAL(altDifferenceChanged(double));
    rgVisualItemSignals[altPercentChangedIndex] =                           SIGNAL(altPercentChanged(double));
    rgVisualItemSignals[azimuthChangedIndex] =                              SIGNAL(azimuthChanged(double));
    rgVisualItemSignals[commandDescriptionChangedIndex] =                   SIGNAL(commandDescriptionChanged());
    rgVisualItemSignals[commandNameChangedIndex] =                          SIGNAL(commandNameChanged());
    rgVisualItemSignals[abbreviationChangedIndex] =                         SIGNAL(abbreviationChanged());
    rgVisualItemSignals[coordinateChangedIndex] =                           SIGNAL(coordinateChanged(const QGeoCoordinate&));
    rgVisualItemSignals[exitCoordinateChangedIndex] =                       SIGNAL(exitCoordinateChanged(const QGeoCoordinate&));
    rgVisualItemSignals[dirtyChangedIndex] =                                SIGNAL(dirtyChanged(bool));
    rgVisualItemSignals[distanceChangedIndex] =                             SIGNAL(distanceChanged(double));
    rgVisualItemSignals[isCurrentItemChangedIndex] =                        SIGNAL(isCurrentItemChanged(bool));
    rgVisualItemSignals[sequenceNumberChangedIndex] =                       SIGNAL(sequenceNumberChanged(int));
    rgVisualItemSignals[isSimpleItemChangedIndex] =                         SIGNAL(isSimpleItemChanged(bool));
    rgVisualItemSignals[specifiesCoordinateChangedIndex] =                  SIGNAL(specifiesCoordinateChanged());
    rgVisualItemSignals[isStandaloneCoordinateChangedIndex] =               SIGNAL(isStandaloneCoordinateChanged());
    rgVisualItemSignals[specifiesAltitudeOnlyChangedIndex] =                SIGNAL(specifiesAltitudeOnlyChanged());
    rgVisualItemSignals[specifiedFlightSpeedChangedIndex] =                 SIGNAL(specifiedFlightSpeedChanged());
    rgVisualItemSignals[specifiedGimbalYawChangedIndex] =                   SIGNAL(specifiedGimbalYawChanged());
46
    rgVisualItemSignals[specifiedGimbalPitchChangedIndex] =                 SIGNAL(specifiedGimbalPitchChanged());
47 48 49 50 51 52 53 54 55 56 57 58 59
    rgVisualItemSignals[lastSequenceNumberChangedIndex] =                   SIGNAL(lastSequenceNumberChanged(int));
    rgVisualItemSignals[missionGimbalYawChangedIndex] =                     SIGNAL(missionGimbalYawChanged(double));
    rgVisualItemSignals[missionVehicleYawChangedIndex] =                    SIGNAL(missionVehicleYawChanged(double));
    rgVisualItemSignals[coordinateHasRelativeAltitudeChangedIndex] =        SIGNAL(coordinateHasRelativeAltitudeChanged(bool));
    rgVisualItemSignals[exitCoordinateHasRelativeAltitudeChangedIndex] =    SIGNAL(exitCoordinateHasRelativeAltitudeChanged(bool));
    rgVisualItemSignals[exitCoordinateSameAsEntryChangedIndex] =            SIGNAL(exitCoordinateSameAsEntryChanged(bool));
}

void VisualMissionItemTest::cleanup(void)
{
    delete _offlineVehicle;
    UnitTest::cleanup();
}
60 61 62 63 64 65 66 67

void VisualMissionItemTest::_createSpy(SimpleMissionItem* simpleItem, MultiSignalSpy** visualSpy)
{
    *visualSpy = NULL;
    MultiSignalSpy* spy = new MultiSignalSpy();
    QCOMPARE(spy->init(simpleItem, rgVisualItemSignals, cVisualItemSignals), true);
    *visualSpy = spy;
}